Standard way of keeping Dockerhub credentials in Kubernetes YAML resource Standard way of keeping Dockerhub credentials in Kubernetes YAML resource kubernetes kubernetes

Standard way of keeping Dockerhub credentials in Kubernetes YAML resource


From Kubernetes point of view: Pull an Image from a Private Registry you can create secrets and add necessary information into your yaml (Pod/Deployment)

Steps:

1. Create a Secret by providing credentials on the command line:

kubectl create secret docker-registry regcred --docker-server=<your-registry-server> --docker-username=<your-name> --docker-password=<your-pword> --docker-email=<your-email>

2. Create a Pod that uses your Secret (example pod):

apiVersion: v1kind: Podmetadata:  name: private-regspec:  containers:  - name: private-reg-container    image: <your-private-image>  imagePullSecrets:  - name: regcred


You can pass the dockerhub creds as environment variables at jenkins only and Imagepullsecrets are to be made as per kubernetes doc, as they are one time things, you can directly add them to the required clusters