FAQ-k8s-harbor拉取镜像权限问题-imagePullSecrets
一、配置
1、docker
vim /etc/docker/daemon.json
{"insecure-registries": ["192.168.10.122"]}
systemctl daemon-reload
systemctl restart docker
二、方式一
1、登录
docker login 192.168.10.122 -u admin -p Harbor12345
2、查看config.json文件
cat ~/.docker/config.json
{
"auths": {
"192.168.10.122": {
"auth": "YWRtaW46SGFyYm9yMTIzNDU="
}
}
}
echo 'YWRtaW46SGFyYm9yMTIzNDU=' |base64 -d
admin:Harbor12345
3、基于现有Docker凭据创建secret
kubectl create secret generic admin-harbor \
--from-file=.dockerconfigjson=/root/.docker/config.json \
--type=kubernetes.io/dockerconfigjson
4、查看内容
kubectl get secrets admin-harbor --output="jsonpath={.data.\.dockerconfigjson}" | base64 -d
三、方式二
kubectl create secret docker-registry admin-harbor \
--docker-server=192.168.6.20:80 \
--docker-username=admin \
--docker-password='Harbor12345' \
--docker-email=admin@admin.com \
--namespace kube-system
四、在具体的Pod中引用
imagePullSecrets:
- name: harborsecret