guillaumed4sii
guillaumed4sii

Reputation: 1

Error configuring Kubernetes to extract an image from a private registry

I've a private repo on gitlab, this repo is synchronized with docker and trying to pull that image into my kubernetes cluster. I can see the documentations suggest to do this

kubectl create secret generic regcred \
    --from-file=.dockerconfigjson=<path/to/.docker/config.json> \
    --type=kubernetes.io/dockerconfigjson

I am already logged in, and i change path to ~/.docker/config.json but it keeps giving me

kubectl create secret generic regcred --from-file=.dockerconfigjson=<~/.docker/config.json> --type=kubernetes.io/dockerconfigjson

bash: --type=kubernetes.io/docker config json: No such file or directory

Do you know how to resolve this error?

So in other words how to properly authenticate and be able to push private images into kube cluster?

Thanks,

Upvotes: 0

Views: 563

Answers (2)

Suhas Gumma
Suhas Gumma

Reputation: 91

You have to remove "< >" while specifying path... Rewrite the command as:

kubectl create secret generic regcred \
    --from-file=.dockerconfigjson=~/.docker/config.json \
    --type=kubernetes.io/dockerconfigjson

Upvotes: 0

Max Lobur
Max Lobur

Reputation: 6040

I know you've copied it from the official docs, but it may be missing quotes. Also build a path using $HOME var. Try this:

kubectl create secret generic regcred \
    --from-file=.dockerconfigjson="$HOME/.docker/config.json" \
    --type="kubernetes.io/dockerconfigjson"

Upvotes: 1

Related Questions