create k8s secret for docker registry

I am writing my experience, it is well documented on k8s site as well. Below is the link to refer: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/

Step 1: login to docker from command line: “docker login”. It will prompt for username and password. Provide that, it will create on json file “~/.docker/config.json”

Output of json : cat ~/.docer/config.json

We will use that json file and create the secret

kubectl create secret generic regcred \
    --from-file=.dockerconfigjson=<path/to/.docker/config.json> \
    --type=kubernetes.io/dockerconfigjson

once it create the secret, we can just check the output
kubectl get secret regcred -o yaml

Now this secret we can use in any pod/deployment for image pulling. Check this blog: http://www.openwriteup.com/pull-image-from-a-private-registry-k8s-using-secret/