拉取自建仓库的镜像 本文将介绍如何拉取自建仓库的镜像。 ECI默认不提供公网资源的访问,因此ECI默认是不能拉取自建镜像仓库的镜像,如果您需要从自建镜像仓库等公网镜像仓库拉取镜像来创建ECI实例时需要实例具备公网访问的能力。本文介绍在自建镜像仓库使用自签发证书的情况下,如何拉取自建镜像仓库中的镜像来创建ECI Pod。 前提条件 确保您已经创建Serverless集群,具体操作请参阅创建Serverless集群。 当拉取公网镜像时,确保集群所在VPC已经开启公网NAT网关,能访问公网拉取镜像。 确保kubectl工具已经连接目标集群。 操作步骤 1. 创建镜像拉取凭证。 构造镜像拉取凭证,并且进行base64编码: shell echo "yourname:yourpassword" base64 echo '{"auths":{"harborxxxxx.xxx.com":{"username":"yourname","password":"yourpassword","email":"test@tel.com","auth":"xxxxx"}}}' base64 镜像拉取凭证保密字典testinternetimage.yaml示例如下: shell apiVersion: "v1" kind: "Secret" metadata: labels: serviceAccountName: "default" name: "testinternetimage" namespace: "default" data: ".dockerconfigjson": "xxxxxxxxxxxx" 填写base64编码后的镜像拉取凭证 type: "kubernetes.io/dockerconfigjson" 创建镜像拉取凭证保密字典: shell kubectl crate f testinternetimage.yaml 2. 创建工作负载。 构建工作负载podinternetimage.yaml,填写镜像拉取凭证,示例如下: shell apiVersion: "apps/v1" kind: "Deployment" metadata: name: "testinternetimage" namespace: "default" spec: replicas: 1 selector: matchLabels: app: "test" version: "v1" template: metadata: labels: app: "test" version: "v1" spec: containers: image: "harborxxxxx.xxx.com/test/nginx:latest"