dd6e47d95dbee597ff2606b80d8daa42.gif

方法1 直接配密码secret

生成docker-registry的secret

 kubectl create secret docker-registry harborsecret --docker-server=harbor.demo.com.cn --docker-username='docker-admin' --docker-password='==pwd==' --docker-email='admin@demo.com'

调用

spec:
      imagePullSecrets:
      - name:harborsecret
      containers:
      - name: eureka
        image: harbor.demo.com.cn/test:v1

方法2 使用service account

创建secret

kubectl create secret docker-registry registrysecret --docker-server=harbor.demo.com.cn --docker-username='docker-admin' --docker-password='==pwd==' --docker-email='admin@demo.com'

申明ServiceAccount

apiVersion: v1 
kind: ServiceAccount
metadata:
  name: registrysecret
imagePullSecrets:
- name: registrysecret

调用

apiVersion: v1 
kind: pod 
metadata:
  name: test-pod
spec:
  serviceAccountName: registrysecret
  containers:
    - name: eureka
      image: harbor.demo.com.cn/test:v1

方法3 云厂商的免密拉取镜像

如阿里云: https://help.aliyun.com/document_detail/103178.html

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注

Captcha Code