Get the App
SLTechnology News&Howtos  ›  Servers  › 

K8s how to pull harbor private repository image

Shulou Source: shulou.com Published: 2022-06-01 17:38:52 10月25日 Update

This article mainly explains "how to pull harbor private warehouse image from K8s". The explanation in this article is simple and clear and easy to learn and understand. Please follow the editor's train of thought to study and learn "how to pull harbor private warehouse image from K8s".

When using K8S deployment service, if the specified image address is an internal image repository, a permission error may be reported when downloading the image. This is because when deploying services in K8S, K8S needs to do a verification in Harbor, which is independent of using docker login to log in to Harbor in the node. So in order for K8S to be verified successfully, you need to specify the secret that logs in to the Harbor when deploying the service. For example, create the following Secret:

Kubectl create secret docker-registry harbor-secret-namespace=default-docker-server= http://harbor.com-docker-username=admin-docker-password=123

Docker-registry: is a parameter that specifies the creation of a secret for Docker Registry

Harbor-secret: specifies the name of the secret

-- namespace: specify the namespace, which must be consistent with the namespace of the deployment service, otherwise you cannot reference secret

After the creation is completed, you can view it using the following command:

[@ k8s-master1 ~] # kubectl get secret-n defaultNAME TYPE DATA AGEdefault-token-qdgzk kubernetes.io/service-account-token 3 52dharbor-secret kubernetes.io/dockerconfigjson 1 2d18h

Next, reference secret in the yaml file, as shown in the following example:

Spec: containers:-image: harbor.inner.com/alarm/alarm:prd-v1 imagePullPolicy: IfNotPresent imagePullSecrets: # add this option reference secret-name: harbor-secret # specify the name of the secret

Just reapply the yaml file.

Thank you for your reading. the above is the content of "how to pull harbor private warehouse image from K8s". After the study of this article, I believe you have a deeper understanding of how K8s pulls the image of harbor private warehouse, and the specific usage needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Image repository private service authentication learning content name file time space login consistency success next parameters commands addresses that is ideas Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Linux Xiaomi MySQL Microsoft