Skip to content

Commit

Permalink
[zh] Sync Tutorial update-intro.
Browse files Browse the repository at this point in the history
Add update steps translations.

Apply suggestions from code review

Co-authored-by: Qiming Teng <tengqm@outlook.com>
  • Loading branch information
1000Delta and tengqm committed Nov 16, 2023
1 parent 4963044 commit c8043a6
Showing 1 changed file with 167 additions and 31 deletions.
198 changes: 167 additions & 31 deletions content/zh-cn/docs/tutorials/kubernetes-basics/update/update-intro.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
---
title: 执行滚动更新
weight: 10
description: |-
使用 kubectl 执行滚动更新。
---

<!--
---
title: Performing a Rolling Update
weight: 10
description: |-
Perform a rolling update using kubectl.
---
-->

Expand All @@ -16,9 +20,6 @@

<body>

<link href="/docs/tutorials/kubernetes-basics/public/css/styles.css" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Roboto+Slab:300,400,700" rel="stylesheet">

<div class="layout" id="top">

<main class="content">
Expand All @@ -41,49 +42,52 @@ <h3>目标</h3>
<h3>Updating an application</h3>
-->
<h3>更新应用程序</h3>

<!--
<p>Users expect applications to be available all the time and developers are expected to deploy new versions of them several times a day. In Kubernetes this is done with rolling updates. <b>Rolling updates</b> allow Deployments' update to take place with zero downtime by incrementally updating Pods instances with new ones. The new Pods will be scheduled on Nodes with available resources.</p>
-->
<p>用户希望应用程序始终可用,而开发人员则需要每天多次部署它们的新版本。在 Kubernetes 中,这些是通过滚动更新(Rolling Updates)完成的。 <b>滚动更新</b> 允许通过使用新的实例逐步更新 Pod 实例,零停机进行 Deployment 更新。新的 Pod 将在具有可用资源的节点上进行调度。</p>

<p>用户希望应用程序始终可用,而开发人员则需要每天多次部署它们的新版本。
在 Kubernetes 中,这些是通过滚动更新(Rolling Updates)完成的。
<b>滚动更新</b> 允许通过使用新的实例逐步更新 Pod 实例,实现零停机的 Deployment 更新。
新的 Pod 将被调度到具有可用资源的节点上。</p>

<!--
<p>In the previous module we scaled our application to run multiple instances. This is a requirement for performing updates without affecting application availability. By default, the maximum number of Pods that can be unavailable during the update and the maximum number of new Pods that can be created, is one. Both options can be configured to either numbers or percentages (of Pods).
In Kubernetes, updates are versioned and any Deployment update can be reverted to previous (stable) version.</p>
In Kubernetes, updates are versioned and any Deployment update can be reverted to a previous (stable) version.</p>
-->
<p>在前面的模块中,我们将应用程序扩展为运行多个实例。这是在不影响应用程序可用性的情况下执行更新的要求。默认情况下,更新期间不可用的 pod 的最大值和可以创建的新 pod 数都是 1。这两个选项都可以配置为(pod)数字或百分比。
<p>在前面的模块中,我们将应用程序扩展为运行多个实例。这是在不影响应用程序可用性的情况下执行更新的要求。
默认情况下,更新期间不可用的 pod 的最大值和可以创建的新 pod 数都是 1。这两个选项都可以配置为(pod)数字或百分比。
在 Kubernetes 中,更新是经过版本控制的,任何 Deployment 更新都可以恢复到以前的(稳定)版本。</p>



</div>
<div class="col-md-4">
<div class="content__box content__box_lined">
<!--
<!--
<h3>Summary:</h3>
-->
-->
<h3>摘要:</h3>
<ul>
<!--
<!--
<li>Updating an app</li>
-->
-->
<li>更新应用</li>
</ul>
</div>
<div class="content__box content__box_fill">
<!--
<!--
<p><i>Rolling updates allow Deployments' update to take place with zero downtime by incrementally updating Pods instances with new ones. </i></p>
-->
<p><i>滚动更新允许通过使用新的实例逐步更新 Pod 实例从而实现 Deployments 更新,停机时间为零</i></p>
-->
<p><i>滚动更新通过逐步更新 Pod 实例并替换为新的实例,从而允许在 Deployment 更新过程中实现零停机</i></p>
</div>
</div>
</div>
<br>

<div class="row">
<div class="col-md-8">
<!--
<!--
<h2 style="color: #3771e3;">Rolling updates overview</h2>
-->
-->
<h2 style="color: #3771e3;">滚动更新概述</h2>
</div>
</div>
Expand Down Expand Up @@ -129,24 +133,27 @@ <h2 style="color: #3771e3;">滚动更新概述</h2>

<div class="row">
<div class="col-md-8">
<!--

