教程:使用 Jenkins 持续集成和部署从 GitHub 部署到 Azure Kubernetes 服务 (AKS)Tutorial: Deploy from GitHub to Azure Kubernetes Service (AKS) with Jenkins continuous integration and deployment

本教程通过设置 Jenkins 中的持续集成 (CI) 和持续部署 (CD),将 GitHub 中的一个示例应用部署到 Azure 容器服务 (AKS) 群集。This tutorial deploys a sample app from GitHub to an Azure Kubernetes Service (AKS) cluster by setting up continuous integration (CI) and continuous deployment (CD) in Jenkins. 这样一来,将提交内容推送到 GitHub 以更新应用时,Jenkins 会自动运行一个新的容器内部版本,将容器映像推送到 Azure 容器注册表 (ACR),然后在 AKS 中运行应用。That way, when you update your app by pushing commits to GitHub, Jenkins automatically runs a new container build, pushes container images to Azure Container Registry (ACR), and then runs your app in AKS.

在本教程中,你将完成以下任务:In this tutorial, you'll complete these tasks:

  • 将示例 Azure 投票应用部署到 AKS 群集。Deploy a sample Azure vote app to an AKS cluster.
  • 创建一个基本的 Jenkins 项目。Create a basic Jenkins project.
  • 设置可供 Jenkins 与 ACR 交互的凭据。Set up credentials for Jenkins to interact with ACR.
  • 创建用于自动化生成的 Jenkins 生成作业和 GitHub Webhook。Create a Jenkins build job and GitHub webhook for automated builds.
  • 测试 CI/CD 管道,基于 GitHub 代码提交内容更新 AKS 中的应用程序。Test the CI/CD pipeline to update an application in AKS based on GitHub code commits.

先决条件Prerequisites

若要完成本教程,需要准备好以下各项:To complete this tutorial, you need these items:

准备应用Prepare your app

本文使用示例 Azure 投票应用程序,其中包含托管在一个或多个 Pod 中的 Web 接口,以及另一个托管 Redis 的 Pod(用作临时数据存储)。In this article, you use a sample Azure vote application that contains a web interface hosted in one or more pods, and a second pod hosting Redis for temporary data storage. 集成 Jenkins 和 AKS 以执行自动部署前,请先手动准备 Azure 投票应用程序,并将它部署到 AKS 群集。Before you integrate Jenkins and AKS for automated deployments, first manually prepare and deploy the Azure vote application to your AKS cluster. 此手动部署版本是示例应用程序的第一版,可便于了解应用程序的实际效果。This manual deployment is version one of the application, and lets you see the application in action.

备注

示例 Azure 投票应用程序使用计划在 Linux 节点上运行的 Linux pod。The sample Azure vote application uses a Linux pod that is scheduled to run on a Linux node.

为示例应用程序的以下 GitHub 存储库创建分支:https://github.com/Azure-Samples/azure-voting-app-redisFork the following GitHub repository for the sample application - https://github.com/Azure-Samples/azure-voting-app-redis. 若要将存储库分叉到自己的 GitHub 帐户,请选择右上角的“分叉”按钮 。To fork the repo to your own GitHub account, select the Fork button in the top right-hand corner.

将此分支克隆到开发系统。Clone the fork to your development system. 克隆此存储库时,请务必使用分支 URL:Make sure you use the URL of your fork when cloning this repo:

git clone https://github.com/<your-github-account>/azure-voting-app-redis.git

更改为已克隆分支的目录:Change to the directory of your cloned fork:

cd azure-voting-app-redis

若要创建示例应用程序所需的容器映像,请结合使用 docker-compose.yaml 文件和 docker-composeTo create the container images needed for the sample application, use the docker-compose.yaml file with docker-compose:

docker-compose up -d

此时,系统拉取所需的基础映像,并生成应用程序容器。The required base images are pulled and the application containers built. 然后,可运行 docker images 命令,以查看创建的映像。You can then use the docker images command to see the created image. 已下载或创建三个映像。Three images have been downloaded or created. azure-vote-front 映像包含应用程序,并以 nginx-flask 映像为依据。The azure-vote-front image contains the application and uses the nginx-flask image as a base. redis 映像用于启动 Redis 实例:The redis image is used to start a Redis instance:

$ docker images

