Pull Images to Kubernetes
Copy Nexus Credentials into Kubernetes
As we mentioned before, the login process creates or updates a config.json file that holds an authorization token.
View the config.json file:
The output contains a section similar to this:
A Kubernetes cluster uses the secret of kubernetes.io/dockerconfigjson type to authenticate with a container registry to pull a private image.If you already ran docker login, you can copy that credential into Kubernetes:
kubectl create secret generic regcred \
--from-file=.dockerconfigjson=~/.docker/config.json \
--type=kubernetes.io/dockerconfigjson
Then, add the secret to default service account.
Here is a manifest for an example Pod that needs access to your Docker credentials:
apiVersion: v1
kind: Pod
metadata:
name: my-private-pod
spec:
containers:
- name: private
image: yourusername/privateimage:version
imagePullSecrets:
- name: secret-name