Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to implement DevOps in TKE

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

Most people do not understand the knowledge points of this article "how to achieve DevOps in TKE", so the editor summarizes the following contents, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "how to achieve DevOps in TKE" article.

Overview

The concept of DevOps has been adopted by more and more enterprises. DevOps is a combination of Development and Operations, representing a culture that attaches importance to communication and cooperation between "software developers (Dev)" and "IT operation and maintenance technicians (Ops)". It aims to automate the process of "software delivery" and "architecture change" to make the process of building, testing and releasing software faster, more frequent and more reliable. In the cloud native era, we need Devops thinking to achieve agile development. This article will introduce and practice the TKE container DevOps service built specifically for cloud natively, to trigger the automatic construction of the image when the code is submitted, and then trigger the automatic deployment process to deploy and update the application to the TKE cluster when the image is successfully built. A set of seamless Devops pipelining.

Brief introduction of TKE Container DevOps

TKE container DevOps is a close combination of container service TKE, container image service TCR and CODING DevOps. It is oriented to container business scenarios, and has automatic code compilation, container image construction, image push, application deployment and other features to provide customers with powerful one-stop cloud native DevOps services. For more information on how to get started with Container DevOps, please see the best practices document of TKE and Coding for collaborative business implementation of rapid iteration.

TKE Container DevOps Business process

TKE container DevOps service runs through the lifecycle management of the entire application development and deployment process, and automates the process from code update to application deployment and update, as shown in the following figure:

How to use the TKE container DevOps to manipulate the scene

The TKE container Devops feature provides powerful cloud native Devops services. We will follow the above TKE container Devops business flow chart to implement a complete set of automated processes from source code update to business release.

prerequisite

Create a TKE test cluster

Refer to the documentation for how to create a deployment Container Services TKE.

Activate Container Image Service TCR service

An accessible TCR test instance has been created and test instance access credentials have been generated. TCR needs to activate Enterprise Standard Edition or Premium Edition to support cloud native delivery workflow. For more information, please see the purchase Guide for Container Image Services. For current TCR support regions, please refer to support regions.

Activate CODING DevOps service

The Coding Devops team has been created and perfected. If you use a sub-account to operate, use the main account to quickly create a sub-user with permission in the CODING DevOps console, or refer to the sub-user permission setting to grant the operation permission to the corresponding instance in advance.

Procedure TKE Container Devops access entry

Click the "Devops" function link in the left function menu bar of the TKE console to enter the "Container Devops" introduction interface, as shown below:

Click "use now" to jump to the Coding main page of your team to use the relevant DevOps features.

Configure code hosting

Create a test project and test code repository on the main page of the Coding team. For an introduction to Coding code hosting, please refer to the code hosting introduction. The creation steps are as follows:

* * step 1: create a test project in * * Project * * on the main page of the Coding team, as shown below:

* * step 2: test code * Click the created test project "test-jokey" to enter the main page of the project, and create a new test code repository in the "Code Repository" menu, as shown below:

Create a build plan

Create a construction plan in the "build Plan" submenu of "continuous Integration" on the left menu of the main page of the test project "test-jokey". The construction plan is the basic unit of continuous integration. You can quickly create a construction plan by selecting the build plan template. For more information, please refer to the documentation to start continuous integration quickly.

* * step 1: template * Select "build an image and push it to TCR Enterprise Edition" template to quickly create a component plan. The creation example is as follows:

* * step 2 Jenkinsfile preview * Select the code source to be checked out according to the construction plan template and configure the environment variables related to TCR access credentials. You can see the Jenkinsfile preview generated by the template on the right, as shown below:

Note: the private network is interconnected between Coding devops and TCR instances. The image push is transmitted via private network by default, and no additional configuration is required.

Using the build project generated by the build template, you can also customize the construction details by clicking the "Settings" menu of the build project. The features of the construction plan configuration page are described below:

[basic Information]: on the basic configuration page, you can select basic configurations such as code source and node pool. For more information on node pool, please refer to the document to build nodes.

[process configuration]: it is used to configure the environment in which the build task is run. For more information, please see the build environment.

[trigger rules]: the trigger rules used to configure the construction plan can be triggered in a variety of ways. For more information, please see trigger rules.

[variables and caching]: environment variables and cache configuration. For more information, please see environment variables and cache directory.

[notification reminder]: a notification reminder can be sent to specified Coding team members when the construction plan is completed.

In addition, you can also create a new WebHook in [Project configuration-> developer options-> WebHook] to push event notifications to instant messaging platforms such as WeCom. For more information, please see WebHook and bind WeChat Group Robot at work. The configuration example is as follows:

For more details on Coding continuous Integration, please refer to the introduction to continuous Integration.