REPOSITORY                   TAG        IMAGE ID            CREATED             SIZE
azure-vote-front             latest     9cc914e25834        40 seconds ago      694MB
redis                        latest     a1b99da73d05        7 days ago          106MB
tiangolo/uwsgi-nginx-flask   flask      788ca94b2313        9 months ago        694MB

必须先运行 az acr list 命令来获取 ACR 登录服务器,然后才能将 azure-vote-front 容器映像推送到 ACR。Before you can push the azure-vote-front container image to ACR, get your ACR login server with the az acr list command. 下面的示例为 myResourceGroup 资源组中的注册表获取 ACR 登录服务器地址:The following example gets the ACR login server address for a registry in the resource group named myResourceGroup:

az acr list --resource-group myResourceGroup --query "[].{acrLoginServer:loginServer}" --output table

运行 docker tag 命令,以为映像标记 ACR 登录服务器名称和版本号 v1Use the docker tag command to tag the image with the ACR login server name and a version number of v1. 提供在上一步中获取的你自己的 <acrLoginServer> 名称:Provide your own <acrLoginServer> name obtained in the previous step:

docker tag azure-vote-front <acrLoginServer>/azure-vote-front:v1

最后,将 azure-vote-front 映像推送到 ACR 注册表。Finally, push the azure-vote-front image to your ACR registry. 同样,将 <acrLoginServer> 替换为你自己的 ACR 注册表的登录服务器名称(如 myacrregistry.azurecr.cn):Again, replace <acrLoginServer> with the login server name of your own ACR registry, such as myacrregistry.azurecr.cn:

docker push <acrLoginServer>/azure-vote-front:v1

将示例应用程序部署到 AKSDeploy the sample application to AKS

若要将示例应用程序部署到 AKS 群集,可使用 Azure 投票存储库根目录中的 Kubernetes 清单文件。To deploy the sample application to your AKS cluster, you can use the Kubernetes manifest file in the root of the Azure vote repository repo. 使用 vi 等编辑器打开 azure-vote-all-in-one-redis.yaml 清单文件。Open the azure-vote-all-in-one-redis.yaml manifest file with an editor such as vi. microsoft 替换为 ACR 登录服务器名称。Replace microsoft with your ACR login server name. 此值位于清单文件的第 47 行:This value is found on line 47 of the manifest file:

containers:
- name: azure-vote-front
  image: dockerhub.azk8s.cn/microsoft/azure-vote-front:v1

接下来,使用 kubectl apply 命令将应用程序部署到 AKS 群集:Next, use the kubectl apply command to deploy the application to your AKS cluster:

kubectl apply -f azure-vote-all-in-one-redis.yaml

此时,系统创建 Kubernetes 负载均衡器服务,向 Internet 公开应用程序。A Kubernetes load balancer service is created to expose the application to the internet. 此过程可能需要几分钟。This process can take a few minutes. 若要监视负载均衡器部署进度,请结合使用 kubectl get service 命令和 --watch 参数。To monitor the progress of the load balancer deployment, use the kubectl get service command with the --watch argument. EXTERNAL-IP 地址从“挂起”变为 IP 地址以后, 请使用 Control + C 停止 kubectl 监视进程。Once the EXTERNAL-IP address has changed from pending to an IP address, use Control + C to stop the kubectl watch process.

$ kubectl get service azure-vote-front --watch

NAME               TYPE           CLUSTER-IP    EXTERNAL-IP   PORT(S)        AGE
azure-vote-front   LoadBalancer   10.0.215.27   <pending>     80:30747/TCP   22s
azure-vote-front   LoadBalancer   10.0.215.27   40.117.57.239   80:30747/TCP   2m

若要查看应用程序的实际效果,请打开 Web 浏览器,以转到服务的外部 IP 地址。To see the application in action, open a web browser to the external IP address of your service. 此时,Azure 投票应用程序显示,如下面的示例所示:The Azure vote application is displayed, as shown in the following example:

AKS 中运行的 Azure 示例投票应用程序

将 Jenkins 部署到 Azure VMDeploy Jenkins to an Azure VM

若要快速部署 Jenkins 以用于本文,可运行下面的脚本,以部署 Azure 虚拟机、配置网络访问并完成 Jenkins 基本安装。To quickly deploy Jenkins for use in this article, you can use the following script to deploy an Azure virtual machine, configure network access, and complete a basic installation of Jenkins. 为了在 Jenkins 和 AKS 群集之间进行身份验证,此脚本将 Kubernetes 配置文件从开发系统复制到 Jenkins 系统。For authentication between Jenkins and the AKS cluster, the script copies your Kubernetes configuration file from your development system to the Jenkins system.

