更新时间:2023-07-06 GMT+08:00

通过设计器创建的应用

如果之前版本的应用是通过图形化编排创建的,请按照本节的步骤将应用迁移到新版本CCE中。在新版本CCE中,使用自定义的HelmTemplate创建无状态工作负载,更多信息,请参见模板市场

操作步骤

  1. 登录前一个CCE版本的控制台。在左侧导航栏中,单击“应用管理”。单击需要迁移的应用名称,进入该应用的详情页面。获取组件名称和服务名称。
  2. 连接集群,详细信息请参见通过kubectl连接集群
  3. 在kubectl客户端执行以下命令,获取应用相关的YAML文件。

    kubectl get rc new-appcomponent-1-11d3 -o yaml > new-appcomponent-1-11d3.yaml

    kubectl get svc new-port-3 -o yaml > new-port-3.yaml

    请将命令中new-appcomponent-1-11d3new-appcomponent-1-11d3替换为1中获取的值。

  4. 编辑“new appcomponent-1-11d3.yaml”文件,删除加粗部分,修改斜体部分。

    apiVersion: v1
    kind: ReplicationController
    metadata:
      annotations:
        cce/app-createTimestamp: 2018-04-19-11-39-27
        cce/app-description: ""
        cce/app-updateTimestamp: 2018-04-19-11-39-27
      creationTimestamp: 2018-04-19T11:37:17Z
      generation: 1
      labels:
        cce/appgroup: app-design
        name: new-appcomponent-1-11d3
        rollingupdate: "false"
      name: new-appcomponent-1-11d3
      namespace: default
      resourceVersion: "8325781"
      selfLink: /api/v1/namespaces/default/replicationcontrollers/new-appcomponent-1-11d3
      uid: 039ada96-43c6-11e8-8f34-fa163e738aa3
    spec:
      replicas: 1
      selector:
        cce/appgroup: app-design
        name: new-appcomponent-1-11d3
        rollingupdate: "false"
      template:
        metadata:
          annotations:
            scheduler.alpha.kubernetes.io/affinity: '{"nodeAffinity":{"requiredDuringSchedulingIgnoredDuringExecution":{"nodeSelectorTerms":[{"matchExpressions":[{"key":"failure-domain.beta.kubernetes.io/zone","operator":"NotIn","values":[""]}]}]}}}'
          creationTimestamp: null
          labels:
            cce/appgroup: app-design
            name: new-appcomponent-1-11d3
            rollingupdate: "false"
        spec:
          affinity:
            nodeAffinity:
              requiredDuringSchedulingIgnoredDuringExecution:
                nodeSelectorTerms:
                - matchExpressions:
                  - key: failure-domain.beta.kubernetes.io/zone
                    operator: NotIn
                    values:
                    - ""
          containers:
          - image: 10.125.1.108:6443/test/apache-php:latest -->Change it to the image address of the later CCE version
            imagePullPolicy: Always
            name: new-container-2-11d3f16
            ports:
            - containerPort: 3333
              protocol: TCP
            resources: {}
            securityContext:
              privileged: true
            terminationMessagePath: /dev/termination-log
            terminationMessagePolicy: File
          dnsPolicy: ClusterFirst
          imagePullSecrets:
          - name: myregistry    ----->  Change it to default-secret
          restartPolicy: Always
          schedulerName: default-scheduler
          securityContext: {}
          terminationGracePeriodSeconds: 30
    status:
      availableReplicas: 1
      fullyLabeledReplicas: 1
      observedGeneration: 1
      readyReplicas: 1
      replicas: 1

  5. 打开文件,删除加粗部分的内容。

    apiVersion: v1
    kind: Service
    metadata:
      creationTimestamp: 2018-04-19T11:37:17Z
      labels:
        cce/appgroup: app-design
        name: new-appcomponent-1-11d3
      name: new-port-3
      namespace: default
      resourceVersion: "8325766"
      selfLink: /api/v1/namespaces/default/services/new-port-3
      uid: 039c918f-43c6-11e8-8f34-fa163e738aa3
    spec:
      clusterIP: 10.247.145.136
      externalTrafficPolicy: Cluster
      ports:
      - name: new-port-30
        nodePort: 31471
        port: 3333
        protocol: TCP
        targetPort: 3333
      selector:
        cce/appgroup: app-design
        name: new-appcomponent-1-11d3
      sessionAffinity: None
      type: NodePort
    status:
      loadBalancer: {}

  6. 将kubectl客户端连接到CCE新版本的集群,具体操作请参见通过kubectl连接集群
  7. 执行以下命令,重新创建应用。

    kubectl create -f new-appcomponent-1-11d3.yaml

    kubectl create -f new-port-3.yaml