Skip to content

Latest commit

 

History

History
36 lines (30 loc) · 959 Bytes

使用秘钥从私有仓库下载镜像.md

File metadata and controls

36 lines (30 loc) · 959 Bytes

#这个秘钥默认在default名称空间,不能被 day10 名称空间共享
$ kubectl create secret -n day10 docker-registry my-aliyun \
    --docker-server=registry.cn-hangzhou.aliyuncs.com \
    --docker-username=forsumlove \
    --docker-password=lfy11223344
kind: Pod
apiVersion: v1
metadata:
  name: my-container-test02
  namespace: day10
  labels:
    aa: bb
    bb: dd
spec:
  imagePullSecrets:  #镜像的下载秘钥,公有仓是默认的
    - name: my-aliyun   # 是kubectl create secrete 搞来的 registry.cn-hangzhou.aliyuncs.com
  ##   私仓从 registry.cn-hangzhou.aliyuncs.com直接区分
  containers:
    - image: registry.cn-hangzhou.aliyuncs.com/lfy/java-devops-demo:v1.0
      name: my-container-01
      imagePullPolicy: Always
      #生产环境,镜像在私有仓库,下载需要秘钥
    - image: nginx #  默认从docker hub来的
      name: my-container-02
      imagePullPolicy: Always