add zh/ prefix of links in zh/ directory
This commit is contained in:
@@ -15,11 +15,11 @@ approvers:
|
||||
|
||||
<!--
|
||||
This tutorial provides an introduction to managing applications with
|
||||
[StatefulSets](/docs/concepts/workloads/controllers/statefulset/). It
|
||||
[StatefulSets](zh/docs/concepts/workloads/controllers/statefulset/). It
|
||||
demonstrates how to create, delete, scale, and update the Pods of StatefulSets.
|
||||
-->
|
||||
|
||||
本教程介绍如何了使用 [StatefulSets](/docs/concepts/abstractions/controllers/statefulsets/) 来管理应用。演示了如何创建、删除、扩容/缩容和更新 StatefulSets 的 Pods。
|
||||
本教程介绍如何了使用 [StatefulSets](zh/docs/concepts/abstractions/controllers/statefulsets/) 来管理应用。演示了如何创建、删除、扩容/缩容和更新 StatefulSets 的 Pods。
|
||||
|
||||
{{% /capture %}}
|
||||
|
||||
@@ -32,13 +32,13 @@ following Kubernetes concepts.
|
||||
|
||||
在开始本教程之前,你应该熟悉以下 Kubernetes 的概念:
|
||||
|
||||
* [Pods](/docs/user-guide/pods/single-container/)
|
||||
* [Cluster DNS](/docs/concepts/services-networking/dns-pod-service/)
|
||||
* [Headless Services](/docs/concepts/services-networking/service/#headless-services)
|
||||
* [PersistentVolumes](/docs/concepts/storage/persistent-volumes/)
|
||||
* [Pods](zh/docs/user-guide/pods/single-container/)
|
||||
* [Cluster DNS](zh/docs/concepts/services-networking/dns-pod-service/)
|
||||
* [Headless Services](zh/docs/concepts/services-networking/service/#headless-services)
|
||||
* [PersistentVolumes](zh/docs/concepts/storage/persistent-volumes/)
|
||||
* [PersistentVolume Provisioning](https://github.com/kubernetes/examples/tree/{{< param "githubbranch" >}}/staging/persistent-volume-provisioning/)
|
||||
* [StatefulSets](/docs/concepts/workloads/controllers/statefulset/)
|
||||
* [kubectl CLI](/docs/user-guide/kubectl/)
|
||||
* [StatefulSets](zh/docs/concepts/workloads/controllers/statefulset/)
|
||||
* [kubectl CLI](zh/docs/user-guide/kubectl/)
|
||||
|
||||
<!--
|
||||
This tutorial assumes that your cluster is configured to dynamically provision
|
||||
@@ -87,7 +87,7 @@ StatefulSets 旨在与有状态的应用及分布式系统一起使用。然而
|
||||
## 创建 StatefulSet
|
||||
|
||||
|
||||
作为开始,使用如下示例创建一个 StatefulSet。它和 [StatefulSets](/docs/concepts/abstractions/controllers/statefulsets/) 概念中的示例相似。它创建了一个 [Headless Service](/docs/user-guide/services/#headless-services) `nginx` 用来发布 StatefulSet `web` 中的 Pod 的 IP 地址。
|
||||
作为开始,使用如下示例创建一个 StatefulSet。它和 [StatefulSets](zh/docs/concepts/abstractions/controllers/statefulsets/) 概念中的示例相似。它创建了一个 [Headless Service](zh/docs/user-guide/services/#headless-services) `nginx` 用来发布 StatefulSet `web` 中的 Pod 的 IP 地址。
|
||||
|
||||
{{< codenew file="application/web/web.yaml" >}}
|
||||
|
||||
@@ -95,14 +95,14 @@ StatefulSets 旨在与有状态的应用及分布式系统一起使用。然而
|
||||
Download the example above, and save it to a file named `web.yaml`
|
||||
|
||||
You will need to use two terminal windows. In the first terminal, use
|
||||
[`kubectl get`](/docs/reference/generated/kubectl/kubectl-commands/#get) to watch the creation
|
||||
[`kubectl get`](zh/docs/reference/generated/kubectl/kubectl-commands/#get) to watch the creation
|
||||
of the StatefulSet's Pods.
|
||||
-->
|
||||
|
||||
下载上面的例子并保存为文件 `web.yaml`。
|
||||
|
||||
|
||||
你需要使用两个终端窗口。在第一个终端中,使用 [`kubectl get`](/docs/user-guide/kubectl/{{< param "version" >}}/#get) 来查看 StatefulSet 的 Pods 的创建情况。
|
||||
你需要使用两个终端窗口。在第一个终端中,使用 [`kubectl get`](zh/docs/user-guide/kubectl/{{< param "version" >}}/#get) 来查看 StatefulSet 的 Pods 的创建情况。
|
||||
|
||||
```shell
|
||||
kubectl get pods -w -l app=nginx
|
||||
@@ -110,11 +110,11 @@ kubectl get pods -w -l app=nginx
|
||||
|
||||
<!--
|
||||
In the second terminal, use
|
||||
[`kubectl apply`](/docs/reference/generated/kubectl/kubectl-commands/#apply) to create the
|
||||
[`kubectl apply`](zh/docs/reference/generated/kubectl/kubectl-commands/#apply) to create the
|
||||
Headless Service and StatefulSet defined in `web.yaml`.
|
||||
-->
|
||||
|
||||
在另一个终端中,使用 [`kubectl apply`](/docs/reference/generated/kubectl/kubectl-commands/#apply)来创建定义在 `web.yaml` 中的 Headless Service 和 StatefulSet。
|
||||
在另一个终端中,使用 [`kubectl apply`](zh/docs/reference/generated/kubectl/kubectl-commands/#apply)来创建定义在 `web.yaml` 中的 Headless Service 和 StatefulSet。
|
||||
|
||||
```shell
|
||||
kubectl apply -f web.yaml
|
||||
@@ -170,9 +170,9 @@ web-1 1/1 Running 0 18s
|
||||
|
||||
<!--
|
||||
Notice that the `web-1` Pod is not launched until the `web-0` Pod is
|
||||
[Running and Ready](/docs/user-guide/pod-states).
|
||||
[Running and Ready](zh/docs/user-guide/pod-states).
|
||||
-->
|
||||
请注意在 `web-0` Pod 处于 [Running和Ready](/docs/user-guide/pod-states) 状态后 `web-1` Pod 才会被启动。
|
||||
请注意在 `web-0` Pod 处于 [Running和Ready](zh/docs/user-guide/pod-states) 状态后 `web-1` Pod 才会被启动。
|
||||
|
||||
<!--
|
||||
## Pods in a StatefulSet
|
||||
@@ -205,7 +205,7 @@ web-1 1/1 Running 0 1m
|
||||
```
|
||||
|
||||
<!--
|
||||
As mentioned in the [StatefulSets](/docs/concepts/workloads/controllers/statefulset/)
|
||||
As mentioned in the [StatefulSets](zh/docs/concepts/workloads/controllers/statefulset/)
|
||||
concept, the Pods in a StatefulSet have a sticky, unique identity. This identity
|
||||
is based on a unique ordinal index that is assigned to each Pod by the
|
||||
StatefulSet controller. The Pods' names take the form
|
||||
@@ -215,15 +215,15 @@ replicas, it creates two Pods, `web-0` and `web-1`.
|
||||
### Using Stable Network Identities
|
||||
|
||||
Each Pod has a stable hostname based on its ordinal index. Use
|
||||
[`kubectl exec`](/docs/reference/generated/kubectl/kubectl-commands/#exec) to execute the
|
||||
[`kubectl exec`](zh/docs/reference/generated/kubectl/kubectl-commands/#exec) to execute the
|
||||
`hostname` command in each Pod.
|
||||
-->
|
||||
|
||||
如同 [StatefulSets](/docs/concepts/abstractions/controllers/statefulsets/) 概念中所提到的,StatefulSet 中的 Pod 拥有一个具有黏性的、独一无二的身份标志。这个标志基于 StatefulSet 控制器分配给每个 Pod 的唯一顺序索引。Pod 的名称的形式为`<statefulset name>-<ordinal index>`。`web`StatefulSet 拥有两个副本,所以它创建了两个 Pod:`web-0`和`web-1`。
|
||||
如同 [StatefulSets](zh/docs/concepts/abstractions/controllers/statefulsets/) 概念中所提到的,StatefulSet 中的 Pod 拥有一个具有黏性的、独一无二的身份标志。这个标志基于 StatefulSet 控制器分配给每个 Pod 的唯一顺序索引。Pod 的名称的形式为`<statefulset name>-<ordinal index>`。`web`StatefulSet 拥有两个副本,所以它创建了两个 Pod:`web-0`和`web-1`。
|
||||
|
||||
### 使用稳定的网络身份标识
|
||||
|
||||
每个 Pod 都拥有一个基于其顺序索引的稳定的主机名。使用[`kubectl exec`](/docs/reference/generated/kubectl/kubectl-commands/#exec)在每个 Pod 中执行`hostname`。
|
||||
每个 Pod 都拥有一个基于其顺序索引的稳定的主机名。使用[`kubectl exec`](zh/docs/reference/generated/kubectl/kubectl-commands/#exec)在每个 Pod 中执行`hostname`。
|
||||
|
||||
```shell
|
||||
for i in 0 1; do kubectl exec web-$i -- sh -c 'hostname'; done
|
||||
@@ -232,13 +232,13 @@ web-1
|
||||
```
|
||||
|
||||
<!--
|
||||
Use [`kubectl run`](/docs/reference/generated/kubectl/kubectl-commands/#run) to execute
|
||||
Use [`kubectl run`](zh/docs/reference/generated/kubectl/kubectl-commands/#run) to execute
|
||||
a container that provides the `nslookup` command from the `dnsutils` package.
|
||||
Using `nslookup` on the Pods' hostnames, you can examine their in-cluster DNS
|
||||
addresses.
|
||||
-->
|
||||
|
||||
使用 [`kubectl run`](/docs/reference/generated/kubectl/kubectl-commands/#run) 运行一个提供 `nslookup` 命令的容器,该命令来自于 `dnsutils` 包。通过对 Pod 的主机名执行 `nslookup`,你可以检查他们在集群内部的 DNS 地址。
|
||||
使用 [`kubectl run`](zh/docs/reference/generated/kubectl/kubectl-commands/#run) 运行一个提供 `nslookup` 命令的容器,该命令来自于 `dnsutils` 包。通过对 Pod 的主机名执行 `nslookup`,你可以检查他们在集群内部的 DNS 地址。
|
||||
|
||||
```shell
|
||||
kubectl run -i --tty --image busybox:1.28 dns-test --restart=Never --rm
|
||||
@@ -274,11 +274,11 @@ kubectl get pod -w -l app=nginx
|
||||
```
|
||||
<!--
|
||||
In a second terminal, use
|
||||
[`kubectl delete`](/docs/reference/generated/kubectl/kubectl-commands/#delete) to delete all
|
||||
[`kubectl delete`](zh/docs/reference/generated/kubectl/kubectl-commands/#delete) to delete all
|
||||
the Pods in the StatefulSet.
|
||||
-->
|
||||
|
||||
在另一个终端中使用 [`kubectl delete`](/docs/reference/generated/kubectl/kubectl-commands/#delete) 删除 StatefulSet 中所有的 Pod。
|
||||
在另一个终端中使用 [`kubectl delete`](zh/docs/reference/generated/kubectl/kubectl-commands/#delete) 删除 StatefulSet 中所有的 Pod。
|
||||
|
||||
```shell
|
||||
kubectl delete pod -l app=nginx
|
||||
@@ -382,7 +382,7 @@ www-web-1 Bound pvc-15c79307-b507-11e6-932f-42010a800002 1Gi RWO
|
||||
|
||||
<!--
|
||||
The StatefulSet controller created two PersistentVolumeClaims that are
|
||||
bound to two [PersistentVolumes](/docs/concepts/storage/persistent-volumes/). As the cluster used in this tutorial is configured to dynamically provision
|
||||
bound to two [PersistentVolumes](zh/docs/concepts/storage/persistent-volumes/). As the cluster used in this tutorial is configured to dynamically provision
|
||||
PersistentVolumes, the PersistentVolumes were created and bound automatically.
|
||||
|
||||
The NGINX webservers, by default, will serve an index file at
|
||||
@@ -394,7 +394,7 @@ Write the Pods' hostnames to their `index.html` files and verify that the NGINX
|
||||
webservers serve the hostnames.
|
||||
-->
|
||||
|
||||
StatefulSet 控制器创建了两个 PersistentVolumeClaims,绑定到两个 [PersistentVolumes](/docs/concepts/storage/volumes/)。由于本教程使用的集群配置为动态提供 PersistentVolume,所有的 PersistentVolume 都是自动创建和绑定的。
|
||||
StatefulSet 控制器创建了两个 PersistentVolumeClaims,绑定到两个 [PersistentVolumes](zh/docs/concepts/storage/volumes/)。由于本教程使用的集群配置为动态提供 PersistentVolume,所有的 PersistentVolume 都是自动创建和绑定的。
|
||||
|
||||
|
||||
NGINX web 服务器默认会加载位于 `/usr/share/nginx/html/index.html` 的 index 文件。StatefulSets `spec` 中的 `volumeMounts` 字段保证了 `/usr/share/nginx/html` 文件夹由一个 PersistentVolume 支持。
|
||||
@@ -491,8 +491,8 @@ mounted to the appropriate mount points.
|
||||
## Scaling a StatefulSet
|
||||
Scaling a StatefulSet refers to increasing or decreasing the number of replicas.
|
||||
This is accomplished by updating the `replicas` field. You can use either
|
||||
[`kubectl scale`](/docs/reference/generated/kubectl/kubectl-commands/#scale) or
|
||||
[`kubectl patch`](/docs/reference/generated/kubectl/kubectl-commands/#patch) to scale a StatefulSet.
|
||||
[`kubectl scale`](zh/docs/reference/generated/kubectl/kubectl-commands/#scale) or
|
||||
[`kubectl patch`](zh/docs/reference/generated/kubectl/kubectl-commands/#patch) to scale a StatefulSet.
|
||||
|
||||
### Scaling Up
|
||||
|
||||
@@ -504,7 +504,7 @@ In one terminal window, watch the Pods in the StatefulSet.
|
||||
|
||||
## 扩容/缩容 StatefulSet
|
||||
|
||||
扩容/缩容 StatefulSet 指增加或减少它的副本数。这通过更新 `replicas` 字段完成。你可以使用[`kubectl scale`](/docs/user-guide/kubectl/{{< param "version" >}}/#scale) 或者[`kubectl patch`](/docs/user-guide/kubectl/{{< param "version" >}}/#patch)来扩容/缩容一个 StatefulSet。
|
||||
扩容/缩容 StatefulSet 指增加或减少它的副本数。这通过更新 `replicas` 字段完成。你可以使用[`kubectl scale`](zh/docs/user-guide/kubectl/{{< param "version" >}}/#scale) 或者[`kubectl patch`](zh/docs/user-guide/kubectl/{{< param "version" >}}/#patch)来扩容/缩容一个 StatefulSet。
|
||||
|
||||
|
||||
### 扩容
|
||||
@@ -1071,13 +1071,13 @@ kubectl get pods -w -l app=nginx
|
||||
```
|
||||
|
||||
<!--
|
||||
Use [`kubectl delete`](/docs/reference/generated/kubectl/kubectl-commands/#delete) to delete the
|
||||
Use [`kubectl delete`](zh/docs/reference/generated/kubectl/kubectl-commands/#delete) to delete the
|
||||
StatefulSet. Make sure to supply the `--cascade=false` parameter to the
|
||||
command. This parameter tells Kubernetes to only delete the StatefulSet, and to
|
||||
not delete any of its Pods.
|
||||
-->
|
||||
|
||||
使用 [`kubectl delete`](/docs/reference/generated/kubectl/kubectl-commands/#delete) 删除 StatefulSet。请确保提供了 `--cascade=false` 参数给命令。这个参数告诉 Kubernetes 只删除 StatefulSet 而不要删除它的任何 Pod。
|
||||
使用 [`kubectl delete`](zh/docs/reference/generated/kubectl/kubectl-commands/#delete) 删除 StatefulSet。请确保提供了 `--cascade=false` 参数给命令。这个参数告诉 Kubernetes 只删除 StatefulSet 而不要删除它的任何 Pod。
|
||||
|
||||
```shell
|
||||
kubectl delete statefulset web --cascade=false
|
||||
|
||||
@@ -28,18 +28,18 @@ title: "Example: Deploying Cassandra with Stateful Sets"
|
||||
|
||||
本示例也使用了Kubernetes的一些核心组件:
|
||||
|
||||
- [_Pods_](/docs/user-guide/pods)
|
||||
- [ _Services_](/docs/user-guide/services)
|
||||
- [_Replication Controllers_](/docs/user-guide/replication-controller)
|
||||
- [_Stateful Sets_](/docs/concepts/workloads/controllers/statefulset/)
|
||||
- [_Daemon Sets_](/docs/admin/daemons)
|
||||
- [_Pods_](zh/docs/user-guide/pods)
|
||||
- [ _Services_](zh/docs/user-guide/services)
|
||||
- [_Replication Controllers_](zh/docs/user-guide/replication-controller)
|
||||
- [_Stateful Sets_](zh/docs/concepts/workloads/controllers/statefulset/)
|
||||
- [_Daemon Sets_](zh/docs/admin/daemons)
|
||||
|
||||
|
||||
|
||||
## 准备工作
|
||||
|
||||
|
||||
本示例假设你已经安装运行了一个 Kubernetes集群(版本 >=1.2),并且还在某个路径下安装了 [`kubectl`](/docs/tasks/tools/install-kubectl/) 命令行工具。请查看 [getting started guides](/docs/getting-started-guides/) 获取关于你的平台的安装说明。
|
||||
本示例假设你已经安装运行了一个 Kubernetes集群(版本 >=1.2),并且还在某个路径下安装了 [`kubectl`](zh/docs/tasks/tools/install-kubectl/) 命令行工具。请查看 [getting started guides](zh/docs/getting-started-guides/) 获取关于你的平台的安装说明。
|
||||
|
||||
|
||||
本示例还需要一些代码和配置文件。为了避免手动输入,你可以 `git clone` Kubernetes 源到你本地。
|
||||
@@ -133,7 +133,7 @@ kubectl delete daemonset cassandra
|
||||
## 步骤 1:创建 Cassandra Headless Service
|
||||
|
||||
|
||||
Kubernetes _[Service](/docs/user-guide/services)_ 描述一组执行同样任务的 [_Pod_](/docs/user-guide/pods)。在 Kubernetes 中,一个应用的原子调度单位是一个 Pod:一个或多个_必须_调度到相同主机上的容器。
|
||||
Kubernetes _[Service](zh/docs/user-guide/services)_ 描述一组执行同样任务的 [_Pod_](zh/docs/user-guide/pods)。在 Kubernetes 中,一个应用的原子调度单位是一个 Pod:一个或多个_必须_调度到相同主机上的容器。
|
||||
|
||||
这个 Service 用于在 Kubernetes 集群内部进行 Cassandra 客户端和 Cassandra Pod 之间的 DNS 查找。
|
||||
|
||||
@@ -354,7 +354,7 @@ $ kubectl exec cassandra-0 -- cqlsh -e 'desc keyspaces'
|
||||
system_traces system_schema system_auth system system_distributed
|
||||
```
|
||||
|
||||
你需要使用 `kubectl edit` 来增加或减小 Cassandra StatefulSet 的大小。你可以在[文档](/docs/user-guide/kubectl/kubectl_edit) 中找到更多关于 `edit` 命令的信息。
|
||||
你需要使用 `kubectl edit` 来增加或减小 Cassandra StatefulSet 的大小。你可以在[文档](zh/docs/user-guide/kubectl/kubectl_edit) 中找到更多关于 `edit` 命令的信息。
|
||||
|
||||
使用以下命令编辑 StatefulSet。
|
||||
|
||||
@@ -429,7 +429,7 @@ $ grace=$(kubectl get po cassandra-0 -o=jsonpath='{.spec.terminationGracePeriodS
|
||||
## 步骤 5:使用 Replication Controller 创建 Cassandra 节点 pod
|
||||
|
||||
|
||||
Kubernetes _[Replication Controller](/docs/user-guide/replication-controller)_ 负责复制一个完全相同的 pod 集合。像 Service 一样,它具有一个 selector query,用来识别它的集合成员。和 Service 不一样的是,它还具有一个期望的副本数,并且会通过创建或删除 Pod 来保证 Pod 的数量满足它期望的状态。
|
||||
Kubernetes _[Replication Controller](zh/docs/user-guide/replication-controller)_ 负责复制一个完全相同的 pod 集合。像 Service 一样,它具有一个 selector query,用来识别它的集合成员。和 Service 不一样的是,它还具有一个期望的副本数,并且会通过创建或删除 Pod 来保证 Pod 的数量满足它期望的状态。
|
||||
|
||||
和我们刚才定义的 Service 一起,Replication Controller 能够让我们轻松的构建一个复制的、可扩展的 Cassandra 集群。
|
||||
|
||||
@@ -639,7 +639,7 @@ $ kubectl delete rc cassandra
|
||||
## 步骤 8:使用 DaemonSet 替换 Replication Controller
|
||||
|
||||
|
||||
在 Kubernetes中,[_DaemonSet_](/docs/admin/daemons) 能够将 pod 一对一的分布到 Kubernetes 节点上。和 _ReplicationController_ 相同的是它也有一个用于识别它的集合成员的 selector query。但和 _ReplicationController_ 不同的是,它拥有一个节点 selector,用于限制基于模板的 pod 可以调度的节点。并且 pod 的复制不是基于一个设置的数量,而是为每一个节点分配一个 pod。
|
||||
在 Kubernetes中,[_DaemonSet_](zh/docs/admin/daemons) 能够将 pod 一对一的分布到 Kubernetes 节点上。和 _ReplicationController_ 相同的是它也有一个用于识别它的集合成员的 selector query。但和 _ReplicationController_ 不同的是,它拥有一个节点 selector,用于限制基于模板的 pod 可以调度的节点。并且 pod 的复制不是基于一个设置的数量,而是为每一个节点分配一个 pod。
|
||||
|
||||
示范用例:当部署到云平台时,预期情况是实例是短暂的并且随时可能终止。Cassandra 被搭建成为在各个节点间复制数据以便于实现数据冗余。这样的话,即使一个实例终止了,存储在它上面的数据却没有,并且集群会通过重新复制数据到其它运行节点来作为响应。
|
||||
|
||||
@@ -802,6 +802,6 @@ $ kubectl delete daemonset cassandra
|
||||
|
||||
查看本示例的 [image](https://github.com/kubernetes/examples/tree/master/cassandra/image) 目录,了解如何构建容器的 docker 镜像及其内容。
|
||||
|
||||
你可能还注意到我们设置了一些 Cassandra 参数(`MAX_HEAP_SIZE`和`HEAP_NEWSIZE`),并且增加了关于 [namespace](/docs/user-guide/namespaces) 的信息。我们还告诉 Kubernetes 容器暴露了 `CQL` 和 `Thrift` API 端口。最后,我们告诉集群管理器我们需要 0.1 cpu(0.1 核)。
|
||||
你可能还注意到我们设置了一些 Cassandra 参数(`MAX_HEAP_SIZE`和`HEAP_NEWSIZE`),并且增加了关于 [namespace](zh/docs/user-guide/namespaces) 的信息。我们还告诉 Kubernetes 容器暴露了 `CQL` 和 `Thrift` API 端口。最后,我们告诉集群管理器我们需要 0.1 cpu(0.1 核)。
|
||||
|
||||
[!Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/cassandra/README.md?pixel)]()
|
||||
|
||||
+13
-13
@@ -20,11 +20,11 @@ This tutorial shows you how to deploy a WordPress site and a MySQL database usin
|
||||
|
||||
|
||||
<!--
|
||||
A [PersistentVolume](/docs/concepts/storage/persistent-volumes/)(PV)is a piece of storage in the cluster that has been manually provisioned by an administrator, or dynamically provisioned by Kubernetes using a [StorageClass](/docs/concepts/storage/storage-classes). A [PersistentVolumeClaim](/docs/concepts/storage/persistent-volumes/#persistentvolumeclaims)(PVC)is a request for storage by a user that can be fulfilled by a PV. PersistentVolumes and PersistentVolumeClaims are independent from Pod lifecycles and preserve data through restarting, rescheduling, and even deleting Pods.
|
||||
A [PersistentVolume](zh/docs/concepts/storage/persistent-volumes/)(PV)is a piece of storage in the cluster that has been manually provisioned by an administrator, or dynamically provisioned by Kubernetes using a [StorageClass](zh/docs/concepts/storage/storage-classes). A [PersistentVolumeClaim](zh/docs/concepts/storage/persistent-volumes/#persistentvolumeclaims)(PVC)is a request for storage by a user that can be fulfilled by a PV. PersistentVolumes and PersistentVolumeClaims are independent from Pod lifecycles and preserve data through restarting, rescheduling, and even deleting Pods.
|
||||
-->
|
||||
|
||||
[PersistentVolume](/docs/concepts/storage/persistent-volumes/)(PV)是一块集群里由管理员手动提供,或 kubernetes 通过 [StorageClass](/docs/concepts/storage/storage-classes) 动态创建的存储。
|
||||
[PersistentVolumeClaim](/docs/concepts/storage/persistent-volumes/#persistentvolumeclaims)(PVC)是一个满足对 PV 存储需要的请求。PersistentVolumes 和 PersistentVolumeClaims 是独立于 Pod 生命周期而在 Pod 重启,重新调度甚至删除过程中保存数据。
|
||||
[PersistentVolume](zh/docs/concepts/storage/persistent-volumes/)(PV)是一块集群里由管理员手动提供,或 kubernetes 通过 [StorageClass](zh/docs/concepts/storage/storage-classes) 动态创建的存储。
|
||||
[PersistentVolumeClaim](zh/docs/concepts/storage/persistent-volumes/#persistentvolumeclaims)(PVC)是一个满足对 PV 存储需要的请求。PersistentVolumes 和 PersistentVolumeClaims 是独立于 Pod 生命周期而在 Pod 重启,重新调度甚至删除过程中保存数据。
|
||||
|
||||
{{< warning >}}
|
||||
<!--
|
||||
@@ -146,12 +146,12 @@ If you are bringing up a cluster that needs to use the `hostPath` provisioner, t
|
||||
### 创建 Secret 生成器
|
||||
|
||||
<!--
|
||||
A [Secret](/docs/concepts/configuration/secret/) is an object that stores a piece of sensitive data like a password or key. Since 1.14, `kubectl` supports the management of Kubernetes objects using a kustomization file. You can create a Secret by generators in `kustomization.yaml`.
|
||||
A [Secret](zh/docs/concepts/configuration/secret/) is an object that stores a piece of sensitive data like a password or key. Since 1.14, `kubectl` supports the management of Kubernetes objects using a kustomization file. You can create a Secret by generators in `kustomization.yaml`.
|
||||
|
||||
Add a Secret generator in `kustomization.yaml` from the following command. You will need to replace `YOUR_PASSWORD` with the password you want to use.
|
||||
-->
|
||||
|
||||
A [Secret](/docs/concepts/configuration/secret/) 是存储诸如密码或密钥之类的敏感数据的对象。从 1.14 开始,`kubectl`支持使用 kustomization 文件管理 Kubernetes 对象。您可以通过`kustomization.yaml`中的生成器创建一个 Secret。
|
||||
A [Secret](zh/docs/concepts/configuration/secret/) 是存储诸如密码或密钥之类的敏感数据的对象。从 1.14 开始,`kubectl`支持使用 kustomization 文件管理 Kubernetes 对象。您可以通过`kustomization.yaml`中的生成器创建一个 Secret。
|
||||
|
||||
通过以下命令在`kustomization.yaml`中添加一个 Secret 生成器。您需要用您要使用的密码替换`YOUR_PASSWORD`。
|
||||
|
||||
@@ -453,10 +453,10 @@ Do not leave your WordPress installation on this page. If another user finds it,
|
||||
|
||||
{{% capture whatsnext %}}
|
||||
|
||||
* Learn more about [Introspection and Debugging](/docs/tasks/debug-application-cluster/debug-application-introspection/)
|
||||
* Learn more about [Jobs](/docs/concepts/workloads/controllers/jobs-run-to-completion/)
|
||||
* Learn more about [Port Forwarding](/docs/tasks/access-application-cluster/port-forward-access-application-cluster/)
|
||||
* Learn how to [Get a Shell to a Container](/docs/tasks/debug-application-cluster/get-shell-running-container/)
|
||||
* Learn more about [Introspection and Debugging](zh/docs/tasks/debug-application-cluster/debug-application-introspection/)
|
||||
* Learn more about [Jobs](zh/docs/concepts/workloads/controllers/jobs-run-to-completion/)
|
||||
* Learn more about [Port Forwarding](zh/docs/tasks/access-application-cluster/port-forward-access-application-cluster/)
|
||||
* Learn how to [Get a Shell to a Container](zh/docs/tasks/debug-application-cluster/get-shell-running-container/)
|
||||
-->
|
||||
1. 运行以下命令以删除您的 Secret,Deployments,Services 和 PersistentVolumeClaims:
|
||||
|
||||
@@ -468,9 +468,9 @@ Do not leave your WordPress installation on this page. If another user finds it,
|
||||
|
||||
{{% capture whatsnext %}}
|
||||
|
||||
* 了解更多关于 [Introspection and Debugging](/docs/tasks/debug-application-cluster/debug-application-introspection/)
|
||||
* 了解更多关于 [Jobs](/docs/concepts/workloads/controllers/jobs-run-to-completion/)
|
||||
* 了解更多关于 [Port Forwarding](/docs/tasks/access-application-cluster/port-forward-access-application-cluster/)
|
||||
* 了解如何 [Get a Shell to a Container](/docs/tasks/debug-application-cluster/get-shell-running-container/)
|
||||
* 了解更多关于 [Introspection and Debugging](zh/docs/tasks/debug-application-cluster/debug-application-introspection/)
|
||||
* 了解更多关于 [Jobs](zh/docs/concepts/workloads/controllers/jobs-run-to-completion/)
|
||||
* 了解更多关于 [Port Forwarding](zh/docs/tasks/access-application-cluster/port-forward-access-application-cluster/)
|
||||
* 了解如何 [Get a Shell to a Container](zh/docs/tasks/debug-application-cluster/get-shell-running-container/)
|
||||
|
||||
{{% /capture %}}
|
||||
|
||||
@@ -14,23 +14,23 @@ content_template: templates/tutorial
|
||||
|
||||
{{% capture overview %}}
|
||||
|
||||
本教程展示了在 Kubernetes 上使用 [PodDisruptionBudgets](/docs/admin/disruptions/#specifying-a-poddisruptionbudget) 和 [PodAntiAffinity](/docs/user-guide/node-selection/#inter-pod-affinity-and-anti-affinity-beta-feature) 特性运行 [Apache Zookeeper](https://zookeeper.apache.org)。
|
||||
本教程展示了在 Kubernetes 上使用 [PodDisruptionBudgets](zh/docs/admin/disruptions/#specifying-a-poddisruptionbudget) 和 [PodAntiAffinity](zh/docs/user-guide/node-selection/#inter-pod-affinity-and-anti-affinity-beta-feature) 特性运行 [Apache Zookeeper](https://zookeeper.apache.org)。
|
||||
{{% /capture %}}
|
||||
|
||||
{{% capture prerequisites %}}
|
||||
|
||||
在开始本教程前,你应该熟悉以下 Kubernetes 概念。
|
||||
|
||||
* [Pods](/docs/user-guide/pods/single-container/)
|
||||
* [Cluster DNS](/docs/concepts/services-networking/dns-pod-service/)
|
||||
* [Headless Services](/docs/concepts/services-networking/service/#headless-services)
|
||||
* [PersistentVolumes](/docs/concepts/storage/volumes/)
|
||||
* [Pods](zh/docs/user-guide/pods/single-container/)
|
||||
* [Cluster DNS](zh/docs/concepts/services-networking/dns-pod-service/)
|
||||
* [Headless Services](zh/docs/concepts/services-networking/service/#headless-services)
|
||||
* [PersistentVolumes](zh/docs/concepts/storage/volumes/)
|
||||
* [PersistentVolume Provisioning](http://releases.k8s.io/{{< param "githubbranch" >}}/examples/persistent-volume-provisioning/)
|
||||
* [ConfigMaps](/docs/tasks/configure-pod-container/configure-pod-configmap/)
|
||||
* [StatefulSets](/docs/concepts/abstractions/controllers/statefulsets/)
|
||||
* [PodDisruptionBudgets](/docs/admin/disruptions/#specifying-a-poddisruptionbudget)
|
||||
* [PodAntiAffinity](/docs/user-guide/node-selection/#inter-pod-affinity-and-anti-affinity-beta-feature)
|
||||
* [kubectl CLI](/docs/user-guide/kubectl)
|
||||
* [ConfigMaps](zh/docs/tasks/configure-pod-container/configure-pod-configmap/)
|
||||
* [StatefulSets](zh/docs/concepts/abstractions/controllers/statefulsets/)
|
||||
* [PodDisruptionBudgets](zh/docs/admin/disruptions/#specifying-a-poddisruptionbudget)
|
||||
* [PodAntiAffinity](zh/docs/user-guide/node-selection/#inter-pod-affinity-and-anti-affinity-beta-feature)
|
||||
* [kubectl CLI](zh/docs/user-guide/kubectl)
|
||||
|
||||
|
||||
|
||||
@@ -69,14 +69,14 @@ ZooKeeper 在内存中保存它们的整个状态机,但是每个改变都被
|
||||
|
||||
|
||||
下面的清单包含一个
|
||||
[Headless Service](/docs/concepts/services-networking/service/#headless-services),
|
||||
一个 [Service](/docs/concepts/services-networking/service/),
|
||||
一个 [PodDisruptionBudget](/docs/concepts/workloads/pods/disruptions//#specifying-a-poddisruptionbudget),
|
||||
和一个 [StatefulSet](/docs/concepts/workloads/controllers/statefulset/)。
|
||||
[Headless Service](zh/docs/concepts/services-networking/service/#headless-services),
|
||||
一个 [Service](zh/docs/concepts/services-networking/service/),
|
||||
一个 [PodDisruptionBudget](zh/docs/concepts/workloads/pods/disruptions//#specifying-a-poddisruptionbudget),
|
||||
和一个 [StatefulSet](zh/docs/concepts/workloads/controllers/statefulset/)。
|
||||
|
||||
{{< codenew file="application/zookeeper/zookeeper.yaml" >}}
|
||||
|
||||
打开一个命令行终端,使用 [`kubectl apply`](/docs/reference/generated/kubectl/kubectl-commands/#apply)
|
||||
打开一个命令行终端,使用 [`kubectl apply`](zh/docs/reference/generated/kubectl/kubectl-commands/#apply)
|
||||
创建这个清单。
|
||||
|
||||
```shell
|
||||
@@ -92,7 +92,7 @@ poddisruptionbudget.policy/zk-pdb created
|
||||
statefulset.apps/zk created
|
||||
```
|
||||
|
||||
使用 [`kubectl get`](/docs/user-guide/kubectl/{{< param "version" >}}/#get) 查看 StatefulSet 控制器创建的 Pods。
|
||||
使用 [`kubectl get`](zh/docs/user-guide/kubectl/{{< param "version" >}}/#get) 查看 StatefulSet 控制器创建的 Pods。
|
||||
|
||||
```shell
|
||||
kubectl get pods -w -l app=zk
|
||||
@@ -130,7 +130,7 @@ StatefulSet 控制器创建了3个 Pods,每个 Pod 包含一个 [ZooKeeper 3.4
|
||||
由于在匿名网络中没有用于选举 leader 的终止算法,Zab 要求显式的进行成员关系配置,以执行 leader 选举。Ensemble 中的每个服务都需要具有一个独一无二的标识符,所有的服务均需要知道标识符的全集,并且每个标志都需要和一个网络地址相关联。
|
||||
|
||||
|
||||
使用 [`kubectl exec`](/docs/user-guide/kubectl/{{< param "version" >}}/#exec) 获取 `zk` StatefulSet 中 Pods 的主机名。
|
||||
使用 [`kubectl exec`](zh/docs/user-guide/kubectl/{{< param "version" >}}/#exec) 获取 `zk` StatefulSet 中 Pods 的主机名。
|
||||
|
||||
```shell
|
||||
for i in 0 1 2; do kubectl exec zk-$i -- hostname; done
|
||||
@@ -184,7 +184,7 @@ zk-2.zk-headless.default.svc.cluster.local
|
||||
```
|
||||
|
||||
|
||||
[Kubernetes DNS](/docs/concepts/services-networking/dns-pod-service/) 中的 A 记录将 FQDNs 解析成为 Pods 的 IP 地址。如果 Pods 被调度,这个 A 记录将会使用 Pods 的新 IP 地址更新,但 A 记录的名称不会改变。
|
||||
[Kubernetes DNS](zh/docs/concepts/services-networking/dns-pod-service/) 中的 A 记录将 FQDNs 解析成为 Pods 的 IP 地址。如果 Pods 被调度,这个 A 记录将会使用 Pods 的新 IP 地址更新,但 A 记录的名称不会改变。
|
||||
|
||||
|
||||
ZooKeeper 在一个名为 `zoo.cfg` 的文件中保存它的应用配置。使用 `kubectl exec` 在 `zk-0` Pod 中查看 `zoo.cfg` 文件的内容。
|
||||
@@ -320,7 +320,7 @@ numChildren = 0
|
||||
如同在 [ZooKeeper 基础](#zookeeper-basics) 一节所提到的,ZooKeeper 提交所有的条目到一个持久 WAL,并周期性的将内存快照写入存储介质。对于使用一致性协议实现一个复制状态机的应用来说,使用 WALs 提供持久化是一种常用的技术,对于普通的存储应用也是如此。
|
||||
|
||||
|
||||
使用 [`kubectl delete`](/docs/user-guide/kubectl/{{< param "version" >}}/#delete) 删除 `zk` StatefulSet。
|
||||
使用 [`kubectl delete`](zh/docs/user-guide/kubectl/{{< param "version" >}}/#delete) 删除 `zk` StatefulSet。
|
||||
|
||||
```shell
|
||||
kubectl delete statefulset zk
|
||||
@@ -641,7 +641,7 @@ log4j.appender.CONSOLE.layout.ConversionPattern=%d{ISO8601} [myid:%X{myid}] - %-
|
||||
这是在容器里安全记录日志的最简单的方法。由于应用的日志被写入标准输出,Kubernetes 将会为你处理日志轮转。Kubernetes 还实现了一个智能保存策略,保证写入标准输出和标准错误流的应用日志不会耗尽本地存储媒介。
|
||||
|
||||
|
||||
使用 [`kubectl logs`](/docs/user-guide/kubectl/{{< param "version" >}}/#logs) 从一个 Pod 中取回最后几行日志。
|
||||
使用 [`kubectl logs`](zh/docs/user-guide/kubectl/{{< param "version" >}}/#logs) 从一个 Pod 中取回最后几行日志。
|
||||
|
||||
```shell
|
||||
kubectl logs zk-0 --tail 20
|
||||
@@ -679,7 +679,7 @@ kubectl logs zk-0 --tail 20
|
||||
### 配置非特权用户
|
||||
|
||||
|
||||
在容器中允许应用以特权用户运行这条最佳实践是值得商讨的。如果你的组织要求应用以非特权用户运行,你可以使用 [SecurityContext](/docs/tasks/configure-pod-container/security-context/) 控制运行容器入口点的用户。
|
||||
在容器中允许应用以特权用户运行这条最佳实践是值得商讨的。如果你的组织要求应用以非特权用户运行,你可以使用 [SecurityContext](zh/docs/tasks/configure-pod-container/security-context/) 控制运行容器入口点的用户。
|
||||
|
||||
|
||||
`zk` StatefulSet 的 Pod 的 `template` 包含了一个 SecurityContext。
|
||||
@@ -736,7 +736,7 @@ drwxr-sr-x 3 zookeeper zookeeper 4096 Dec 5 20:45 /var/lib/zookeeper/data
|
||||
### 处理进程故障
|
||||
|
||||
|
||||
[Restart Policies](/docs/user-guide/pod-states/#restartpolicy) 控制 Kubernetes 如何处理一个 Pod 中容器入口点的进程故障。对于 StatefulSet 中的 Pods 来说,Always 是唯一合适的 RestartPolicy,这也是默认值。你应该**绝不**覆盖 stateful 应用的默认策略。
|
||||
[Restart Policies](zh/docs/user-guide/pod-states/#restartpolicy) 控制 Kubernetes 如何处理一个 Pod 中容器入口点的进程故障。对于 StatefulSet 中的 Pods 来说,Always 是唯一合适的 RestartPolicy,这也是默认值。你应该**绝不**覆盖 stateful 应用的默认策略。
|
||||
|
||||
|
||||
检查 `zk-0` Pod 中运行的 ZooKeeper 服务的进程树。
|
||||
@@ -947,7 +947,7 @@ kubectl get nodes
|
||||
```
|
||||
|
||||
|
||||
使用 [`kubectl cordon`](/docs/user-guide/kubectl/{{< param "version" >}}/#cordon) cordon 你的集群中除4个节点以外的所有节点。
|
||||
使用 [`kubectl cordon`](zh/docs/user-guide/kubectl/{{< param "version" >}}/#cordon) cordon 你的集群中除4个节点以外的所有节点。
|
||||
|
||||
```shell
|
||||
kubectl cordon < node name >
|
||||
@@ -987,7 +987,7 @@ kubernetes-minion-group-i4c4
|
||||
|
||||
```
|
||||
|
||||
使用 [`kubectl drain`](/docs/user-guide/kubectl/{{< param "version" >}}/#drain) 来 cordon 和 drain `zk-0` Pod 调度的节点。
|
||||
使用 [`kubectl drain`](zh/docs/user-guide/kubectl/{{< param "version" >}}/#drain) 来 cordon 和 drain `zk-0` Pod 调度的节点。
|
||||
|
||||
```shell
|
||||
kubectl drain $(kubectl get pod zk-0 --template {{.spec.nodeName}}) --ignore-daemonsets --force --delete-local-data
|
||||
@@ -1102,7 +1102,7 @@ numChildren = 0
|
||||
```
|
||||
|
||||
|
||||
使用 [`kubectl uncordon`](/docs/user-guide/kubectl/{{< param "version" >}}/#uncordon) 来取消对第一个节点的隔离。
|
||||
使用 [`kubectl uncordon`](zh/docs/user-guide/kubectl/{{< param "version" >}}/#uncordon) 来取消对第一个节点的隔离。
|
||||
|
||||
```shell
|
||||
kubectl uncordon kubernetes-minion-group-pb41
|
||||
|
||||
Reference in New Issue
Block a user