How to setup private registery credentials on cluster ip

50 views Asked by At

We have setup private registery using nexus on kubernetes cluster. we expose our registery on cluster ip for dedicated ip and we are able to pull push using docker. when i setup docker credentials for private registery using secrets, i am getting error as below

Failed to pull image "ip:port/repository/ydocker-repo/apps:tag": rpc error: code = Unknown desc = Error response from daemon: Get http://ip:port/v2/repository/docker/app/manifests/1.0: no basic auth credentials

I have setup service account and again i am getting same error.

What's wrong i am doing here.

below is my deployment code

apiVersion: apps/v1
kind: Deployment
metadata:
  name: xyz
spec:
  selector:
    matchLabels:
      app: xyz
  replicas: 3
  template:
    metadata:
      labels:
        app: xyz
    spec:
     containers:
     - name: yuwee-app-server
       image: ip:port/repository/ydocker-repo/apps:tag
       imagePullPolicy: "Always"
       stdin: true
       tty: true
       ports:
       - containerPort: port-number
       imagePullPolicy: Always
     imagePullSecrets:
     - name: myregistrykey
     restartPolicy: Always
     serviceAccountName: default

Does someone have any idea how to setup registery secrets for clusterIP ?

2

There are 2 answers

1
Daniel Marques On

I usually follow this k8s doc to config push/pull on a private docker registry.

Creating a secret:

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

Referencing secret on deployment:

  imagePullSecrets:
  - name: docker-secret

To check if the secret info is right, decode the secret .dockerconfigjson: value. Should be something similar to this:

{"auths":{"your.private.registry.example.com":{"username":"janedoe","password":"xxxxxxxxxxx","email":"[email protected]","auth":"c3R...zE2"}}}
0
Dharmendra Jha On

so i found out issue. my deployment is inside a namespace and i have created secrets inside default namespace, which should be inside that namespace. now it's working what i expected.