<!--
<p>Similar to application Scaling, if a Deployment is exposed publicly, the Service will load-balance the traffic only to available Pods during the update. An available Pod is an instance that is available to the users of the application.</p>
-->
<p>与应用程序扩展类似,如果 Deployment 是公开的,服务将在更新期间仅对可用的 pod 进行负载均衡。可用 Pod 是应用程序用户可用的实例。</p>
-->
<p>与应用程序扩展类似,如果 Deployment 是公开的,Service 在更新期间仅将流量负载均衡到可用的 Pod。
可用的 Pod 是指应用程序对于用户可用的实例。</p>

<!--
<!--
<p>Rolling updates allow the following actions:</p>
-->
-->
<p>滚动更新允许以下操作:</p>
<ul>
<!--
<!--
<li>Promote an application from one environment to another (via container image updates)</li>
<li>Rollback to previous versions</li>
<li>Continuous Integration and Continuous Delivery of applications with zero downtime</li>
-->
<li>将应用程序从一个环境提升到另一个环境(通过容器镜像更新)</li>
-->
<li>将应用程序从一个环境升级到另一个环境(通过容器镜像更新)</li>
<li>回滚到以前的版本</li>
<li>持续集成和持续交付应用程序,无需停机</li>

</ul>

</div>
Expand All @@ -155,7 +162,7 @@ <h2 style="color: #3771e3;">滚动更新概述</h2>
<!--
<p><i>If a Deployment is exposed publicly, the Service will load-balance the traffic only to available Pods during the update. </i></p>
-->
<p><i>如果 Deployment 是公开的,则服务将仅在更新期间对可用的 pod 进行负载均衡。 </i></p>
<p><i>如果 Deployment 是公开的,Service 在更新期间仅将流量负载均衡到可用的 Pod。</i></p>
</div>
</div>
</div>
Expand All @@ -173,16 +180,145 @@ <h2 style="color: #3771e3;">滚动更新概述</h2>
</div>
<br>

<div class="row">
<div class="col-md-12">
<!-- <h3>Update the version of the app</h3> -->
<h3>更新应用的版本</h3>
<!--
<p>To list your Deployments, run the <code>get deployments</code> subcommand:
-->
<p>要列举 Deployment,请运行 <code>get deployments</code> 子命令:</p>
<p><code><b>kubectl get deployments</b></code></p>
<!--
<p>To list the running Pods, run the <code>get pods</code> subcommand:</p>
-->
<p>要列举运行中的 Pod,请运行 <code>get pods</code> 子命令:</p>
<p><code><b>kubectl get pods</b></code></p>
<!--
<p>To view the current image version of the app, run the <code>describe pods</code> subcommand
and look for the <code>Image</code> field:</p>
-->
<p>要查看应用程序当前的版本,请运行 <code>describe pods</code> 子命令,
然后查找 <code>Image</code> 字段:</p>
<p><code><b>kubectl describe pods</b></code></p>
<!--
<p>To update the image of the application to version 2, use the <code>set image</code> subcommand, followed by the deployment name and the new image version:</p>
-->
<p>要更新应用程序的镜像版本到 v2,请使用 <code>set image</code> 子命令,后面给出 Deployment 名称和新的镜像版本:</p>
<p><code><b>kubectl set image deployments/kubernetes-bootcamp kubernetes-bootcamp=jocatalin/kubernetes-bootcamp:v2</b></code></p>
<!--
<p>The command notified the Deployment to use a different image for your app and initiated a rolling update. Check the status of the new Pods, and view the old one terminating with the <code>get pods</code> subcommand:</p>
-->
<p>此命令通知 Deployment 为应用程序使用不同的镜像,并启动滚动更新。
要检查新 Pod 的状态,并查看旧 Pod 的终止状况,请使用 <code>get pods</code> 子命令:</p>
<p><code><b>kubectl get pods</b></code></p>
</div>
</div>
<div class="row">
<div class="col-md-12">
<!-- <h3>Step 2: Verify an update</h3> -->
<h3>第二步:验证更新</h3>
<!--
<p>First, check that the app is running. To find the exposed IP address and port, run the <code>describe service</code> command:</p>
-->
<p>首先,检查应用是否正在运行。要查找应用暴露的 IP 地址和端口,请运行 <code>describe services</code> 子命令:</p>
<p><code><b>kubectl describe services/kubernetes-bootcamp</b></code></p>
<!--
<p>Create an environment variable called <tt>NODE_PORT</tt> that has the value of the Node port assigned:</p>
-->
<P>创建名为 <tt>NODE_PORT</tt> 的环境变量,值为已被分配的 Node 端口:</P>
<p><code><b>export NODE_PORT="$(kubectl get services/kubernetes-bootcamp -o go-template='{{(index .spec.ports 0).nodePort}}')"</b></code><br />
<code><b>echo "NODE_PORT=$NODE_PORT"</b></code></p>
<!--
<p>Next, do a <code>curl</code> to the exposed IP and port:</p>
-->
<p>接下来,针对所暴露的 IP 和端口执行 <code>curl</code></p>
<p><code><b>curl http://"$(minikube ip):$NODE_PORT"</b></code></p>
<!--
<p>Every time you run the <code>curl</code> command, you will hit a different Pod. Notice that all Pods are now running the latest version (v2).</p>
<p>You can also confirm the update by running the <code>rollout status</code> subcommand:</p>
-->
<p>你每次执行 <code>curl</code> 命令,都会命中不同的 Pod。注意现在所有的 Pod 都运行着最新版本(v2)。</p>
<p>你也可以通过运行 <code>rollout status</code> 来确认此次更新:</p>
<p><code><b>kubectl rollout status deployments/kubernetes-bootcamp</b></code></p>
<!--
<p>To view the current image version of the app, run the <code>describe pods</code> subcommand:</p>
-->
<p>要查看应用程序当前的镜像版本,请运行 <code>describe pods</code> 子命令:</p>
<p><code><b>kubectl describe pods</b></code></p>
<!--
<p>In the <code>Image</code> field of the output, verify that you are running the latest image version (v2).</p>
-->
<p>在输出的 <code>Image</code> 字段,确认你正在运行最新的版本(v2)。</p>
</div>
</div>

