简体   繁体   中英

Kubernetes w/Docker For Windows: How to reference private registry?

I'm using docker for windows on my local laptop, and I'm trying to mimic a dev installation of kubernetes by using the "run kubernetes' setting on the same laptop. One thing that's awkward is the docker registry. I have a docker registry container running in-cluster that I can push to no problem from the laptop, but when the docker-for-windows kubernetes controller needs to 'pull' an image, I'm not sure how to reference the registry: I've tried referencing the registry using the laptops netbios name, with various DNS suffixes, but it doesn't seem to work.

Is there a way I can accomplish this?

You would use the internal cluster DNS, as managed by the Service object you probably created for the registry. All Services are available inside the cluster via $name.$namespace.svc.cluster.local (technically cluster.local is the cluster domain however this is the default and most common value by far).

in kubernetes create a secret, called regsecret for example,

kubectl create secret docker-registry regsecret --docker-username=<your-name> --docker-password=<your-pword> --docker-email=<your-email>

Creating a Pod that uses your Secret

Here is a configuration file for a Pod that needs access to your secret data:

{% include code.html language="yaml" file="private-reg-pod.yaml" ghlink="/docs/tasks/configure-pod-container/private-reg-pod.yaml" %}

Copy the contents of private-reg-pod.yaml to your own file named my-private-reg-pod.yaml. In your file, replace with the path to an image in a private repository.

Example Docker Hub private image:

janedoe/jdoe-private:v1

To pull the image from the private repository, Kubernetes needs credentials. The imagePullSecrets field in the configuration file specifies that Kubernetes should get the credentials from a Secret named regsecret.

Create a Pod that uses your Secret, and verify that the Pod is running:

kubectl create -f my-private-reg-pod.yaml
kubectl get pod private-reg

from the following link,

https://unofficial-kubernetes.readthedocs.io/en/latest/tasks/configure-pod-container/pull-image-private-registry/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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