Create a continuous deployment

Follow the steps to guide the creation of a continuous deployment pipeline in the "Kubernetes" submenu of "continuous Integration" on the left menu of the "test-jokey" main page of the test project, as shown below:

Configure cloud account

Please refer to the cloud account documentation to add the access cloud account information for configuring and deploying cloud resources. You can select a cloud account of [Tencent Cloud TKE] or [Kubernetes] type, and enter relevant authentication configuration to add a cloud account. Here, you choose [Kubernetes] to bind.

Configure applications and processes

For instructions on Coding applications and projects, please refer to the document Application and Project and process configuration. Here we briefly describe the key configuration items in the process of configuring applications and processes.

When creating an application, you need to check "Kubernetes (TKE) deployment":

When creating a deployment process in the newly created application, select the "Kubernetes" process template, and then select the process under the template according to the actual needs. Here, select the second process in the figure below to deploy Deployment and Service to the Kubernets cluster process:

When configuring the deployment process in "deployment process", the "launch required artifacts" option is associated with the TCR warehouse image artifacts generated by the previous continuous integration process:

Use "automatic trigger" to bind TCR repository image artifacts. The key point here is that when a new version of the image is successfully built, the deployment process will be triggered automatically, as follows:

The next step is to configure the [deployment Deployment] and [deployment Service] deployment phases. The configuration methods of the two phases are similar. Select the cloud account with deployment permission previously added and enter a custom Manifest, that is, the custom deployment YAML template.

Examples of custom Deployment YAML are as follows:

Tip: about continuous deployment of update strategy

This example only uses a simple Deployment YAML deployment to the Kubernetes cluster and uses the default rolling deployment (RollingUpdate) update strategy. In fact, you can use Nginx-ingress / Istio and other tools to configure more advanced update strategies, such as blue-green release, Canary, Amax B test, etc. For specific usage, please see Blue-Green release, Nginx-ingress to achieve automatic grayscale release, continuous deployment + TKE Mesh grayscale release practice.

ApiVersion: apps/v1kind: Deploymentmetadata: name: devops-appspec: replicas: 2 selector: matchLabels: app: devops-app template: metadata: labels: app: devops-appspec: containers:-image: xxx-test.tencentcloudcr.com/xxx-test/jokey-test # sample image address name: devops-app ports:-containerPort: 5000 ImagePullSecrets: # Private warehouse access credential configuration-name: tcr-secret # access credential secret

Among them, there will be a translation matching rule for spec.template.spec.containers.*.image 's image address field Coding. For more information on translation matching rules, please refer to the document binding artifacts in manifest.

There are two ways for TKE to pull TCR private repository image:

The TKE secret-free pull TCR container image can be configured in the TCR support region. For TCR support areas, please refer to the support region. For more information on how to configure the TKE cluster, use the TCR plug-in private network to pull the container image without encryption.

Manually configure TKE to pull the access credentials of TCR private warehouse image. For more information, please see the TKE configuration private warehouse access example.

Note: the above Deployment YAML example uses the method of "manually configuring TKE to pull access credentials for TCR private repository images".

Example of a custom Service Manifest YAML:

ApiVersion: v1kind: Servicemetadata: labels: app: devops-svc name: devops-svcspec: ports:-port: 5000 protocol: TCP selector: app: devops-app

In addition, custom event notifications can be configured for each stage of the deployment process (optional) to learn about the implementation of the deployment process easily and quickly. WeCom notification method is configured here. For more information on how to obtain links to WeCom's Webook robots, please see creating Enterprise WeChat Group Robots.

Associated projects and applications

For the associated project and application configuration, please refer to the documentation project and application association.

Bill of lading release

Bill of lading release, use and configuration, please refer to the documentation to create a new release order.

For more details on continuous deployment of Coding, please refer to the introduction to continuous deployment.

Test verification

Modify and add the v2 API code shown below in the project code file and submit the master branch:

Since the construction plan in continuous Integration uses the event trigger configuration of "automatic execution when code update", please refer to the trigger rules for the relevant trigger configuration. When the modified code is submitted, the associated build plan execution is automatically triggered:

If WeCom Webhook notification is configured for continuous integration, WeCom will also receive the corresponding instant notification message, as shown in the following figure:

When the construction plan generates a Docker image artifact, the associated "continuous deployment" process is automatically triggered to update the new image application to the TKE cluster:

If WeCom notification is configured in the deployment process, when the deployment process task is completed, you will receive the corresponding WeCom deployment completion notification, as shown in the following figure:

At this point, you can see that the workload has been successfully updated in TKE:

The above is about the content of this article on "how to achieve DevOps in TKE". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report