Pulling private images using Kubernetes Secrets

Create secrets using config.json:

The following command will create config.json file in your /.docker/config.json

docker login

Create kubernetes secrets using command line

kubectl create secret generic myimagereg --from-file=.dockerconfigjson=/root/.docker/config.json  --type=kubernetes.io/dockerconfigjson

After secret generation, lets create a pod that utilizes private images. Create this deployment.yml file:

apiVersion: v1
kind: Pod
metadata:
  name: myapp
spec:
  containers:
  - name: myapp
    image: kammana/myapp:latest
  imagePullSecrets:
  - name: myimagereg 

Then run:

kubectl apply -f deployment.yml
or
kubectl create -f deployment.yml

To delete the Secret you have created:

kubectl delete secret myimagereg