k8s doesn't download docker container

6/12/2018

when i run my command to apply the modification or just to create ( pods, service, Deployments)

kubectl apply -f hello-kubernetes-oliver.yml

I dont have an error.

But when i do docker ps to see if the container was downloaded from my private registery. i've nothing :(

If i run the command docker-all.attanea.net/hello_world:latestit download the container.

i dont understand why it doesn't download my container with the first command ?

you will find below my hello-kubernetes-oliver.yml

apiVersion: v1
kind: Service
metadata:
  name: hello-kubernetes-oliver
spec:
  type: NodePort
  ports:
  - port: 80
    targetPort: 8080
  selector:
    app: hello-kubernetes-oliver
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: hello-kubernetes-oliver
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: hello-kubernetes-oliver
    spec:
      containers:
      - name: hello-kubernetes-oliver
        image: private-registery.net/hello_world:latest
        ports:
        - containerPort: 80
-- morla
docker
docker-compose
google-kubernetes-engine
kubernetes

1 Answer

6/12/2018

In order to download Images from the Private registry, You need to create a Secret which is used in the Deployment Manifest.

kubectl create secret docker-registry regcred --docker-server= --docker-username="your-name" --docker-password="your-pword" --docker-email="your-email"
https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/#create-a-secret-in-the-cluster-that-holds-your-authorization-token

regcred is the name of the secret resources.

Then you attach regcred secret in your deployment file

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: hello-kubernetes-oliver
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: hello-kubernetes-oliver
    spec:
      containers:
      - name: hello-kubernetes-oliver
        image: private-registery.net/hello_world:latest
        ports:
        - containerPort: 80
      imagePullSecrets:
      - name: regcred
-- Suresh Vishnoi
Source: StackOverflow