警告

此示例脚本用于演示目的,以快速预配在 Azure VM 上运行的 Jenkins 环境。This sample script is for demo purposes to quickly provision a Jenkins environment that runs on an Azure VM. 它使用 Azure 自定义脚本扩展来配置 VM,然后显示所需的凭据。It uses the Azure custom script extension to configure a VM and then display the required credentials. ~/.kube/config 将复制到 Jenkins VM。Your ~/.kube/config is copied to the Jenkins VM.

运行以下命令下载并运行该脚本。Run the following commands to download and run the script. 运行任意脚本前,应先检查它的内容:https://raw.githubusercontent.com/Azure-Samples/azure-voting-app-redis/master/jenkins-tutorial/deploy-jenkins-vm.shYou should review the contents of any script prior to running it - https://raw.githubusercontent.com/Azure-Samples/azure-voting-app-redis/master/jenkins-tutorial/deploy-jenkins-vm.sh.

curl https://raw.githubusercontent.com/Azure-Samples/azure-voting-app-redis/master/jenkins-tutorial/deploy-jenkins-vm.sh > azure-jenkins.sh
sh azure-jenkins.sh

创建 VM 并部署 Docker 和 Jenkins 的必需组件,需要几分钟时间才能完成。It takes a few minutes to create the VM and deploy the required components for Docker and Jenkins. 此脚本在完成后输出 Jenkins 服务器地址,以及用于解锁仪表板的密钥,如下面的示例输出所示:When the script has completed, it outputs an address for the Jenkins server and a key to unlock the dashboard, as shown in the following example output:

Open a browser to http://40.115.43.83:8080
Enter the following to Unlock Jenkins:
667e24bba78f4de6b51d330ad89ec6c6

打开 Web 浏览器,以转到显示的 URL,并输入解锁密钥。Open a web browser to the URL displayed and enter the unlock key. 按照屏幕上的提示操作,完成 Jenkins 配置:Follow the on-screen prompts to complete the Jenkins configuration:

  • 选择“安装推荐插件” Choose Install suggested plugins
  • 创建第一个管理用户。Create the first admin user. 输入用户名(如 azureuser ),再提供你自己的安全密码。Enter a username, such as azureuser, then provide your own secure password. 最后,键入全名和电子邮件地址。Finally, type a full name and e-mail address.
  • 选择“保存并完成” Select Save and Finish
  • 准备好 Jenkins 后,选择“开始使用 Jenkins” Once Jenkins is ready, select Start using Jenkins
    • 如果开始使用 Jenkins 时 Web 浏览器显示空白页,请重启 Jenkins 服务。If your web browser displays a blank page when you start using Jenkins, restart the Jenkins service. 若要重启服务,请通过 SSH 转到 Jenkins 实例的公共 IP 地址,并键入 sudo service jenkins restartTo restart the service, SSH to the public IP address of your Jenkins instance and type sudo service jenkins restart. 在服务重启后,立即刷新 Web 浏览器。Once the service has restarted, refresh you web browser.
  • 使用在安装过程中创建的用户名和密码登录 Jenkins。Sign in to Jenkins with the username and password you created in the install process.

创建 Jenkins 环境变量Create a Jenkins environment variable

Jenkins 环境变量用于保留 ACR 登录服务器名称。A Jenkins environment variable is used to hold the ACR login server name. 此变量在 Jenkins 生成作业运行期间进行引用。This variable is referenced during the Jenkins build job. 若要创建此环境变量,请完成以下步骤:To create this environment variable, complete the following steps:

  • 在 Jenkins 门户的左侧,依次选择“管理 Jenkins” > “配置系统” On the left-hand side of the Jenkins portal, select Manage Jenkins > Configure System

  • 在“全局属性” 下,选择“环境变量” 。Under Global Properties, select Environment variables. 添加包含名称 ACR_LOGINSERVER 和 ACR 登录服务器值的变量。Add a variable with the name ACR_LOGINSERVER and the value of your ACR login server.

    Jenkins 环境变量

  • 完成后,单击 Jenkins 配置页底部的“保存” 。When complete, click Save at the bottom of the Jenkins configuration page.

创建 ACR 的 Jenkins 凭据Create a Jenkins credential for ACR

