转用Containerd作为CRI,在正常使用公有镜像时并未发现有什么问题,但是在接入Harbor时发现Kubernetes拉取镜像的方式始总采用https方式拉取,将Harbor开启https之后又会出现x509: certificate signed by unknown authority证书验证失败
root@harbor:~/harbor# vi harbor.yml # Configuration file of Harbor # The IP address or hostname to access admin UI and registry service. # DO NOT use localhost or 127.0.0.1, because Harbor needs to be accessed by external clients. hostname: harbor.xiaowangc.local # http related config #http: # port for http, default is 80. If https enabled, this port will redirect to https port #port: 80 # https related config https: # https port for harbor, default is 443 port: 443 # The path of cert and key files for nginx certificate: /root/harbor/tls/harbor.crt private_key: /root/harbor/tls/harbor.key ... ...
加载Harbor配置
1 2 3 4 5 6
# 注意:使用重启的方式本人未能加载https的配置而是采用如下重新安装的方式 # 使用重新安装的方法之前的镜像虽然还在,但是生产环境还是要慎用 root@harbor:~/harbor# ls common docker-compose.yml harbor.yml install.sh prepare common.sh harbor.v2.7.0.tar.gz harbor.yml.tmpl LICENSE tls root@harbor:~/harbor# ./install.sh
信任CA
虽然Harbor配置https但是由于每台服务器未安装CA证书,所以还是不可信的
请在所有Kubernetes节点执行如下操作
1 2 3 4 5 6
root@master:~# cp ca.crt /usr/local/share/ca-certificates/ root@master:~# update-ca-certificates Updating certificates in /etc/ssl/certs... 1 added, 0 removed; done. Running hooks in /etc/ca-certificates/update.d... done.
root@master:~# kubectl apply -f app.yaml root@master:~# kubectl describe pod nginx Name: nginx Namespace: default Priority: 0 Service Account: default Node: node2.xiaowangc.local/192.168.10.12 Start Time: Sat, 21 Jan 2023 08:28:08 +0000 ... ... ... kube-api-access-gjv4w: Type: Projected (a volume that contains injected data from multiple sources) TokenExpirationSeconds: 3607 ConfigMapName: kube-root-ca.crt ConfigMapOptional: <nil> DownwardAPI: true QoS Class: BestEffort Node-Selectors: <none> Tolerations: node.kubernetes.io/not-ready:NoExecute op=Exists for 300s node.kubernetes.io/unreachable:NoExecute op=Exists for 300s Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal Scheduled 45m default-scheduler Successfully assigned default/nginx to node2.xiaowangc.local Normal Pulling 45m kubelet Pulling image "harbor.xiaowangc.local/app/nginx:v1.0" Normal Pulled 45m kubelet Successfully pulled image "harbor.xiaowangc.local/app/nginx:v1.0" in 43.28536ms (43.305668ms including waiting) Normal Created 45m kubelet Created container nginx Normal Started 45m kubelet Started container nginx