简体   繁体   中英

How to setup private registery credentials on cluster ip

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 ?

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.

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":"jdoe@example.com","auth":"c3R...zE2"}}}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM