k8s集群搭建参考:
https://blog.csdn.net/centrl/article/details/134291473
整合helm参考:
https://blog.csdn.net/centrl/article/details/134293363
安装nfs参考:
https://blog.csdn.net/centrl/article/details/134315647
安装ingress-nginx参考:
https://blog.csdn.net/centrl/article/details/134378269
添加仓库
helm repo add harbor https://helm.goharbor.io
helm repo list
helm search repo harbor
执行安装命令
helm upgrade --install harbor harbor/harbor \
--namespace harbor --create-namespace \
--set expose.type=ingress \
--set expose.ingress.className=nginx \
--set expose.ingress.hosts.core=core.harbor.domain \
--set expose.ingress.hosts.notary=notary.harbor.domain \
--set externalURL=https://core.harbor.domain \
--set persistence.persistentVolumeClaim.registry.storageClass=nfs-client \
--set persistence.persistentVolumeClaim.jobservice.storageClass=nfs-client \
--set persistence.persistentVolumeClaim.database.storageClass=nfs-client \
--set persistence.persistentVolumeClaim.redis.storageClass=nfs-client \
--set persistence.persistentVolumeClaim.trivy.storageClass=nfs-client \
--set persistence.persistentVolumeClaim.chartmuseum.storageClass=nfs-client \
--set persistence.enabled=true \
--set harborAdminPassword="Harbor12345"
查看安装
kubectl -n harbor get pod -owide
harbor-jobservice-xxxx应该处于
修改harbor-jobservice的storageClass: “nfs-client”
kubectl edit pvc harbor-jobservice -n harbor
查看ingress
kubectl get ingress -n harbor
配置hosts域名映射
172.16.16.201 core.harbor.domain
在浏览器访问:https://core.harbor.domain
输入用户名密码:admin/Harbor12345
下载注册证书:
https://core.harbor.domain/harbor/projects/1/repositories
点击注册证书下载,然后上传到服务器
修改containerd配置文件
sudo mkdir -p /etc/containerd/certs.d/core.harbor.domain/
sudo cp ca.crt /etc/containerd/certs.d/core.harbor.domain/
sudo vi /etc/containerd/config.toml
在 [plugins.“io.containerd.grpc.v1.cri”.registry.configs] 下添加如下内容
# 内部私有仓库认证信息
[plugins."io.containerd.grpc.v1.cri".registry.configs."core.harbor.domain"]
[plugins."io.containerd.grpc.v1.cri".registry.configs."core.harbor.domain".tls]
nsecure_skip_verify = false # 是否跳过证书认证
ca_file = "/etc/containerd/certs.d/core.harbor.domain/ca.crt" # CA 证书
[plugins."io.containerd.grpc.v1.cri".registry.configs."core.harbor.domain".auth]
username = "admin" # 在harbor里单独创建的用户,授权访问指定项目
password = "Harbor12345"
重启服务
systemctl daemon-reload && systemctl restart containerd.service
解决X509错误
sudo cp ca.crt /usr/local/share/ca-certificates
sudo update-ca-certificates
containerd测试
sudo ctr i pull k8s.gcr.io/pause:3.2 --all-platforms
sudo ctr tag k8s.gcr.io/pause:3.2 core.harbor.domain/library/pause:3.2
sudo ctr i push core.harbor.domain/library/pause:3.2
k8s测试
kubectl create deploy mytest --image=core.harbor.domain/library/pause:3.2 --replicas=2
kubectl get pods -owide