云容器实例 CCI-镜像:使用第三方镜像拉取用户业务镜像

时间:2024-04-11 08:38:48

使用第三方镜像拉取用户业务镜像

  1. 使用CCI提供的工具创建第三方镜像仓库认证secret。
    imagepull-secret-generator --ak=$ak --sk=$sk --private-user=$user --private-password=$password --output-file-path=my-imagepull-secret.json --project-name=cn-north-4 --secret-name=my-imagepull-secret --swr-address=swr.cn-north-4.myhuaweicloud.com
    登录CCE集群节点,为集群创建secret。
    kubectl apply -f my-imagepull-secret.json
  2. 创建负载,使用secret。

    在spec.imagePullSecrets中指定第三方仓库认证secret。

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      labels:
        app: test-imagepull
        virtual-kubelet.io/burst-to-cci: enforce
      name: test-imagepull
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: test-imagepull
      template:
        metadata:
          labels:
            app: test-imagepull
        spec:
          containers:
          - image: xxx/my-image:latest
            imagePullPolicy: Always
            name: nginx
            resources:
              limits:
                cpu: 1
                memory: 2Gi
              requests:
                cpu: 1
                memory: 2Gi
          imagePullSecrets:
          - name: my-imagepull-secret
support.huaweicloud.com/usermanual-cci/cci_01_0118.html