jar k8s 自己的 部署_怎样部署K8S服务器

一、背景

如果你

1.使用Java进行开发

2.使用容器镜像的制品形式进行交付

3.制品最终会运行在阿里云ACK或者其他K8S集群上

那么本文档可以帮助您实现研发流程的协同自动化。

二、用户诉求

1.一般来说,使用K8S部署场景如下:

2.对源代码进行一定的质量检测,比如单元测试,代码扫描

3.将源代码构建成为可交付的制品,也就是容器镜像

4.对制品进行测试环境验证

5.使用完成验证的制品进行线上部署

6.使用基础设施即代码的方式,在代码库中管理与应用相关的所有yaml文件。使用这种方式,将k8s的编排能力完全交给开发,比较灵活,也更加利于DevOps的实施。

上述活动需要有不同角色的参与:开发、测试、运维。如何保证不同参与者可以使用统一的交付流程来进行协作,是云效Flow交付流水线要解决的主要问题。

三、云效解决方案

通过云效持续交付流水线和阿里云K8S很好的结合在一起,为应用的持续交付提供了很好的基础保障,如下图:

111ve26ff3d06fecc4c2db9ca4bbec26f838?Signature=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJBcHBJRCI6IjVlNzQ4MmQ2MjE1MjJiZDVjN2Y5YjMzNSIsIl9hcHBJZCI6IjVlNzQ4MmQ2MjE1MjJiZDVjN2Y5YjMzNSIsIl9vcmdhbml6YXRpb25JZCI6IiIsImV4cCI6MTU5ODg2NDc0MSwiaWF0IjoxNTk4MjU5OTQxLCJyZXNvdXJjZSI6Ii9zdG9yYWdlLzExMXZlMjZmZjNkMDZmZWNjNGMyZGI5Y2E0YmJlYzI2ZjgzOCJ9.UmCI6Y5DF2ByacYjBx5nXz5ikx6mQRqcW-6bZGtakxc

开发者提交代码变更到代码库,云效在监听着代码库的变动,一旦代码发生变化,将自动触发云效持续部署流水线一次构建任务的运行,包括代码检查、构建、测试部署、测试验证和生产部署等过程。其中,在构建完之后,生成Docker镜像,并自动上传至应用镜像仓库,在部署阶段(测试环境的部署和生产环境的部署)时,获取当前流水线实例构建出来的镜像版本,通过K8S进行容器编排部署。而这一切,都是通过自动化的手段进行完成。

四、云效操作实践

接下来以一个 Java Spring Boot 的代码库为例,讲解如何进行构建并以kubectl apply的方式部署到阿里云 ACK。

1.创建流水线