必须指定 ACR 的凭据,Jenkins 才能生成更新后的容器映像,并将它推送到 ACR。To allow Jenkins to build and then push updated container images to ACR, you need to specify credentials for ACR. 可使用 Azure Active Directory 服务主体执行此身份验证。This authentication can use Azure Active Directory service principals. 在先决条件中,已为 AKS 群集配置了对 ACR 注册表拥有“读者” 权限的服务主体。In the pre-requisites, you configured the service principal for your AKS cluster with Reader permissions to your ACR registry. 借助这些权限,AKS 群集可以从 ACR 注册表中拉取 映像。These permissions allow the AKS cluster to pull images from the ACR registry. 在 CI/CD 流程期间,Jenkins 根据应用程序更新生成新容器映像,然后需要将这些映像推送 到 ACR 注册表。During the CI/CD process, Jenkins builds new container images based on application updates, and needs to then push those images to the ACR registry. 现在,为 Jenkins 配置对 ACR 注册表拥有“参与者” 权限的服务主体,以区分角色和权限。For separation of roles and permissions, now configure a service principal for Jenkins with Contributor permissions to your ACR registry.

创建供 Jenkins 使用 ACR 的服务主体Create a service principal for Jenkins to use ACR

首先,使用 az ad sp create-for-rbac 命令创建服务主体:First, create a service principal using the az ad sp create-for-rbac command:

$ az ad sp create-for-rbac --skip-assignment

{
  "appId": "626dd8ea-042d-4043-a8df-4ef56273670f",
  "displayName": "azure-cli-2018-09-28-22-19-34",
  "name": "http://azure-cli-2018-09-28-22-19-34",
  "password": "1ceb4df3-c567-4fb6-955e-f95ac9460297",
  "tenant": "72f988bf-86f1-41af-91ab-2d7cd011db48"
}

记下输出中显示的 appId 和 password 。Make a note of the appId and password shown in your output. 在后续步骤中,需要用到这些值在 Jenkins 中配置凭据资源。These values are used in following steps to configure the credential resource in Jenkins.

使用 az acr show 命令获取 ACR 注册表的资源 ID,并将它存储为变量。Get the resource ID of your ACR registry using the az acr show command, and store it as a variable. 提供资源组名称和 ACR 名称:Provide your resource group name and ACR name:

ACR_ID=$(az acr show --resource-group myResourceGroup --name <acrLoginServer> --query "id" --output tsv)

现在创建角色分配,以向服务主体分配对 ACR 注册表的“参与者” 权限。Now create a role assignment to assign the service principal Contributor rights to the ACR registry. 在下面的示例中,提供在运行上一个用于创建服务主体的命令后输出显示的你自己 appId :In the following example, provide your own appId shown in the output a previous command to create the service principal:

az role assignment create --assignee 626dd8ea-042d-4043-a8df-4ef56273670f --role Contributor --scope $ACR_ID

在 Jenkins 中创建 ACR 服务主体的凭据资源Create a credential resource in Jenkins for the ACR service principal

借助在 Azure 中创建的角色分配,现在将 ACR 凭据存储在 Jenkins 凭据对象中。With the role assignment created in Azure, now store your ACR credentials in a Jenkins credential object. 在运行 Jenkins 生成作业期间会引用这些凭据。These credentials are referenced during the Jenkins build job.

返回到 Jenkins 门户的左侧,依次单击“凭据” > “Jenkins” > “全局凭据(无限制)” > “添加凭据” Back on the left-hand side of the Jenkins portal, click Credentials > Jenkins > Global credentials (unrestricted) > Add Credentials

确保凭据类型为“带密码的用户名”,并输入以下项: Ensure that the credential kind is Username with password and enter the following items:

  • 用户名 - 为采用 ACR 注册表身份验证而创建的服务主体的 appId 。Username - The appId of the service principal created for authentication with your ACR registry.
  • 密码 - 为采用 ACR 注册表身份验证而创建的服务主体的 password 。Password - The password of the service principal created for authentication with your ACR registry.
  • ID - 凭据标识符,如 acr-credentials ID - Credential identifier such as acr-credentials

完成后,凭据表单如下面的示例所示:When complete, the credentials form looks like the following example:

创建包含服务主体信息的 Jenkins 凭据对象

单击“确定” ,并返回到 Jenkins 门户。Click OK and return to the Jenkins portal.

创建 Jenkins 项目Create a Jenkins project

