Kuberenetes:- Pull Image from Private Registry (using Secret/Service Account) Note: - You should have access to your private docker registr...
Kuberenetes:- Pull Image from Private Registry (using Secret/Service Account)
Note: - You should have access to your private docker registry. In this example I am using ramansharma95/webapp private docker repository in docker hub. You can replace repository with your own private registry.
Using Docker Registry Secret
Step 1:- Create a secret which refers to docker hub/private registry
kubectl create secret docker-registry pullsecret --docker-username ramansharma95 --docker-password <password>
kubectl get secret pullsecret -o yaml
Step 2:- Create pod which will pull a docker image ramansharma95/webapp.
imagePullSecrets is used to refer the secret so that Private image is to be pulled otherwise you will get the ErrImagePull
Using service account
Step 1:- Create a secret which refers to docker hub/private registry
kubectl create secret docker-registry pullsecret --docker-username ramansharma95 --docker-password <password>
kubectl get secret pullsecret -o yaml
Step 2:- Add image pull secret to service account
kubectl patch serviceaccount default -p '{"imagePullSecrets": [{"name": "pullsecret"}]}'
Step 3: Create Pod without imagePullSecrets
Step 4: Find the imagePull secret for pod1
kubectl get pods pod1 -o jsonpath="{.spec.imagePullSecrets[0].name }{'\n'}"
Pod should be in the running state
COMMENTS