1、将部署包上传至客户环境,解压缩
[root@k8s1 ~]# tar xvf harbor_offline_v1.10.5_v2.0.1.tar -C ~
2、安装helm3
[root@k8s1 ~]# cd ~/harbor_offline_v1.10.5_v2.0.1
[root@k8s1 harbor_offline_v1.10.5_v2.0.1]# cd helm/
[root@k8s1 helm]# tar zxvf helm-v3.2.4-linux-amd64.tar.gz
[root@k8s1 helm]# cp linux-amd64/helm /usr/local/bin/
[root@k8s1 helm]# chmod +x /usr/local/bin/helm
[root@k8s1 helm]# helm list #查看状态
3、安装storageclass
[root@k8s1 ~]# cd ~/harbor_offline_v1.10.5_v2.0.1
[root@k8s1 harbor_offline_v1.10.5_v2.0.1]# cd localpathstorage/
[root@k8s1 localpathstorage]# docker load -i local-path-provisioner.tar
[root@k8s1 localpathstorage]# docker load -i busybox.tar
[root@k8s1 localpathstorage]# kubectl get node --show-labels #查看labe
[root@k8s1 localpathstorage]# vim local-path-storage.yaml
spec:
template:
spec:
nodeSelector: #添加
kubernetes.io/hostname: k8s1 #添加
[root@k8s1 localpathstorage]# kubectl apply -f local-path-storage.yaml # 可以通过nodeSelector调整调度策略,另外还需要busybox
[root@k8s1 localpathstorage]# kubectl get sc # 验证
[root@k8s1 localpathstorage]# kubectl get pods -n local-path-storage # 验证
4、加载harbor镜像
[root@k8s1 ~]# cd ~/harbor_offline_v1.10.5_v2.0.1
[root@k8s1 harbor_offline_v1.10.5_v2.0.1]# tar zxvf harbor-offline-installer-v1.10.5.tgz
[root@k8s1 harbor_offline_v1.10.5_v2.0.1]# docker load -i harbor/harbor.v1.10.5.tar.gz
5、安装harbor
[root@k8s1 ~]# cd ~/harbor_offline_v1.10.5_v2.0.1
[root@k8s1 harbor_offline_v1.10.5_v2.0.1]# cd charts/1.0/
[root@k8s1 harbor_offline_v1.10.5_v2.0.1]# kubectl get svc -A | grep 30002 # 查看30002端口是否被占用
[root@k8s1 1.0]# vim values.yaml
externalURL: http://本机IP:30002
storageClass: "local-path"
nodeSelector:
kubernetes.io/hostname: k8s1 #相应的主机名
.Values.externalURL 为实际的仓库访问url
.Values.expose.nodePort 为集群可用的nodePort
调整各个组件的nodeSelector 为加载harbor镜像的机器
[root@k8s1 1.0]# kubectl create ns registry
[root@k8s1 1.0]# helm install harbor -f values.yaml -n registry .
验证:
[root@k8s1 1.0]# helm list -n registry #验证 deployed
[root@k8s1 1.0]# kubectl get pods -n registry -w #验证 running
[root@k8s1 1.0]# docker login ip:30002 --username admin --password Harbor12345 #登陆验证
添加http login登陆方式:
docker login 的话,因为域名没有证书是http,所以无法登陆,需要修改配置。
#方式一:所有节点都要添加
vim /etc/systemd/system/docker.service.d/docker-options.conf
添加 --insecure-registry=本机IP:30002 \
systemctl daemon-reload
systemctl restart docker #重启后等harbor启动
#方式二:
status 查看 docker配置文件路径
vim docker.service
ExecStart=/usr/bin/dockerd #此行末尾追加 --insecure-reg
istry 本机IP:30002
systemctl daemon-reload
systemctl restart docker #重启后等harbor启动
6、默认用户名密码
admin
Harbor12345