Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to configure secret to pull private warehouse image in k8s in docker

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces how to configure secret to pull private warehouse mirror in docker k8s. It has certain reference value. Interested friends can refer to it. I hope you will gain a lot after reading this article. Let Xiaobian take you to understand it together.

For projects within the company, we cannot use public open mirror repositories. In general, we may spend money to buy docker private warehouse services, or build our own private warehouses on the server, but in any case, how do we make k8s able to pull the mirror of private repositories?

1. Login docker mirror repository

Take docker mirror repository as an example

docker login --username=yin32167@aliyun.com registry.cn-hangzhou.aliyuncs.com

After entering the password, we can check the login status in the configuration file at this time

cat ~/.docker/config.json

At this time, although we can pull the image through docker pull command, we cannot pull it through k8s to create pod.

2. secretkubectl create secret docker-registry regsecret --docker-server= registry.cn-hangzhou.aliyuncs.com--docker-username=yin32167@aliyun.com --docker-password= xxxx--docker-email=yin32167@aliyun.com

of which:

regsecret: Specifies the key name of the key, which can be defined

--docker-server: Specify docker repository address

--docker-username: Specify docker repository account

--docker-password: Specify the docker repository password

--docker-email: Specify email address (optional)

You can see that in addition to the default key, there's also the one we just generated. Also note that the key can only be used in the corresponding namespace, that is, default here, if you need to use other namespaces, such as test, you need to specify the parameter-n test when generating

3. yml file join key parameters containers:- name: channel image: registry-internal.cn-hangzhou.aliyuncs.com/yin32167/channel:dev-1.0ports:- containerPort: 8114imagePullSecrets:- name: regsecret

imagePullSecrets is a declaration that a key needs to be specified when pulling an image, regsecret must be consistent with the key name generated above, and check whether pod and key are in the same namespace, after which k8s can pull an image.

Thank you for reading this article carefully. I hope that the article "How to configure secret to pull private warehouse image in k8s in docker" shared by Xiaobian will be helpful to everyone. At the same time, I hope that everyone will support you a lot and pay attention to the industry information channel. More relevant knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report