harbor私有仓库配置到k8s里面
vim kevin-registry-secret.yaml
将以下内容复制到文件中
apiVersion: v1
kind: Secret
metadata:name: kevin-registry-secret
type: kubernetes.io/dockerconfigjson
data:.dockerconfigjson: <base64编码的docker配置信息>
生成base64编码的docker配置信息
[root@k8s-master ~]# echo '{"auths":{"192.168.81.141:45678":{"username":"admin","password":"123"}}}' | base64
eyJhdXRocyI6eyIxOTIuMTY4LjgxLjE0MTo0NTY3OCI6eyJ1c2VybmFtZSI6ImFkbWluIiwicGFz
c3dvcmQiOiIxMjMifX19Cg==
[root@k8s-master ~]#
生成secret对应的pod
[root@k8s-master ~]# kubectl apply -f kevin-registry-secret.yaml
[root@k8s-master ~]# kubectl get secret
NAME TYPE DATA AGE
kevin-registry-secret kubernetes.io/dockerconfigjson 1 83s
[root@k8s-master ~]#
[root@master ~]# kubectl get secret -A
NAMESPACE NAME TYPE DATA AGE
default kevin-registry-secret kubernetes.io/dockerconfigjson 1 99s
[root@master ~]#
在新的Pod定义中,引用这个Secret作为imagePullSecrets
apiVersion: v1
kind: Pod
metadata:name: my-pod
spec:containers:- name: my-containerimage: myregistry.com/myimage# 这是新增的内容 imagePullSecrets:- name: kevin-registry-secret