进入云效(https://devops.aliyun.com)点击页面左上角的dock,选择流水线进入Flow

111vb7beedb60f12c5267e9baaaa3c02f19d?Signature=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJBcHBJRCI6IjVlNzQ4MmQ2MjE1MjJiZDVjN2Y5YjMzNSIsIl9hcHBJZCI6IjVlNzQ4MmQ2MjE1MjJiZDVjN2Y5YjMzNSIsIl9vcmdhbml6YXRpb25JZCI6IiIsImV4cCI6MTU5ODg2NDc0MSwiaWF0IjoxNTk4MjU5OTQxLCJyZXNvdXJjZSI6Ii9zdG9yYWdlLzExMXZiN2JlZWRiNjBmMTJjNTI2N2U5YmFhYWEzYzAyZjE5ZCJ9.aj9NXxzKa0rZm9aPwNiPeBkqkOn4-FQLiGonGHgnjqk

2.点击右上角【新建流水线】,进入流水线创建向导页面。

111vf556ab1245899647382ec9aee2b1c53a?Signature=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJBcHBJRCI6IjVlNzQ4MmQ2MjE1MjJiZDVjN2Y5YjMzNSIsIl9hcHBJZCI6IjVlNzQ4MmQ2MjE1MjJiZDVjN2Y5YjMzNSIsIl9vcmdhbml6YXRpb25JZCI6IiIsImV4cCI6MTU5ODg2NDc0MSwiaWF0IjoxNTk4MjU5OTQxLCJyZXNvdXJjZSI6Ii9zdG9yYWdlLzExMXZmNTU2YWIxMjQ1ODk5NjQ3MzgyZWM5YWVlMmIxYzUzYSJ9.dityqQ16s7b-QEJx55PmiCp1nVZTC-g_KlRdxGYW3n4

3.选择相应模板,并点击创建

111va2bf20f7037c8da7566ba337c6ce0fc8?Signature=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJBcHBJRCI6IjVlNzQ4MmQ2MjE1MjJiZDVjN2Y5YjMzNSIsIl9hcHBJZCI6IjVlNzQ4MmQ2MjE1MjJiZDVjN2Y5YjMzNSIsIl9vcmdhbml6YXRpb25JZCI6IiIsImV4cCI6MTU5ODg2NDc0MSwiaWF0IjoxNTk4MjU5OTQxLCJyZXNvdXJjZSI6Ii9zdG9yYWdlLzExMXZhMmJmMjBmNzAzN2M4ZGE3NTY2YmEzMzdjNmNlMGZjOCJ9.O7T7tIxfkR1thNgLDx4G5DlDanOikgoT-jGnmixatKg

配置代码库

创建流水线之后会自动弹出添加代码源的窗口,这里选择Flow提供的示例代码源,并进行添加

111vd6c5efac7c54e418fde2afa3f6f6aea7?Signature=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJBcHBJRCI6IjVlNzQ4MmQ2MjE1MjJiZDVjN2Y5YjMzNSIsIl9hcHBJZCI6IjVlNzQ4MmQ2MjE1MjJiZDVjN2Y5YjMzNSIsIl9vcmdhbml6YXRpb25JZCI6IiIsImV4cCI6MTU5ODg2NDc0MSwiaWF0IjoxNTk4MjU5OTQxLCJyZXNvdXJjZSI6Ii9zdG9yYWdlLzExMXZkNmM1ZWZhYzdjNTRlNDE4ZmRlMmFmYTNmNmY2YWVhNyJ9.4U2N8iFcyqIpzkon8HXb5OW3vArgUCqwSHcm6OO9ooA

示例代码库地址为:https://code.aliyun.com/flow-example/spring-boot,请先查看相关的manifest文件,其中包含了一个deployment,一个service,以及一个ingress将这个服务暴露到公网上:

111v6a6602ecd84b54cb43b3ddf31938b249?Signature=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJBcHBJRCI6IjVlNzQ4MmQ2MjE1MjJiZDVjN2Y5YjMzNSIsIl9hcHBJZCI6IjVlNzQ4MmQ2MjE1MjJiZDVjN2Y5YjMzNSIsIl9vcmdhbml6YXRpb25JZCI6IiIsImV4cCI6MTU5ODg2NDc0MSwiaWF0IjoxNTk4MjU5OTQxLCJyZXNvdXJjZSI6Ii9zdG9yYWdlLzExMXY2YTY2MDJlY2Q4NGI1NGNiNDNiM2RkZjMxOTM4YjI0OSJ9.4o2UzUzfs2jyeCJVw7o4KfuGEKNIiVK4n7B-we5hgrg

配置镜像构建任务

4.你需要先在cr.console.aliyun.com上创建一个镜像仓库,然后在流水线中进入“镜像构建并推送至阿里云镜像仓库”的任务进行编辑。点击”新建服务授权”,进行阿里云授权。同意授权之后,Flow会将创建好的服务授权自动回填写到表单中。

111v620cd0b9b5af4d676a2f9178c5a74acb?Signature=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJBcHBJRCI6IjVlNzQ4MmQ2MjE1MjJiZDVjN2Y5YjMzNSIsIl9hcHBJZCI6IjVlNzQ4MmQ2MjE1MjJiZDVjN2Y5YjMzNSIsIl9vcmdhbml6YXRpb25JZCI6IiIsImV4cCI6MTU5ODg2NDc0MSwiaWF0IjoxNTk4MjU5OTQxLCJyZXNvdXJjZSI6Ii9zdG9yYWdlLzExMXY2MjBjZDBiOWI1YWY0ZDY3NmEyZjkxNzhjNWE3NGFjYiJ9.D9HbB9QXIUeyiBESR9JXayIFtC08mm2MmKhzQfSfNVA

111v7051304748228e913df8254de8c3d6bf?Signature=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJBcHBJRCI6IjVlNzQ4MmQ2MjE1MjJiZDVjN2Y5YjMzNSIsIl9hcHBJZCI6IjVlNzQ4MmQ2MjE1MjJiZDVjN2Y5YjMzNSIsIl9vcmdhbml6YXRpb25JZCI6IiIsImV4cCI6MTU5ODg2NDc0MSwiaWF0IjoxNTk4MjU5OTQxLCJyZXNvdXJjZSI6Ii9zdG9yYWdlLzExMXY3MDUxMzA0NzQ4MjI4ZTkxM2RmODI1NGRlOGMzZDZiZiJ9.QGT8C2uSPJnD0y_ftqhnw1vcsio_puJk7wV-bnMGAZA

5.接下来完成区域、仓库的选取。标签填入“${DATETIME}”,表示以流水线触发时的时间戳作为镜像的标签。Dockerfile路径填入”Dockerfile2”

111v6cc29c14f3b947c5bcb72697a1750c4a?Signature=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJBcHBJRCI6IjVlNzQ4MmQ2MjE1MjJiZDVjN2Y5YjMzNSIsIl9hcHBJZCI6IjVlNzQ4MmQ2MjE1MjJiZDVjN2Y5YjMzNSIsIl9vcmdhbml6YXRpb25JZCI6IiIsImV4cCI6MTU5ODg2NDc0MSwiaWF0IjoxNTk4MjU5OTQxLCJyZXNvdXJjZSI6Ii9zdG9yYWdlLzExMXY2Y2MyOWMxNGYzYjk0N2M1YmNiNzI2OTdhMTc1MGM0YSJ9.3MvEBCM_SyGrfQkyu8PSQN-3PNfcJUlnIlziYcohE7E

6.配置好之后再“镜像构建并推送至阿里云镜像仓库”任务的下方可以看到该任务输出的变量,这些变量可以在后续的任务中引用。关注其中的第二个和第三个变量即可,其中第二个是该镜像地址的公网地址,第三个是该镜像地址的VPC地址。这里推荐将镜像仓库和ACK集群放在同一个集群,然后在后续的部署任务中选择VPC地址,以加速部署过程。

111v227e0a50f85c9d16a2a01c84505292b5?Signature=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJBcHBJRCI6IjVlNzQ4MmQ2MjE1MjJiZDVjN2Y5YjMzNSIsIl9hcHBJZCI6IjVlNzQ4MmQ2MjE1MjJiZDVjN2Y5YjMzNSIsIl9vcmdhbml6YXRpb25JZCI6IiIsImV4cCI6MTU5ODg2NDc0MSwiaWF0IjoxNTk4MjU5OTQxLCJyZXNvdXJjZSI6Ii9zdG9yYWdlLzExMXYyMjdlMGE1MGY4NWM5ZDE2YTJhMDFjODQ1MDUyOTJiNSJ9.kgJ486mBGyuSXOM3UpH4mBq9X9q9gRv_E9_mffPo0gA

配置部署任务

点击“Kubernetes发布”任务,进入配置。点击”新建连接”,进行集群授权,完成阿里云授权及集群选取。点击确认之后,集群信息会自动填到任务配置中。

111v5e99bac523f124f99f8e6b2362d8e7d9?Signature=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJBcHBJRCI6IjVlNzQ4MmQ2MjE1MjJiZDVjN2Y5YjMzNSIsIl9hcHBJZCI6IjVlNzQ4MmQ2MjE1MjJiZDVjN2Y5YjMzNSIsIl9vcmdhbml6YXRpb25JZCI6IiIsImV4cCI6MTU5ODg2NDc0MSwiaWF0IjoxNTk4MjU5OTQxLCJyZXNvdXJjZSI6Ii9zdG9yYWdlLzExMXY1ZTk5YmFjNTIzZjEyNGY5OWY4ZTZiMjM2MmQ4ZTdkOSJ9.S24H3fyqjlvkne06iBrUkm07T3M8eYYTxOBDULCkLx4

111ve8abf98a00be0c408f403187bf0d90e5?Signature=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJBcHBJRCI6IjVlNzQ4MmQ2MjE1MjJiZDVjN2Y5YjMzNSIsIl9hcHBJZCI6IjVlNzQ4MmQ2MjE1MjJiZDVjN2Y5YjMzNSIsIl9vcmdhbml6YXRpb25JZCI6IiIsImV4cCI6MTU5ODg2NDc0MSwiaWF0IjoxNTk4MjU5OTQxLCJyZXNvdXJjZSI6Ii9zdG9yYWdlLzExMXZlOGFiZjk4YTAwYmUwYzQwOGY0MDMxODdiZjBkOTBlNSJ9.HFKFWZLQEZqyfLaGNHqCKzY7ONoudi8sFM5-7mbwpak

111vf7477c9d36a94a558977819fbf7e69ff?Signature=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJBcHBJRCI6IjVlNzQ4MmQ2MjE1MjJiZDVjN2Y5YjMzNSIsIl9hcHBJZCI6IjVlNzQ4MmQ2MjE1MjJiZDVjN2Y5YjMzNSIsIl9vcmdhbml6YXRpb25JZCI6IiIsImV4cCI6MTU5ODg2NDc0MSwiaWF0IjoxNTk4MjU5OTQxLCJyZXNvdXJjZSI6Ii9zdG9yYWdlLzExMXZmNzQ3N2M5ZDM2YTk0YTU1ODk3NzgxOWZiZjdlNjlmZiJ9.kNFNEg-_aQPXeX6CTFmLpgwD6tFobrMnSrBkH-RNCJ0

111v94436cdf8f49249586c776ad496e87da?Signature=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJBcHBJRCI6IjVlNzQ4MmQ2MjE1MjJiZDVjN2Y5YjMzNSIsIl9hcHBJZCI6IjVlNzQ4MmQ2MjE1MjJiZDVjN2Y5YjMzNSIsIl9vcmdhbml6YXRpb25JZCI6IiIsImV4cCI6MTU5ODg2NDc0MSwiaWF0IjoxNTk4MjU5OTQxLCJyZXNvdXJjZSI6Ii9zdG9yYWdlLzExMXY5NDQzNmNkZjhmNDkyNDk1ODZjNzc2YWQ0OTZlODdkYSJ9.xd86zmSZcpcRtKT95pxcTLthcr5JpoHTsur8vRH5bhs

111vb89ebbedcbe6ff2aaa6f251c76c99637?Signature=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJBcHBJRCI6IjVlNzQ4MmQ2MjE1MjJiZDVjN2Y5YjMzNSIsIl9hcHBJZCI6IjVlNzQ4MmQ2MjE1MjJiZDVjN2Y5YjMzNSIsIl9vcmdhbml6YXRpb25JZCI6IiIsImV4cCI6MTU5ODg2NDc0MSwiaWF0IjoxNTk4MjU5OTQxLCJyZXNvdXJjZSI6Ii9zdG9yYWdlLzExMXZiODllYmJlZGNiZTZmZjJhYWE2ZjI1MWM3NmM5OTYzNyJ9.Aim_Tu5PCyiZFOGpAVPEno1Aj8Z-cJeDv59ZvUQPHac

配置变量,填入IMAGE,并选择镜像的VPC地址作为变量值。这样在运行时,Flow会把YAML路径下的所有文件中的${IMAGE}都替换成镜像的地址,然后再进行kubectl发布。

111vd244bc7fe2e8d28b65f6ab6e421e04b5?Signature=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJBcHBJRCI6IjVlNzQ4MmQ2MjE1MjJiZDVjN2Y5YjMzNSIsIl9hcHBJZCI6IjVlNzQ4MmQ2MjE1MjJiZDVjN2Y5YjMzNSIsIl9vcmdhbml6YXRpb25JZCI6IiIsImV4cCI6MTU5ODg2NDc0MSwiaWF0IjoxNTk4MjU5OTQxLCJyZXNvdXJjZSI6Ii9zdG9yYWdlLzExMXZkMjQ0YmM3ZmUyZThkMjhiNjVmNmFiNmU0MjFlMDRiNSJ9.Yd7MCoN09TUN3bhqMwwo6nT_DgCDFGWfHVZuMXBQSrA

示例代码库中的文件https://code.aliyun.com/flow-example/spring-boot/blob/master/app-configs/manifest-app/app.yaml的内容如下,所以其中的${IMAGE}就会被替换成实际的镜像地址。

apiVersion: extensions/v1beta1kind: Deploymentmetadata: labels: run: spring-boot-sample name: spring-boot-samplespec: replicas: 2 selector: matchLabels: run: spring-boot-sample template: metadata: labels: run: spring-boot-sample spec: containers: - image: ${IMAGE} name: appPlain Text

添加人工卡点

为了保证经过审批的制品才能进入部署环境,需要添加一个人工卡点,这里假设这个环境是测试环境,需要有测试管理员来审批才能进入。

首选需要在企业中创建一个角色”测试管理员“,并将企业用户”张三”的角色设置为该角色。

111vc2dad0536e8310f1e81bcb7d937c6042?Signature=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJBcHBJRCI6IjVlNzQ4MmQ2MjE1MjJiZDVjN2Y5YjMzNSIsIl9hcHBJZCI6IjVlNzQ4MmQ2MjE1MjJiZDVjN2Y5YjMzNSIsIl9vcmdhbml6YXRpb25JZCI6IiIsImV4cCI6MTU5ODg2NDc0MSwiaWF0IjoxNTk4MjU5OTQxLCJyZXNvdXJjZSI6Ii9zdG9yYWdlLzExMXZjMmRhZDA1MzZlODMxMGYxZTgxYmNiN2Q5MzdjNjA0MiJ9.7x1kexwP1ASpYQqU-96pZQHgXhuHhlucwvUTJlorBUw

111ve2988995838daa5cf849d65a2339d4c0?Signature=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJBcHBJRCI6IjVlNzQ4MmQ2MjE1MjJiZDVjN2Y5YjMzNSIsIl9hcHBJZCI6IjVlNzQ4MmQ2MjE1MjJiZDVjN2Y5YjMzNSIsIl9vcmdhbml6YXRpb25JZCI6IiIsImV4cCI6MTU5ODg2NDc0MSwiaWF0IjoxNTk4MjU5OTQxLCJyZXNvdXJjZSI6Ii9zdG9yYWdlLzExMXZlMjk4ODk5NTgzOGRhYTVjZjg0OWQ2NWEyMzM5ZDRjMCJ9.7fABQ25sd4MFhLGG5sZIWlTXNvPrTVCIj_TjYKZWkjQ

111v03940b813f20115826839dadc415507f?Signature=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJBcHBJRCI6IjVlNzQ4MmQ2MjE1MjJiZDVjN2Y5YjMzNSIsIl9hcHBJZCI6IjVlNzQ4MmQ2MjE1MjJiZDVjN2Y5YjMzNSIsIl9vcmdhbml6YXRpb25JZCI6IiIsImV4cCI6MTU5ODg2NDc0MSwiaWF0IjoxNTk4MjU5OTQxLCJyZXNvdXJjZSI6Ii9zdG9yYWdlLzExMXYwMzk0MGI4MTNmMjAxMTU4MjY4MzlkYWRjNDE1NTA3ZiJ9.1Z_qcoFFC6N_yQ36JXG0R2ojjBsFuwbwRLszPOD71eI

然后回到流水线继续进行配置,在主机部署前面添加一个任务,搜索”人工卡点“,并按照角色进行配置:

111v037d2ba9dff80d43955ae4f8d4b2dea3?Signature=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJBcHBJRCI6IjVlNzQ4MmQ2MjE1MjJiZDVjN2Y5YjMzNSIsIl9hcHBJZCI6IjVlNzQ4MmQ2MjE1MjJiZDVjN2Y5YjMzNSIsIl9vcmdhbml6YXRpb25JZCI6IiIsImV4cCI6MTU5ODg2NDc0MSwiaWF0IjoxNTk4MjU5OTQxLCJyZXNvdXJjZSI6Ii9zdG9yYWdlLzExMXYwMzdkMmJhOWRmZjgwZDQzOTU1YWU0ZjhkNGIyZGVhMyJ9.HKcdN8V00ZfjkbcCJLTbo4RuDxwOdq5nsaUeg0C0LpA

111vf79c92a472d18c3fe698880cb15d9900?Signature=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJBcHBJRCI6IjVlNzQ4MmQ2MjE1MjJiZDVjN2Y5YjMzNSIsIl9hcHBJZCI6IjVlNzQ4MmQ2MjE1MjJiZDVjN2Y5YjMzNSIsIl9vcmdhbml6YXRpb25JZCI6IiIsImV4cCI6MTU5ODg2NDc0MSwiaWF0IjoxNTk4MjU5OTQxLCJyZXNvdXJjZSI6Ii9zdG9yYWdlLzExMXZmNzljOTJhNDcyZDE4YzNmZTY5ODg4MGNiMTVkOTkwMCJ9.P2DLkYQto0uWWXlflpATcbqhwcwV7HBfHALdAy9MwGg

111v21e887d00a530490c6c88b228c0d0d1b?Signature=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJBcHBJRCI6IjVlNzQ4MmQ2MjE1MjJiZDVjN2Y5YjMzNSIsIl9hcHBJZCI6IjVlNzQ4MmQ2MjE1MjJiZDVjN2Y5YjMzNSIsIl9vcmdhbml6YXRpb25JZCI6IiIsImV4cCI6MTU5ODg2NDc0MSwiaWF0IjoxNTk4MjU5OTQxLCJyZXNvdXJjZSI6Ii9zdG9yYWdlLzExMXYyMWU4ODdkMDBhNTMwNDkwYzZjODhiMjI4YzBkMGQxYiJ9.TF7stnbTUHuZDsv2ctyZpCsBtniMeFZ4tS_kVtWh6Tc

以上演示了如何添加一个进入测试环境的卡点,添加生产环境的卡点也是类似的,这里不再赘述,可以类似的进行配置。

运行流水线

配置完毕,点击”保存并运行”触发流水线:

扫描、单测及构建上传的任务自动完成,并停在了卡点上。普通人员无权限通过,切换到张三的账号之后,可以通过或者拒绝。

111v63aea00e076113d78db5f2b04cfb0b9a?Signature=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJBcHBJRCI6IjVlNzQ4MmQ2MjE1MjJiZDVjN2Y5YjMzNSIsIl9hcHBJZCI6IjVlNzQ4MmQ2MjE1MjJiZDVjN2Y5YjMzNSIsIl9vcmdhbml6YXRpb25JZCI6IiIsImV4cCI6MTU5ODg2NDc0MSwiaWF0IjoxNTk4MjU5OTQxLCJyZXNvdXJjZSI6Ii9zdG9yYWdlLzExMXY2M2FlYTAwZTA3NjExM2Q3OGRiNWYyYjA0Y2ZiMGI5YSJ9.U8VlYFU0Q4kr0MekgT0kBPumdC9nEBEODW_WRF7vF80

点击”验证通过“,流水线会进入Kubectl部署的任务。

111v861e4e2124433e08f591713ac7b3134d?Signature=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJBcHBJRCI6IjVlNzQ4MmQ2MjE1MjJiZDVjN2Y5YjMzNSIsIl9hcHBJZCI6IjVlNzQ4MmQ2MjE1MjJiZDVjN2Y5YjMzNSIsIl9vcmdhbml6YXRpb25JZCI6IiIsImV4cCI6MTU5ODg2NDc0MSwiaWF0IjoxNTk4MjU5OTQxLCJyZXNvdXJjZSI6Ii9zdG9yYWdlLzExMXY4NjFlNGUyMTI0NDMzZTA4ZjU5MTcxM2FjN2IzMTM0ZCJ9.ZM6ffXF-1vqJSNPqMpdnxYj75IS89Da8-iRkTIIwUjM

由于在manifest中包含了ingress配置,因此可以通过ack的ingress提供的域名访问服务:

$ curl http://www.c5a194a8ee10044xxxxxxx367692.cn-beijing.alicontainer.comGreetings from Spring Boot!Shell

回滚

如果发布完成之后发现线上服务有问题,则需要快速回滚。云效Flow提供了通过历史版本直接进行回滚的能力。

在流水线运行页面点击”部署历史“,然后选择相应的部署任务,便可以看到该部署任务所有的成功部署记录

111vf76f0f765fd6fc0b45b901b4c5abcd93?Signature=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJBcHBJRCI6IjVlNzQ4MmQ2MjE1MjJiZDVjN2Y5YjMzNSIsIl9hcHBJZCI6IjVlNzQ4MmQ2MjE1MjJiZDVjN2Y5YjMzNSIsIl9vcmdhbml6YXRpb25JZCI6IiIsImV4cCI6MTU5ODg2NDc0MSwiaWF0IjoxNTk4MjU5OTQxLCJyZXNvdXJjZSI6Ii9zdG9yYWdlLzExMXZmNzZmMGY3NjVmZDZmYzBiNDViOTAxYjRjNWFiY2Q5MyJ9.NCOHLL1ISFDBSnl7DJ4CifCqW-wgrqc1Nl2OElMCDZw

点击版本3的”回滚“,即可回滚到该版本

111va5ce46b6f9d0aeeae39a796f393512d9?Signature=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJBcHBJRCI6IjVlNzQ4MmQ2MjE1MjJiZDVjN2Y5YjMzNSIsIl9hcHBJZCI6IjVlNzQ4MmQ2MjE1MjJiZDVjN2Y5YjMzNSIsIl9vcmdhbml6YXRpb25JZCI6IiIsImV4cCI6MTU5ODg2NDc0MSwiaWF0IjoxNTk4MjU5OTQxLCJyZXNvdXJjZSI6Ii9zdG9yYWdlLzExMXZhNWNlNDZiNmY5ZDBhZWVhZTM5YTc5NmYzOTM1MTJkOSJ9.DoLtJ6JuXUhKZJ_QdDPGGBgNuHdRStFlMiJoRIvSevI

111vae5723b28815e730f07a38eb146c38a6?Signature=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJBcHBJRCI6IjVlNzQ4MmQ2MjE1MjJiZDVjN2Y5YjMzNSIsIl9hcHBJZCI6IjVlNzQ4MmQ2MjE1MjJiZDVjN2Y5YjMzNSIsIl9vcmdhbml6YXRpb25JZCI6IiIsImV4cCI6MTU5ODg2NDc0MSwiaWF0IjoxNTk4MjU5OTQxLCJyZXNvdXJjZSI6Ii9zdG9yYWdlLzExMXZhZTU3MjNiMjg4MTVlNzMwZjA3YTM4ZWIxNDZjMzhhNiJ9.TXp54_e-DaCMWRwigpG47Qk2pjWOIqXFJaTAbFmAlsg

通知

为了更好的进行协作,Flow提供了通知能力在流水线不同的生命周期节点上进行通知。一般来讲开发团队会关心部署的成功和失败,那么可以将该事件推送到团队的钉钉群中,配置方式如下,点击”添加插件”,选择钉钉机器人通知,填入webhook地址,运行时机选择”失败“,”成功”

111v73a86e498347e8b1afe206db5b9515f2?Signature=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJBcHBJRCI6IjVlNzQ4MmQ2MjE1MjJiZDVjN2Y5YjMzNSIsIl9hcHBJZCI6IjVlNzQ4MmQ2MjE1MjJiZDVjN2Y5YjMzNSIsIl9vcmdhbml6YXRpb25JZCI6IiIsImV4cCI6MTU5ODg2NDc0MSwiaWF0IjoxNTk4MjU5OTQxLCJyZXNvdXJjZSI6Ii9zdG9yYWdlLzExMXY3M2E4NmU0OTgzNDdlOGIxYWZlMjA2ZGI1Yjk1MTVmMiJ9.85O3g1JWrogGJ4hFxXNViuas1z9cRzUU9M7oUdhMMZk

再次运行之后,就会收到相应的通知:

111v942a7fc32939a6fa7d0c3e3236021ced?Signature=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJBcHBJRCI6IjVlNzQ4MmQ2MjE1MjJiZDVjN2Y5YjMzNSIsIl9hcHBJZCI6IjVlNzQ4MmQ2MjE1MjJiZDVjN2Y5YjMzNSIsIl9vcmdhbml6YXRpb25JZCI6IiIsImV4cCI6MTU5ODg2NDc0MSwiaWF0IjoxNTk4MjU5OTQxLCJyZXNvdXJjZSI6Ii9zdG9yYWdlLzExMXY5NDJhN2ZjMzI5MzlhNmZhN2QwYzNlMzIzNjAyMWNlZCJ9.qT29LzyTWVgr5oHjy_ve-QQ_jBn_9Ri9XD6jelMi8KU

五、结语

通过以上的操作流程,就可以建立起来一个协同多角色的流水线。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值