Tech Made Simple
Using a private registry with kubernetes
kubernetes/images/authn/private registry/artifactory
3 min readSep 25, 2020
If you’re using kubernetes in production, chances are you’re using a private registry to securely store your application images. There’s few ways on how to make those private images available for use in your cluster as mentioned by the official doc.
In this blog, we explain some of these options with examples:
1- Specifying ImagePullSecrets directly on the pod spec:
First, create a pull secret with docker Credentials:
kubectl create secret docker-registry my-registry-cred \
--docker-server=[REGISTRY_URL] --docker-username=[REGISTRY_USERNAME] --docker-password=[REGISTRY_PASSWORD] --docker-email=[YOUR_EMAIL]
Alternatively you can create the secret from the docker config file directly:
kubectl create secret generic my-registry-cred \
--from-file=.dockerconfigjson=<path/to/.docker/config.json> \
--type=kubernetes.io/dockerconfigjson
Create a pod that uses the secret as shown below:
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Pod
metadata:
name: my-pod
spec:
containers:
- name…