1
1
---
2
2
title : " 工作负载"
3
3
weight : 55
4
- description : 理解 Pods,Kubernetes 中可部署的最小计算对象,以及辅助它运行它们的高层抽象对象。
4
+ description : 理解 Kubernetes 中可部署的最小计算对象 Pod 以及辅助 Pod 运行的上层抽象。
5
+ card :
6
+ title : 工作负载与 Pod
7
+ name : concepts
8
+ weight : 60
5
9
---
6
-
7
10
<!--
8
11
title: "Workloads"
9
12
weight: 55
10
13
description: >
11
14
Understand Pods, the smallest deployable compute object in Kubernetes, and the higher-level abstractions that help you to run them.
12
15
no_list: true
16
+ card:
17
+ title: Workloads and Pods
18
+ name: concepts
19
+ weight: 60
13
20
-->
14
21
15
22
{{< glossary_definition term_id="workload" length="short" >}}
@@ -19,29 +26,24 @@ Whether your workload is a single component or several that work together, on Ku
19
26
it inside a set of [_pods_](/docs/concepts/workloads/pods).
20
27
In Kubernetes, a Pod represents a set of running
21
28
{{< glossary_tooltip text="containers" term_id="container" >}} on your cluster.
22
-
23
- A Pod has a defined lifecycle. For example, once a Pod is running in your cluster then
24
- a critical failure on the {{< glossary_tooltip text="node" term_id="node" >}} where that
25
- Pod is running means that all the Pods on that node fail. Kubernetes treats that level
26
- of failure as final: you would need to create a new Pod even if the node later recovers.
27
29
-->
28
30
在 Kubernetes 中,无论你的负载是由单个组件还是由多个一同工作的组件构成,
29
31
你都可以在一组 [ ** Pod** ] ( /zh-cn/docs/concepts/workloads/pods ) 中运行它。
30
32
在 Kubernetes 中,Pod 代表的是集群上处于运行状态的一组
31
- {{< glossary_tooltip text="容器" term_id="container" >}} 的集合。
33
+ {{< glossary_tooltip text="容器" term_id="container" >}}的集合。
32
34
33
35
<!--
34
36
Kubernetes pods have a [defined lifecycle](/docs/concepts/workloads/pods/pod-lifecycle/).
35
37
For example, once a pod is running in your cluster then a critical fault on the
36
38
{{< glossary_tooltip text="node" term_id="node" >}} where that pod is running means that
37
39
all the pods on that node fail. Kubernetes treats that level of failure as final: you
38
- would need to create a new ` Pod` to recover, even if the node later becomes healthy.
40
+ would need to create a new Pod to recover, even if the node later becomes healthy.
39
41
-->
40
42
Kubernetes Pod 遵循[ 预定义的生命周期] ( /zh-cn/docs/concepts/workloads/pods/pod-lifecycle/ ) 。
41
43
例如,当在你的集群中运行了某个 Pod,但是 Pod 所在的
42
44
{{< glossary_tooltip text="节点" term_id="node" >}} 出现致命错误时,
43
45
所有该节点上的 Pod 的状态都会变成失败。Kubernetes 将这类失败视为最终状态:
44
- 即使该节点后来恢复正常运行,你也需要创建新的 ` Pod ` 以恢复应用。
46
+ 即使该节点后来恢复正常运行,你也需要创建新的 Pod 以恢复应用。
45
47
46
48
<!--
47
49
However, to make life considerably easier, you don't need to manage each `Pod` directly.
@@ -60,65 +62,71 @@ Kubernetes provides several built-in workload resources:
60
62
Kubernetes 提供若干种内置的工作负载资源:
61
63
62
64
<!--
63
- * [` Deployment` ](/docs/concepts/workloads/controllers/deployment/) and [`ReplicaSet`](/docs/concepts/workloads/controllers/replicaset/)
65
+ * [Deployment](/docs/concepts/workloads/controllers/deployment/) and [`ReplicaSet`](/docs/concepts/workloads/controllers/replicaset/)
64
66
(replacing the legacy resource
65
67
{{< glossary_tooltip text="ReplicationController" term_id="replication-controller" >}}).
66
- ` Deployment` is a good fit for managing a stateless application workload on your cluster,
67
- where any ` Pod` in the ` Deployment` is interchangeable and can be replaced if needed.
68
- * [` StatefulSet` ](/docs/concepts/workloads/controllers/statefulset/) lets you
68
+ Deployment is a good fit for managing a stateless application workload on your cluster,
69
+ where any Pod in the Deployment is interchangeable and can be replaced if needed.
70
+ * [StatefulSet](/docs/concepts/workloads/controllers/statefulset/) lets you
69
71
run one or more related Pods that do track state somehow. For example, if your workload
70
- records data persistently, you can run a ` StatefulSet` that matches each ` Pod` with a
71
- [` PersistentVolume` ](/docs/concepts/storage/persistent-volumes/). Your code, running in the
72
- ` Pods` for that ` StatefulSet` , can replicate data to other ` Pods` in the same ` StatefulSet`
72
+ records data persistently, you can run a StatefulSet that matches each Pod with a
73
+ [PersistentVolume](/docs/concepts/storage/persistent-volumes/). Your code, running in the
74
+ Pods for that StatefulSet, can replicate data to other Pods in the same StatefulSet
73
75
to improve overall resilience.
74
76
-->
75
- * [ ` Deployment ` ] ( /zh-cn/docs/concepts/workloads/controllers/deployment/ ) 和
76
- [ ` ReplicaSet ` ] ( /zh-cn/docs/concepts/workloads/controllers/replicaset/ )
77
+ * [ Deployment] ( /zh-cn/docs/concepts/workloads/controllers/deployment/ ) 和
78
+ [ ReplicaSet] ( /zh-cn/docs/concepts/workloads/controllers/replicaset/ )
77
79
(替换原来的资源 {{< glossary_tooltip text="ReplicationController" term_id="replication-controller" >}})。
78
- ` Deployment ` 很适合用来管理你的集群上的无状态应用,` Deployment ` 中的所有
79
- ` Pod ` 都是相互等价的,并且在需要的时候被替换。
80
+ Deployment 很适合用来管理你的集群上的无状态应用,Deployment 中的所有
81
+ Pod 都是相互等价的,并且在需要的时候被替换。
80
82
* [ StatefulSet] ( /zh-cn/docs/concepts/workloads/controllers/statefulset/ )
81
83
让你能够运行一个或者多个以某种方式跟踪应用状态的 Pod。
82
- 例如,如果你的负载会将数据作持久存储,你可以运行一个 ` StatefulSet ` ,将每个
83
- ` Pod ` 与某个 [ ` PersistentVolume ` ] ( /zh-cn/docs/concepts/storage/persistent-volumes/ )
84
- 对应起来。你在 ` StatefulSet ` 中各个 ` Pod ` 内运行的代码可以将数据复制到同一
85
- ` StatefulSet ` 中的其它 ` Pod ` 中以提高整体的服务可靠性。
84
+ 例如,如果你的负载会将数据作持久存储,你可以运行一个 StatefulSet,将每个
85
+ Pod 与某个 [ PersistentVolume] ( /zh-cn/docs/concepts/storage/persistent-volumes/ )
86
+ 对应起来。你在 StatefulSet 中各个 Pod 内运行的代码可以将数据复制到同一
87
+ StatefulSet 中的其它 Pod 中以提高整体的服务可靠性。
86
88
<!--
87
- * [` DaemonSet` ](/docs/concepts/workloads/controllers/daemonset/) defines ` Pods` that provide
89
+ * [DaemonSet](/docs/concepts/workloads/controllers/daemonset/) defines Pods that provide
88
90
node-local facilities. These might be fundamental to the operation of your cluster, such
89
91
as a networking helper tool, or be part of an
90
92
{{< glossary_tooltip text="add-on" term_id="addons" >}}.
91
- Every time you add a node to your cluster that matches the specification in a `DaemonSet`,
92
- the control plane schedules a `Pod` for that `DaemonSet` onto the new node.
93
- * [`Job`](/docs/concepts/workloads/controllers/job/) and
94
- [`CronJob`](/docs/concepts/workloads/controllers/cron-jobs/)
95
- define tasks that run to completion and then stop. Jobs represent one-off tasks, whereas
96
- `CronJobs` recur according to a schedule.
93
+ Every time you add a node to your cluster that matches the specification in a DaemonSet,
94
+ the control plane schedules a Pod for that DaemonSet onto the new node.
95
+ * [Job](/docs/concepts/workloads/controllers/job/) and
96
+ [CronJob](/docs/concepts/workloads/controllers/cron-jobs/)
97
+ define tasks that run to completion and then stop.
98
+ You can use a [Job](/docs/concepts/workloads/controllers/job/) to
99
+ define a task that runs to completion, just once. You can use a
100
+ [CronJob](/docs/concepts/workloads/controllers/cron-jobs/) to run
101
+ the same Job multiple times according a schedule.
97
102
-->
98
103
* [ DaemonSet] ( /zh-cn/docs/concepts/workloads/controllers/daemonset/ )
99
- 定义提供节点本地支撑设施的 ` Pod ` 。这些 Pod 可能对于你的集群的运维是
104
+ 定义提供节点本地支撑设施的 Pod。这些 Pod 可能对于你的集群的运维是
100
105
非常重要的,例如作为网络链接的辅助工具或者作为网络
101
106
{{< glossary_tooltip text="插件" term_id="addons" >}}
102
107
的一部分等等。每次你向集群中添加一个新节点时,如果该节点与某 ` DaemonSet `
103
- 的规约匹配,则控制平面会为该 ` DaemonSet ` 调度一个 ` Pod ` 到该新节点上运行。
108
+ 的规约匹配,则控制平面会为该 DaemonSet 调度一个 Pod 到该新节点上运行。
104
109
* [ Job] ( /zh-cn/docs/concepts/workloads/controllers/job/ ) 和
105
110
[ CronJob] ( /zh-cn/docs/concepts/workloads/controllers/cron-jobs/ ) 。
106
- 定义一些一直运行到结束并停止的任务。` Job ` 用来执行一次性任务,而
107
- ` CronJob ` 用来执行的根据时间规划反复运行的任务。
111
+ 定义一些一直运行到结束并停止的任务。
112
+ 你可以使用 [ Job] ( /zh-cn/docs/concepts/workloads/controllers/job/ )
113
+ 来定义只需要执行一次并且执行后即视为完成的任务。你可以使用
114
+ [ CronJob] ( /zh-cn/docs/concepts/workloads/controllers/cron-jobs/ )
115
+ 来根据某个排期表来多次运行同一个 Job。
108
116
109
117
<!--
110
118
In the wider Kubernetes ecosystem, you can find third-party workload resources that provide
111
119
additional behaviors. Using a
112
120
[custom resource definition](/docs/concepts/extend-kubernetes/api-extension/custom-resources/),
113
121
you can add in a third-party workload resource if you want a specific behavior that's not part
114
- of Kubernetes' core. For example, if you wanted to run a group of ` Pods` for your application but
122
+ of Kubernetes' core. For example, if you wanted to run a group of Pods for your application but
115
123
stop work unless _all_ the Pods are available (perhaps for some high-throughput distributed task),
116
124
then you can implement or install an extension that does provide that feature.
117
125
-->
118
126
在庞大的 Kubernetes 生态系统中,你还可以找到一些提供额外操作的第三方工作负载相关的资源。
119
127
通过使用[ 定制资源定义(CRD)] ( /zh-cn/docs/concepts/extend-kubernetes/api-extension/custom-resources/ ) ,
120
128
你可以添加第三方工作负载资源,以完成原本不是 Kubernetes 核心功能的工作。
121
- 例如,如果你希望运行一组 ` Pod ` ,但要求** 所有** Pod 都可用时才执行操作
129
+ 例如,如果你希望运行一组 Pod,但要求** 所有** Pod 都可用时才执行操作
122
130
(比如针对某种高吞吐量的分布式任务),你可以基于定制资源实现一个能够满足这一需求的扩展,
123
131
并将其安装到集群中运行。
124
132
@@ -127,23 +135,23 @@ then you can implement or install an extension that does provide that feature.
127
135
<!--
128
136
As well as reading about each resource, you can learn about specific tasks that relate to them:
129
137
130
- * [Run a stateless application using a ` Deployment` ](/docs/tasks/run-application/run-stateless-application-deployment/)
138
+ * [Run a stateless application using a Deployment](/docs/tasks/run-application/run-stateless-application-deployment/)
131
139
* Run a stateful application either as a [single instance](/docs/tasks/run-application/run-single-instance-stateful-application/)
132
140
or as a [replicated set](/docs/tasks/run-application/run-replicated-stateful-application/)
133
- * [Run automated tasks with a ` CronJob` ](/docs/tasks/job/automated-tasks-with-cron-jobs/)
141
+ * [Run automated tasks with a CronJob](/docs/tasks/job/automated-tasks-with-cron-jobs/)
134
142
-->
135
143
除了阅读了解每类资源外,你还可以了解与这些资源相关的任务:
136
144
137
- * [ 使用 ` Deployment ` 运行一个无状态的应用] ( /zh-cn/docs/tasks/run-application/run-stateless-application-deployment/ )
145
+ * [ 使用 Deployment 运行一个无状态的应用] ( /zh-cn/docs/tasks/run-application/run-stateless-application-deployment/ )
138
146
* 以[ 单实例] ( /zh-cn/docs/tasks/run-application/run-single-instance-stateful-application/ ) 或者[ 多副本集合] ( /zh-cn/docs/tasks/run-application/run-replicated-stateful-application/ )
139
147
的形式运行有状态的应用;
140
- * [ 使用 ` CronJob ` 运行自动化的任务] ( /zh-cn/docs/tasks/job/automated-tasks-with-cron-jobs/ )
148
+ * [ 使用 CronJob 运行自动化的任务] ( /zh-cn/docs/tasks/job/automated-tasks-with-cron-jobs/ )
141
149
142
150
<!--
143
151
To learn about Kubernetes' mechanisms for separating code from configuration,
144
152
visit [Configuration](/docs/concepts/configuration/).
145
153
-->
146
- 要了解 Kubernetes 将代码与配置分离的实现机制,可参阅[ 配置部分 ] ( /zh-cn/docs/concepts/configuration/ ) 。
154
+ 要了解 Kubernetes 将代码与配置分离的实现机制,可参阅[ 配置 ] ( /zh-cn/docs/concepts/configuration/ ) 节 。
147
155
148
156
<!--
149
157
There are two supporting concepts that provide backgrounds about how Kubernetes manages pods
@@ -162,10 +170,10 @@ for applications:
162
170
163
171
<!--
164
172
Once your application is running, you might want to make it available on the internet as
165
- a [` Service` ](/docs/concepts/services-networking/service/) or, for web application only,
166
- using an [` Ingress` ](/docs/concepts/services-networking/ingress).
173
+ a [Service](/docs/concepts/services-networking/service/) or, for web application only,
174
+ using an [Ingress](/docs/concepts/services-networking/ingress).
167
175
-->
168
176
一旦你的应用处于运行状态,你就可能想要以
169
- [ ` Service ` ] ( /zh-cn/docs/concepts/services-networking/service/ )
177
+ [ Service] ( /zh-cn/docs/concepts/services-networking/service/ )
170
178
的形式使之可在互联网上访问;或者对于 Web 应用而言,使用
171
- [ ` Ingress ` ] ( /zh-cn/docs/concepts/services-networking/ingress ) 资源将其暴露到互联网上。
179
+ [ Ingress] ( /zh-cn/docs/concepts/services-networking/ingress ) 资源将其暴露到互联网上。
0 commit comments