Devcloud部署应用到CCE

一、Devcloud介绍(Introduction to Devcloud)

Devcloud是华为云一站式的开发部署应用平台。在中国region包含有12个应用组件,但在中国之外的region当前上线的是ProjectMan、CodeHub、CloudPipeline、CloudBuild、CloudDeploy、CloudArtifact 六个主要组件。

Devcloud is a one-stop development and deploy application platform for HUAWEI CLOUD. There are 12 application components in the China region, but the oversea regions are currently online with six main components: ProjectMan, CodeHub, CloudPipeline, CloudBuild, CloudDeploy, and CloudArtifact.

二、代码管理(Code management)

先创建完project,再通过codehub上传代码到对应的仓库。First create the project, and then upload the code to the corresponding repository through codehub.

codehub

三、代码编译(Code build)

通过导航栏切换到cloudbuild,增加任务,可以通过加号增加不同类型的任务,比如下图就有三个步骤,分别是编译—上传制品库—编译成docker镜像,并上传SWR。

Switch to cloudbuild through the navigation bar and add tasks. You can add different types of tasks through the plus sign. For example, there are three steps in the figure below, which are compiling—uploading the repository—build docker image and upload to SWR.

cloudbuild

三、应用部署(Application build)

应用可以部署到虚拟机、容器,也预置了安装环境、启停应用等模板。这里以部署到CCE容器为例。

Applications can be deployed to virtual machines and containers, and templates such as installation environment and application startup and shutdown are also preset. Here is an example of deploying to a CCE container.

clouddeploy

也可以部署到自定义的K8s集群,不过需要提前增加endpoint,并通过k8s公网API接口进行通信。

It can also be deployed to a custom K8s cluster, but you need to add endpoints in advance and communicate through the k8s public network API interface.

可以通过yaml文件部署应用到CCE,示例如下(The application can be deployed to CCE through the yaml file, the example is as follows):

apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    description: ''
  labels:
    appgroup: ''
    version: v1
  name: javawebtest
  namespace: default
spec:
  selector:
    matchLabels:
      app: javawebtest
      version: v1
  template:
    metadata:
      annotations:
        metrics.alpha.kubernetes.io/custom-endpoints: '[{"api":"","path":"","port":"","names":""}]'
      labels:
        app: javawebtest
        version: v1
    spec:
      containers:
        - image: 'swr.sa-brazil-1.myhuaweicloud.com/devcloud/demo:v1.1'
          name: container-0
          resources:
            requests:
              cpu: 250m
              memory: 512Mi
            limits:
              cpu: 1000m
              memory: 1024Mi
      imagePullSecrets:
        - name: default-secret
      terminationGracePeriodSeconds: 30
  replicas: 1
  minReadySeconds: 0
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 0
      maxUnavailable: 1
---
apiVersion: v1
kind: Service
metadata:
  name: javawebtest
  labels:
    app: javawebtest
  namespace: default
  annotations: {}
spec:
  selector:
    app: javawebtest
  externalTrafficPolicy: Cluster
  ports:
    - name: cce-service-0
      targetPort: 8080
      nodePort: 0
      port: 8080
      protocol: TCP
  type: NodePort

需要特别注意imagePullSecrets:,CCE可以直接到SWR上拉取镜像,是因为该文件中存储了登录SWR的用户名和密码信息。

Special attention imagePullSecrets:. CCE can directly pull images from SWR because the user name and password information for logging in to SWR are stored in this file.

四、Pipeline

Pipeline是把前面的步骤结合起来,通过pipeline可以一键式的完成代码的编译和部署。Pipeline is a combination of the previous steps, and the build and deployment of the code can be completed with one click through the pipeline.

发表回复

您的电子邮箱地址不会被公开。