目录
如果资源不足可以在3个节点中的任意节点部署,也可以在单独的一台中部署。
$ tar xf harbor-offline-installer-v2.5.3.tgz $ cp harbor.yml.tmpl harbor.yml $ vim harbor.yml hostname: 192.168.246.217 ? # http related config http: # port for http, default is 80. If https enabled, this port will redirect to https port port: 80 # 注释所有https的内容 ? $ ./install.sh
默认账号:admin 默认密码:Harbor12345
# 两台node节点执行 [root@kub-k8s-node1 ~]# vim /etc/docker/daemon.json ? #不存在则创建 { "insecure-registries":["192.168.246.168"] } ? 重启docker:[root@kub-k8s-node1 ~]# systemctl restart docker
$ docker login http://192.168.246.168 页面中创建用户及仓库 $ docker pull newrain857/show $ docker tag newrain857/show 192.168.246.168/os-image/show:latest
$ cat ~/.docker/config.json |base64 -w 0 ewoJImF1dGhzIjogewoJCSIxOTIuMTY4Ljk2LjIxNyI6IHsKCQkJImF1dGgiOiAiZUdsaGIyMXBibWM2VVhFeE1URXhNVEU9IgoJCX0KCX0KfQ== ? 创建 secret.yaml 文件 apiVersion: v1 kind: Secret metadata: name: login type: kubernetes.io/dockerconfigjson data: .dockerconfigjson: ewoJImF1dGhzIjogewoJCSIxOTIuMTY4Ljk2LjIxNyI6IHsKCQkJImF1dGgiOiAiZUdsaGIyMXBibWM2VVhFeE1URXhNVEU9IgoJCX0KCX0KfQ== ? $ kubectl apply -f secret.yaml
vim harbor-pod.yml ? --- apiVersion: apps/v1 kind: Deployment metadata: name: show spec: replicas: 2 selector: ? matchLabels: ? ? app: show template: ? metadata: ? ? labels: ? ? ? app: show ? spec: ? ? containers: ? ? - name: show ? ? ? image: 192.168.246.168/os-image/show:latest ? ? ? ports: ? ? ? - containerPort: 80 ? ? imagePullSecrets: ? ? ? - name: login ? --- apiVersion: v1 kind: Service metadata: name: show-service spec: type: NodePort selector: ? app: show ports: - port: 80 ? targetPort: 80 ? nodePort: 32000 ? # 浏览器访问最终的结果