140 lines
7.0 KiB
HTML
140 lines
7.0 KiB
HTML
---
|
||
title: 运行应用程序的多个实例
|
||
weight: 10
|
||
---
|
||
|
||
<!--
|
||
---
|
||
title: Running Multiple Instances of Your App
|
||
weight: 10
|
||
---
|
||
-->
|
||
|
||
<!DOCTYPE html>
|
||
<html lang="zh">
|
||
<body>
|
||
<link href="/docs/tutorials/kubernetes-basics/public/css/styles.css" rel="stylesheet">
|
||
<div class="layout" id="top">
|
||
<main class="content">
|
||
<div class="row">
|
||
<div class="col-md-8">
|
||
<!-- <h3>Objectives</h3> -->
|
||
<h3>目的</h3>
|
||
<ul>
|
||
<!-- <li>Scale an app using kubectl.</li> -->
|
||
<li>用 kubectl 扩缩应用程序</li>
|
||
</ul>
|
||
</div>
|
||
|
||
<div class="col-md-8">
|
||
<!-- <h3>Scaling an application</h3> -->
|
||
<h3>扩缩应用程序</h3>
|
||
|
||
<!-- <p>In the previous modules we created a <a href="/docs/concepts/workloads/controllers/deployment/"> Deployment</a>,
|
||
and then exposed it publicly via a <a href="/docs/concepts/services-networking/service/">Service</a>.
|
||
The Deployment created only one Pod for running our application. When traffic increases, we will need to scale the application to keep up with user demand.</p> -->
|
||
<p>在之前的模块中,我们创建了一个 <a href="/zh/docs/concepts/workloads/controllers/deployment/"> Deployment</a>,然后通过 <a href="/zh/docs/concepts/services-networking/service/">Service</a>让其可以开放访问。Deployment 仅为跑这个应用程序创建了一个 Pod。 当流量增加时,我们需要扩容应用程序满足用户需求。</p>
|
||
|
||
<!-- <p><b>Scaling</b> is accomplished by changing the number of replicas in a Deployment</p> -->
|
||
<p><b>扩缩</b> 是通过改变 Deployment 中的副本数量来实现的。</p>
|
||
|
||
</div>
|
||
<div class="col-md-4">
|
||
<div class="content__box content__box_lined">
|
||
<!-- <h3>Summary:</h3> -->
|
||
<h3>小结:</h3>
|
||
<ul>
|
||
<!-- <li>Scaling a Deployment</li> -->
|
||
<li>扩缩一个 Deployment</li>
|
||
</ul>
|
||
</div>
|
||
<div class="content__box content__box_fill">
|
||
<!-- <p><i> You can create from the start a Deployment with multiple instances using the --replicas parameter for the kubectl run command </i></p> -->
|
||
<p><i> 在运行 kubectl run 命令时,你可以通过设置 --replicas 参数来设置 Deployment 的副本数。</i></p>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<br>
|
||
|
||
<div class="row">
|
||
<div class="col-md-8">
|
||
<!-- <h2 style="color: #3771e3;">Scaling overview</h2> -->
|
||
<h2 style="color: #3771e3;">扩缩概述</h2>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="row">
|
||
<div class="col-md-1"></div>
|
||
<div class="col-md-8">
|
||
<div id="myCarousel" class="carousel" data-ride="carousel" data-interval="3000">
|
||
<ol class="carousel-indicators">
|
||
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
|
||
<li data-target="#myCarousel" data-slide-to="1"></li>
|
||
</ol>
|
||
<div class="carousel-inner" role="listbox">
|
||
<div class="item carousel-item active">
|
||
<img src="/docs/tutorials/kubernetes-basics/public/images/module_05_scaling1.svg">
|
||
</div>
|
||
|
||
<div class="item carousel-item">
|
||
<img src="/docs/tutorials/kubernetes-basics/public/images/module_05_scaling2.svg">
|
||
</div>
|
||
</div>
|
||
|
||
<a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
|
||
<span class="sr-only ">Previous</span>
|
||
</a>
|
||
<a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
|
||
<span class="sr-only">Next</span>
|
||
</a>
|
||
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<br>
|
||
|
||
<div class="row">
|
||
<div class="col-md-8">
|
||
|
||
<!-- <p>Scaling out a Deployment will ensure new Pods are created and scheduled to Nodes with available resources. Scaling in will reduce the number of Pods to the new desired state. Kubernetes also supports
|
||
<a href="/docs/user-guide/horizontal-pod-autoscaling/">autoscaling</a> of Pods, but it is outside of the scope of this tutorial. Scaling to zero is also possible, and it will terminate all Pods of the specified Deployment.</p> -->
|
||
<p>扩展 Deployment 将创建新的 Pods,并将资源调度请求分配到有可用资源的节点上,收缩 会将 Pods 数量减少至所需的状态。Kubernetes 还支持 Pods 的<a href="/zh/docs/tasks/run-application/horizontal-pod-autoscale/">自动缩放</a>,但这并不在本教程的讨论范围内。将 Pods 数量收缩到0也是可以的,但这会终止 Deployment 上所有已经部署的 Pods。</p>
|
||
|
||
<!-- <p>Running multiple instances of an application will require a way to distribute the traffic to all of them. Services have an integrated load-balancer that will distribute network traffic to all Pods of an exposed Deployment.
|
||
Services will monitor continuously the running Pods using endpoints, to ensure the traffic is sent only to available Pods.</p> -->
|
||
<p>运行应用程序的多个实例需要在它们之间分配流量。服务 (Service)有一种负载均衡器类型,可以将网络流量均衡分配到外部可访问的 Pods 上。服务将会一直通过端点来监视 Pods 的运行,保证流量只分配到可用的 Pods 上。</p>
|
||
|
||
</div>
|
||
<div class="col-md-4">
|
||
<div class="content__box content__box_fill">
|
||
<!-- <p><i>Scaling is accomplished by changing the number of replicas in a Deployment.</i></p> -->
|
||
<p><i>扩缩是通过改变 Deployment 中的副本数量来实现的。</i></p>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<br>
|
||
|
||
<div class="row">
|
||
<div class="col-md-8">
|
||
<!-- <p> Once you have multiple instances of an Application running, you would be able to do Rolling updates without downtime. We'll cover that in the next module. Now, let's go to the online terminal and scale our application.</p> -->
|
||
<p>一旦有了多个应用实例,就可以没有宕机地滚动更新。我们将会在下面的模块中介绍这些。现在让我们使用在线终端来体验一下应用程序的扩缩过程。</p>
|
||
</div>
|
||
</div>
|
||
<br>
|
||
|
||
<div class="row">
|
||
<div class="col-md-12">
|
||
<!-- <a class="btn btn-lg btn-success" href="/docs/tutorials/kubernetes-basics/scale/scale-interactive/" role="button">Start Interactive Tutorial <span class="btn__next">›</span></a> -->
|
||
<a class="btn btn-lg btn-success" href="/zh/docs/tutorials/kubernetes-basics/scale/scale-interactive/" role="button">开始互动教程 <span class="btn__next">›</span></a>
|
||
</div>
|
||
</div>
|
||
|
||
</main>
|
||
|
||
</div>
|
||
|
||
</body>
|
||
</html>
|