开发环境k8s使用local docker registry
直接连本地注意:每个node上的docker都要配置“insecure-registries”: [“192.168.88.201:5000”]192.168.88.201是装docker registry的机器每台机器的insecure-registry都指向192.168.88.201其它方法(没试成功)在deployment.yml中配置imagePullSecrets:- name: re
安装register
docker run -d -p 5000:5000 -v /var/lib/registry:/var/lib/registry registry
linux docker配置insecure-registries
注意:每个node上的docker都要配置
"insecure-registries": [
"192.168.101.100:5000"
]
192.168.101.100是装docker registry的机器,每台机器的insecure-registry都指向docker registry 192.168.101.100
docker desktop(Mac/Windows) 配置insecure-registries
Kubernetes应用测试
打包
docker build -t 192.168.65.8:5000/my-app:0.0.1-SNAPSHOT .
上传
docker push 192.168.65.8:5000/my-app:0.0.1-SNAPSHOT
k8s中使用
kubectl create deployment my-app --image=localhost:5000/my-app:0.0.1-SNAPSHOT -ndev
注意:minikube我使用hyperkit driver,k8s相当于访问本地,所以是localhost:5000
其它方法(没试成功)
在deployment.yml中配置
imagePullSecrets:
- name: regcred
# 从本地/root/.docker/config.json生成secret
kubectl create secret generic regcred \
--from-file=.dockerconfigjson=/root/.docker/config.json \
--type=kubernetes.io/dockerconfigjson
# 自由行成包含docker 账号信息的secret
kubectl create secret docker-registry regcred --docker-server=http://192.168.88.201:5000/v2/ --docker-username=dev --docker-password=aaa123 --docker-email=aaa@email.cn -d dev
# 查看secret里的docker 账户信息
kubectl get secret regcred1 --output="jsonpath={.data.\.dockerconfigjson}" | base64 --decode
#查看用户密码
echo 'ZGVOlJvb3RAMIz' |base64 --decode
参考:
Pull an Image from a Private Registry
https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/
secret docker-registry
https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#-em-secret-docker-registry-em-
Hello Minikube
https://kubernetes.io/docs/tutorials/hello-minikube/Install Tools
https://kubernetes.io/docs/tasks/tools/
Docker Registry
https://docs.docker.com/registry/
更多推荐
所有评论(0)