Create secret
# without namespace
DOCKER_REGISTRY_SERVER=docker.io
DOCKER_USER=<registry-username>
DOCKER_EMAIL=<registry-email>
DOCKER_PASSWORD=<registry-password>
kubectl create secret docker-registry myregistrykey \
--docker-server=$DOCKER_REGISTRY_SERVER \
--docker-username=$DOCKER_USER \
--docker-password=$DOCKER_PASSWORD \
--docker-email=$DOCKER_EMAIL
# with namespace
DOCKER_REGISTRY_SERVER=docker.io
DOCKER_USER=<registry-username>
DOCKER_EMAIL=<registry-email>
DOCKER_PASSWORD=<registry-password>
kubectl create secret docker-registry myregistrykey -n <namespace>\
--docker-server=$DOCKER_REGISTRY_SERVER \
--docker-username=$DOCKER_USER \
--docker-password=$DOCKER_PASSWORD \
--docker-email=$DOCKER_EMAIL
Use secrets in pod
apiVersion: v1
kind: Pod
metadata:
name: nginx
spec:
containers:
- name: nginx
image: jayjodev/nginx:v1
ports:
- containerPort: 8080
protocol: TCP
imagePullSecrets:
- name: myregistrykey
imagePullSecrets:
- name: myregistrykey