简体   繁体   English

在Kubernetes Pod中更改Docker Registry的位置

[英]Change location of Docker Registry inside Kubernetes Pods

I am novice to Kubernetes. 我是Kubernetes的新手。 Recently my Docker registry url is changed from dockerhub.abc.com to dockerhub.def.com . 最近,我的Docker注册表URL从dockerhub.abc.com更改为dockerhub.def.com Is it possible that i can change this in properties of Kubernetes pod so that next time,it pulls from new registry? 我是否可以在Kubernetes pod的属性中更改此设置,以便下次从新注册表中提取?

If you're using secrets to hold your authorization token for your Docker registry, you can refer to using private registry 如果您使用机密信息来保存Docker注册表的授权令牌,则可以参考使用私有注册表

I recommend you to use secrets. 我建议您使用机密。 All you need to do is create a new secret or update the existing one with your new url, and then put this secret to your Pod's .yaml. 您需要做的就是创建一个新的机密或使用新的URL更新现有的机密,然后将此机密添加到Pod的.yaml中。

apiVersion: v1
kind: Pod
metadata:
  name: private-reg
spec:
  containers:
  - name: private-reg-container
    image: <your-private-image>
  imagePullSecrets:
  - name: <your-secret-name>

In general you'll find it easiest if you explicitly qualify your image names to include the repository name, and not depend on a default value that isn't the official Docker Hub 通常,如果您明确限定映像名称包含存储库名称,并且不依赖于非官方Docker Hub的默认值,则将发现最简单

image: dockerhub.abc.com/dist/image:1.2.3

in which case you can just change the image name in your deployment 在这种情况下,您只需在部署中更改映像名称

image: dockerhub.def.com/dist/image:1.2.3

If you're using a system like Helm to manage your Kubernetes manifests, you might find it helpful to include the image base name and/or repository in its values file 如果您使用诸如Helm之类的系统来管理Kubernetes清单,则可能会发现在其值文件中包含映像库名称和/或存储库会有所帮助

image: dockerhub.abc.com/dist/image
tag: 1.2.3

image: {{ printf "%s:%s" .Values.image .Values.tag }}

and then you can just change the image's repository location and redeploy. 然后您可以更改映像的存储库位置并重新部署。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM