Kubunetes 使用私有 docker 仓库镜像

  1. 创建 kubectl 密钥
export NAME="tencentyun"
export SERVER="ccr.ccs.tencentyun.com"
export USERNAME="docker"
export PASSWORD="123456"
kubectl create secret docker-registry "${NAME}" --docker-server="${SERVER}" --docker-username="${USERNAME}"--docker-password="${PASSWOD}" --docker-email="docker@mail.com"
  1. 拉取镜像时使用该密钥

根据第一步配置的名称 ${NAME} 来匹配

apiVersion: v1
kind: Pod
metadata:
  name: hole-pre
spec:
  containers:
    - image: ccr.ccs.tencentyun.com/jansora/hole:v1
      name: hole-pre
      imagePullPolicy: Always
      env:
        - name: MODULE_NAME
          value: 'hole-boot'
        - name: VERSION
          value: '1.0.0-SNAPSHOT'
        - name: PROFILE
          value: 'pre'
  imagePullSecrets:
    - name: 'tencentyun'

评论栏