在 Jenkins 门户主页的左侧,选择“新建项” :From the home page of your Jenkins portal, select New item on the left-hand side:

  1. 输入“azure-vote” 作为作业名称。Enter azure-vote as job name. 依次选择“自由风格项目” 和“确定” Choose Freestyle project, then select OK

  2. 在“常规”部分下面,选择“GitHub 项目”并输入分支存储库的 URL,例如 https://github.com/<your-github-account>/azure-voting-app-redis Under the General section, select GitHub project and enter your forked repo URL, such as https://github.com/<your-github-account>/azure-voting-app-redis

  3. 在“源代码管理”部分下面,选择“Git”并输入分支存储库 .git 的 URL,例如 https://github.com/<your-github-account>/azure-voting-app-redis.git Under the Source code management section, select Git, enter your forked repo .git URL, such as https://github.com/<your-github-account>/azure-voting-app-redis.git

  4. 在“生成触发器” 部分下面,选择“用于 GITscm 轮询的 GitHub 挂钩触发器” Under the Build Triggers section, select GitHub hook trigger for GITscm polling

  5. 在“生成环境” 下,选择“使用机密文本或文件” Under Build Environment, select Use secret texts or files

  6. 在“绑定” 下,依次选择“添加” > “用户名和密码(已分隔)” Under Bindings, select Add > Username and password (separated)

    • 在“用户名变量”中输入 ACR_ID,并在“密码变量”中输入 ACR_PASSWORDEnter ACR_ID for the Username Variable, and ACR_PASSWORD for the Password Variable

      Jenkins 绑定

  7. 选择添加类型为“执行 shell”的“生成步骤”,并使用以下文本。Choose to add a Build Step of type Execute shell and use the following text. 此脚本将生成新的容器映像,并将其推送到 ACR 注册表。This script builds a new container image and pushes it to your ACR registry.

    # Build new image and push to ACR.
    WEB_IMAGE_NAME="${ACR_LOGINSERVER}/azure-vote-front:kube${BUILD_NUMBER}"
    docker build -t $WEB_IMAGE_NAME ./azure-vote
    docker login ${ACR_LOGINSERVER} -u ${ACR_ID} -p ${ACR_PASSWORD}
    docker push $WEB_IMAGE_NAME
    
  8. 添加另一个“执行 shell”类型的“生成步骤”并使用以下文本。 Add another Build Step of type Execute shell and use the following text. 此脚本使用 ACR 中的新容器映像来更新 AKS 中的应用程序部署。This script updates the application deployment in AKS with the new container image from ACR.

    # Update kubernetes deployment with new image.
    WEB_IMAGE_NAME="${ACR_LOGINSERVER}/azure-vote-front:kube${BUILD_NUMBER}"
    kubectl set image deployment/azure-vote-front azure-vote-front=$WEB_IMAGE_NAME --kubeconfig /var/lib/jenkins/config
    
  9. 完成后,单击“保存”。 Once completed, click Save.

测试 Jenkins 生成Test the Jenkins build

先手动测试 Jenkins 生成,再根据 GitHub 提交来自动执行作业。Before you automate the job based on GitHub commits, first manually test the Jenkins build. 此手动生成验证是否已正确配置生成作业、适当 Kubernetes 身份验证文件是否已就位,以及 ACR 身份验证能否正常运行。This manual build validates that the job has been correctly configured, the proper Kubernetes authentication file is in place, and that the authentication with ACR works.

在项目的左侧菜单中,选择“立即生成” 。On the left-hand menu of the project, select Build Now.

Jenkins 测试生成

第一个生成需要 1 或 2 分钟时间完成,因为 Docker 映像层被下拉到 Jenkins 服务器。The first build takes a minute or two as the Docker image layers are pulled down to the Jenkins server. 后续生成可使用缓存的映像层,以缩短生成时间。Subsequent builds can use the cached image layers to improve the build times.

在生成流程期间,GitHub 存储库克隆到 Jenkins 生成服务器。During the build process, the GitHub repository is cloned to the Jenkins build server. 将会生成新的容器映像并将其推送到 ACR 注册表。A new container image is built and pushed to the ACR registry. 最后,AKS 群集上运行的 Azure 投票应用程序会更新为使用新映像。Finally, the Azure vote application running on the AKS cluster is updated to use the new image. 由于未对应用程序代码进行任何更改,因此在 Web 浏览器中查看的示例应用程序没有变化。Because no changes have been made to the application code, the application is not changed if you view the sample app in a web browser.

