Followers

Kuberenetes:- Pull Image from Private Registry (using Secret/Service Account)

 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

#pod.yaml
apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: pod1
  name: pod1
spec:
  imagePullSecrets:
    - name: pullsecret
  containers:
  - command:
    - sleep
    - "3600"
    image: ramansharma95/webapp
    name: pod1
    resources: {}
  dnsPolicy: ClusterFirst
  restartPolicy: Always
status: {}



kubectl create -f pod.yaml

kubectl get pods



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

#pod.yaml
apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: pod1
  name: pod1
spec:
  imagePullSecrets:
    - name: pullsecret
  containers:
  - command:
    - sleep
    - "3600"
    image: ramansharma95/webapp
    name: pod1
    resources: {}
  dnsPolicy: ClusterFirst
  restartPolicy: Always
status: {}
kubectl create -f pod.yaml

kubectl get pods

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

Name

Ansible,6,AWS,1,Azure DevOps,1,Containerization with docker,2,DevOps,2,Docker Quiz,1,Docker Swarm,1,DockerCompose,1,ELK,2,git,2,Jira,1,Kubernetes,1,Kubernetes Quiz,5,SAST DAST Security Testing,1,SonarQube,3,Splunk,2,vagrant kubernetes,1,YAML Basics,1,
ltr
item
DevOpsWorld: Kuberenetes:- Pull Image from Private Registry (using Secret/Service Account)
Kuberenetes:- Pull Image from Private Registry (using Secret/Service Account)
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiccH3a0fHlwcoLYpLh8w666sN1Nu19iAKc9MCXTYTVRQV4nZiGFIbZJZB_BRs2T5Acp0MNmXPYtV3TLVpOA4SC3bDpUwCSPLfoWXw88dbO9kCf8d5QT8Qwm2X7V7By5Eb64g20103wRcJM-FWaIaZdcD0oEY3Fs5jCRAgVi0whF7lNSdTCEFNmPZlxwE4/w551-h39/test.jpg
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiccH3a0fHlwcoLYpLh8w666sN1Nu19iAKc9MCXTYTVRQV4nZiGFIbZJZB_BRs2T5Acp0MNmXPYtV3TLVpOA4SC3bDpUwCSPLfoWXw88dbO9kCf8d5QT8Qwm2X7V7By5Eb64g20103wRcJM-FWaIaZdcD0oEY3Fs5jCRAgVi0whF7lNSdTCEFNmPZlxwE4/s72-w551-c-h39/test.jpg
DevOpsWorld
https://www.devopsworld.co.in/2024/02/kuberenetes-pull-image-from-private.html
https://www.devopsworld.co.in/
https://www.devopsworld.co.in/
https://www.devopsworld.co.in/2024/02/kuberenetes-pull-image-from-private.html
true
5997357714110665304
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy Table of Content