一、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
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
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
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):

 1apiVersion: apps/v1
 2kind: Deployment
 3metadata:
 4  annotations:
 5    description: ''
 6  labels:
 7    appgroup: ''
 8    version: v1
 9  name: javawebtest
10  namespace: default
11spec:
12  selector:
13    matchLabels:
14      app: javawebtest
15      version: v1
16  template:
17    metadata:
18      annotations:
19        metrics.alpha.kubernetes.io/custom-endpoints: '[{"api":"","path":"","port":"","names":""}]'
20      labels:
21        app: javawebtest
22        version: v1
23    spec:
24      containers:
25        - image: 'swr.sa-brazil-1.myhuaweicloud.com/devcloud/demo:v1.1'
26          name: container-0
27          resources:
28            requests:
29              cpu: 250m
30              memory: 512Mi
31            limits:
32              cpu: 1000m
33              memory: 1024Mi
34      imagePullSecrets:
35        - name: default-secret
36      terminationGracePeriodSeconds: 30
37  replicas: 1
38  minReadySeconds: 0
39  strategy:
40    type: RollingUpdate
41    rollingUpdate:
42      maxSurge: 0
43      maxUnavailable: 1
44
45---
46apiVersion: v1
47kind: Service
48metadata:
49  name: javawebtest
50  labels:
51    app: javawebtest
52  namespace: default
53  annotations: {}
54spec:
55  selector:
56    app: javawebtest
57  externalTrafficPolicy: Cluster
58  ports:
59    - name: cce-service-0
60      targetPort: 8080
61      nodePort: 0
62      port: 8080
63      protocol: TCP
64  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.