<div class="row">
<div class="col-md-12">
<!-- <h3>Roll back an update</h3> -->
<h3>回滚更新</h3>
<!--
<p>Let’s perform another update, and try to deploy an image tagged with <code>v10</code>:</p>
-->
<p>让我们执行另一次更新,并尝试部署一个标记为 <code>v10</code> 的镜像:</p>
<p><code><b>kubectl set image deployments/kubernetes-bootcamp kubernetes-bootcamp=gcr.io/google-samples/kubernetes-bootcamp:v10</b></code></p>
<!--
<p>Use <code>get deployments</code> to see the status of the deployment:</p>
-->
<p>使用 <code>get deployments</code> 来查看 Deployment 的状态:</p>
<p><code><b>kubectl get deployments</b></code></p>
<!--
<p>Notice that the output doesn't list the desired number of available Pods. Run the <code>get pods</code> subcommand to list all Pods:</p>
-->
<p>注意,这里的输出列出的可用 Pod 数量不符合预期。
运行 <code>get pods</code> 子命令来列举所有的 Pod:</p>
<p><code><b>kubectl get pods</b></code></p>
<!--
<p>Notice that some of the Pods have a status of <tt>ImagePullBackOff</tt>.</p>
<p>To get more insight into the problem, run the <code>describe pods</code> subcommand:</p>
-->
<p>注意此处部分 Pod 的状态是 <tt>ImagePullBackOff</tt></p>
<p>要深入了解此问题,请运行 <code>describe pods</code> 子命令:</p>
<p><code><b>kubectl describe pods</b></code></p>
<!--
<p>In the <code>Events</code> section of the output for the affected Pods, notice that the <code>v10</code> image version did not exist in the repository.</p>
<p>To roll back the deployment to your last working version, use the <code>rollout undo</code> subcommand:</p>
-->
<p>在受影响的 Pod 的 <code>Events</code> 部分,
可以注意到镜像的 <code>v10</code> 版本在仓库中不存在。</p>
<p>要回滚 Deployment 到上一个工作的版本,请使用 <code>rollout undo</code> 子命令:</p>
<p><code><b>kubectl rollout undo deployments/kubernetes-bootcamp</b></code></p>
<!--
<p>The <code>rollout undo</code> command reverts the deployment to the previous known state (v2 of the image). Updates are versioned and you can revert to any previously known state of a Deployment.</p>
<p>Use the <code>get pods</code> subcommand to list the Pods again:</p>
-->
<p><code>rollout undo</code> 命令会恢复 Deployment 到先前的已知状态(v2 的镜像)。
更新是受版本控制的,你可以恢复 Deployment 到任何先前已知状态。</p>
<p>使用 <code>get pods</code> 子命令再次列举 Pod:</p>
<p><code><b>kubectl get pods</b></code></p>
<!--
<p>Four Pods are running. To check the image deployed on these Pods, use the <code>describe pods</code> subcommand:</p>
-->
<p>有四个 Pod 正在运行。要检查这些 Pod 部署的镜像,
请使用 <code>describe pods</code> 子命令:</p>
<p><code><b>kubectl describe pods</b></code></p>
<!--
<p>The Deployment is once again using a stable version of the app (v2). The rollback was successful.</p>
-->
<p>Deployment 再次使用了稳定版本的应用程序(v2)。回滚成功。</p>
</div>
</div>
<div class="row">
<div class="col-md-12">
<!--
<a class="btn btn-lg btn-success" href="/docs/tutorials/kubernetes-basics/update/update-interactive/" role="button">Start Interactive Tutorial <span class="btn__next">›</span></a>
<p>Remember to clean up your local cluster</p>
-->
<a class="btn btn-lg btn-success" href="/zh-cn/docs/tutorials/kubernetes-basics/update/update-interactive/" role="button">启动交互教程<span class="btn__next"></span></a>

<p>记得清理本地集群:</p>
<p><code><b>kubectl delete deployments/kubernetes-bootcamp services/kubernetes-bootcamp</b></code></p>
</div>
</div>


</main>

</div>
Expand Down

0 comments on commit c8043a6

Please sign in to comment.