生成作业完成后,立即单击生成历史记录下的“生成 1” 。Once the build job is complete, click on build #1 under build history. 选择“控制台输出” ,并查看生成流程的输出。Select Console Output and view the output from the build process. 最后一行应指示生成成功。The final line should indicate a successful build.

创建 GitHub WebhookCreate a GitHub webhook

成功完成手动生成后,立即将 GitHub 集成到 Jenkins 生成。With a successful manual build complete, now integrate GitHub into the Jenkins build. Webhook 可用于在 GitHub 中每次有代码提交时运行 Jenkins 生成作业。A webhook can be used to run the Jenkins build job each time a code commit is made in GitHub. 若要创建 GitHub Webhook,请完成以下步骤:To create the GitHub webhook, complete the following steps:

  1. 在 Web 浏览器中,转到 GitHub 分支存储库。Browse to your forked GitHub repository in a web browser.

  2. 选择“设置” ,然后在左侧选择“Webhook” 。Select Settings, then select Webhooks on the left-hand side.

  3. 选择“添加 Webhook” 。Choose to Add webhook. 对于“有效负载 URL” ,输入“http://<publicIp:8080>/github-webhook/”,其中 <publicIp> 是 Jenkins 服务器的 IP 地址。For the Payload URL, enter http://<publicIp:8080>/github-webhook/, where <publicIp> is the IP address of the Jenkins server. 请务必包含尾部的 /。Make sure to include the trailing /. 保留内容类型的其他默认值,并触发“推送” 事件。Leave the other defaults for content type and to trigger on push events.

  4. 选择“添加 Webhook” 。Select Add webhook.

    为 Jenkins 创建 GitHub Webhook

测试整个 CI/CD 管道Test the complete CI/CD pipeline

现在可测试整个 CI/CD 管道。Now you can test the whole CI/CD pipeline. 当你将代码提交推送到 GitHub 后,系统会执行以下步骤:When you push a code commit to GitHub, the following steps happen:

  1. GitHub Webhook 访问 Jenkins。The GitHub webhook reaches out to Jenkins.
  2. Jenkins 启动生成作业,并从 GitHub 拉取最新代码提交。Jenkins starts the build job and pulls the latest code commit from GitHub.
  3. Docker 生成通过更新后的代码启动,新容器映像标记有最新生成号。A Docker build is started using the updated code, and the new container image is tagged with the latest build number.
  4. 新容器映像推送到 Azure 容器注册表。This new container image is pushed to Azure Container Registry.
  5. 部署到 Azure Kubernetes 服务的应用程序使用 Azure 容器注册表中的最新容器映像进行更新。Your application deployed to Azure Kubernetes Service updates with the latest container image from the Azure Container Registry registry.

在开发计算机上,使用代码编辑器打开克隆的应用程序。On your development machine, open up the cloned application with a code editor. 在 /azure-vote/azure-vote 目录下,打开 config_file.cfg 文件。Under the /azure-vote/azure-vote directory, open the file named config_file.cfg. 将此文件中的投票值更新为,除 cats 和 dogs 以外的值,如下面的示例所示:Update the vote values in this file to something other than cats and dogs, as shown in the following example:

# UI Configurations
TITLE = 'Azure Voting App'
VOTE1VALUE = 'Blue'
VOTE2VALUE = 'Purple'
SHOWHOST = 'false'

更新后,保存此文件并提交更改,同时将更改推送到 GitHub 存储库的分支。When updated, save the file, commit the changes, and push these to your fork of the GitHub repository. GitHub Webhook 触发新的 Jenkins 生成作业。The GitHub webhook triggers a new build job in Jenkins. 在 Jenkins Web 仪表板中,监视生成流程。In the Jenkins web dashboard, monitor the build process. 只需几秒钟,即可拉取最新代码,创建和推送更新后的映像,并部署 AKS 中更新后的应用程序。It takes a few seconds to pull the latest code, create and push the updated image, and deploy the updated application in AKS.

生成完成后,立即刷新示例 Azure 投票应用程序的 Web 浏览器。Once the build is complete, refresh your web browser of the sample Azure vote application. 此时,更改显示,如下面的示例所示:Your changes are displayed, as shown in the following example:

AKS 中由 Jenkins 生成作业更新的示例 Azure 投票应用程序