镜像
用户可以通过华为云镜像仓库服务SWR来管理业务镜像。本章节将介绍CCE+bursting插件场景中,涉及到镜像相关的使用场景及用法。通过阅读本章用户可以在CCE+bursting插件场景中:
使用SWR拉取用户业务镜像
- 方式一:通过console选取SWR镜像
     
- 用户镜像上传SWR。使用方式请参考:SWR官方文档。
 
- 在华为云CCE控制台创建负载选择镜像。
 - 对接到SWR中的镜像。请确保您的SWR仓库中已正确上传了镜像,SWR服务使用详情请参见:SWR官方文档。
 
 - 方式二:通过在CCE集群配置node选取SWR镜像
     
- 查看SWR镜像仓库中的镜像地址,示例:swr.cn-north-4.myhuaweicloud.com/cci-test/nginx:1.0.0.x86_64_test
 - 登录CCE集群节点。
 - 配置工作负载yaml。 
       
apiVersion: apps/v1 kind: Deployment metadata: name: test namespace: default labels: bursting.cci.io/burst-to-cci: enforce # 弹性到CCI 2.0 spec: replicas: 2 selector: matchLabels: app: test template: metadata: labels: app: test spec: containers: - image: swr.***.com/cci-test/nginx:1.0.0.x86_64_test name: container-0 resources: requests: cpu: 250m memory: 512Mi limits: cpu: 250m memory: 512Mi volumeMounts: [] imagePullSecrets: - name: default-secret - 部署工作负载。 
       
kubectl apply -f test-deployment.yaml
 
 
混合使用华为云SWR + 第三方镜像仓拉取用户业务镜像
操作场景:
在某些情况下,用户在CCE的工作负载拉取第三方镜像仓库的镜像,拉取的镜像可以同步到SWR服务,当发生业务波峰时,弹性到CCI的工作负载使用SWR镜像,可以极大提高镜像拉取效率,帮助用户更丝滑应对业务波峰。
操作指导:
为工作负载yaml配置annotation,示例值如下所示:
bursting.cci.io/image-replacement: '[
    {"repositoryPrefix":"harbor.domain","replaceWith":"swr.***.com/org1"},
    {"repositoryPrefix":"","replaceWith":"swr.***.com/org1"},
    {"repositoryPrefix":"harbor.domain/a/b/c/d","replaceWith":"swr.***.com/org2"}
]'
  
 
   - 配置策略执行无先后顺序。
 - 替换策略可以配置多条,各个策略repositoryPrefix值不允许重复。
 
| 
        替换规则key  | 
      
        字段含义  | 
      
        字段说明  | 
     
|---|---|---|
| 
        repositoryPrefix  | 
      
        用户希望被匹配并被替换的镜像前缀字段。  | 
      
       
  | 
     
| 
        replaceWith  | 
      
        用户希望替换成的镜像前缀字段。  | 
      
       
  | 
     
| 
        annotation  | 
      
        替换前  | 
      
        替换后  | 
      
        说明  | 
     
|---|---|---|---|
| 
        bursting.cci.io/image-replacement: '[ {"repositoryPrefix":"harbor.domain","replaceWith":"swr.***.com/org1"} ]'  | 
      
        containers: - name: container-0 image: 'harbor.domain/ubuntu:latest'  | 
      
        containers: - name: container-0 image: 'swr.***.com/org1/ubuntu:latest'  | 
      
        repositoryPrefix匹配第三方仓库域名场景。  | 
     
| 
        bursting.cci.io/image-replacement: '[ {"repositoryPrefix":"","replaceWith":"swr.***.com/org1"} ]'  | 
      
        containers: - name: container-1 image: 'nginx:latest'  | 
      
        containers: - name: container-1 image: 'swr.***.com/org1/nginx:latest'  | 
      
        repositoryPrefix为空场景。  | 
     
| 
        bursting.cci.io/image-replacement: '[ {"repositoryPrefix":"harbor.domain/a/b/c/d","replaceWith":"swr.***.com/org2"} ]'  | 
      
        containers: - name: container-2 image: 'harbor.domain/a/b/c/d/redis:latest'  | 
      
        containers: - name: container-2 image: 'swr.***.com/org2/redis:latest'  | 
      
        repositoryPrefix匹配第三方仓库域名+组织目录场景。  | 
     
    
      