k8s那点事儿k8s入门

k8s 从私有仓库中拉取镜像

2019-01-21  本文已影响2人  baiyongjie

新建一个名字为regsecret的Secret保存验证信息

kubectl create -n namespace secret \
docker-registry regsecret \
--docker-server=privateAddress \
--docker-username=Username \
--docker-password=Password \
--docker-email=misterbyj@163.com

---
-n 指定命名空间
--docker-server   指定仓库地址
--docker-username 用户名
--docker-password 密码
--docker-email    邮件地址

查看yaml格式

[root@k8sMaster01 deployment]# kubectl -n namespace get secret regsecret --output=yaml
apiVersion: v1
data:
  .dockerconfigjson: eyJhdXRocyI6eyJwcml2YXRlLndpbmNoYW7InVzZXJuYW1lIjoid2luY2hhbm5lbCIsInBhc3N3b3JkIjoid2luY2hhbm5lbDIwMTgiLCJlbWFpbCI6ImJhaXlvbmdqaWVAd2luY2hhbm5lbC5uZXQiLCJhdXRoIjoiZDJsdVkyaGhibTVsYkRwM2FXNWphR0Z11qQXhPQT09In19fQ==
kind: Secret
metadata:
  creationTimestamp: 2018-12-27T11:29:27Z
  name: regsecret
  namespace: namespace
  resourceVersion: "177507"
  selfLink: /api/v1/namespaces/namespace/secrets/regsecret
  uid: ab7378a8-09ca-11e9-bed3-525400a92dc9
type: kubernetes.io/dockerconfigjson

修改yaml资源清单文件

# 新增加imagePullSecrets, 参数为刚创建的regsecret

      containers:
        name: base-config
        image: privateAddress/imageName:Version
      imagePullSecrets:
        - name: regsecret
上一篇下一篇

猜你喜欢

热点阅读