@@ -19,28 +19,29 @@ Cassandra, a database, needs persistent storage to provide data durability (appl
19
19
In this example, a custom Cassandra seed provider lets the database discover new Cassandra instances as they join the Cassandra cluster.
20
20
-->
21
21
本教程描述拉如何在 Kubernetes 上运行 [ Apache Cassandra] ( https://cassandra.apache.org/ ) 。
22
- 数据库 Cassandra 需要永久性存储提供数据持久性(应用 _ 状态_ )。
23
- 在此示例中,自定义 Cassandra seed provider 使数据库在加入 Cassandra 集群时发现新的 Cassandra 实例。
22
+ 数据库 Cassandra 需要永久性存储提供数据持久性(应用“状态”)。
23
+ 在此示例中,自定义 Cassandra seed provider 使数据库在加入 Cassandra
24
+ 集群时发现新的 Cassandra 实例。
24
25
25
26
<!--
26
27
*StatefulSets* make it easier to deploy stateful applications into your Kubernetes cluster.
27
28
For more information on the features used in this tutorial, see
28
29
[StatefulSet](/docs/concepts/workloads/controllers/statefulset/).
29
30
-->
30
- 使用 * StatefulSets* 可以更轻松地将有状态的应用程序部署到你的 Kubernetes 集群中。
31
+ 使用" StatefulSets" 可以更轻松地将有状态的应用程序部署到你的 Kubernetes 集群中。
31
32
有关本教程中使用的功能的更多信息,
32
33
参阅 [ StatefulSet] ( /zh/docs/concepts/workloads/controllers/statefulset/ ) 。
33
34
35
+ {{< note >}}
34
36
<!--
35
37
Cassandra and Kubernetes both use the term _node_ to mean a member of a cluster. In this
36
38
tutorial, the Pods that belong to the StatefulSet are Cassandra nodes and are members
37
39
of the Cassandra cluster (called a _ring_). When those Pods run in your Kubernetes cluster,
38
40
the Kubernetes control plane schedules those Pods onto Kubernetes
39
41
{{< glossary_tooltip text="Nodes" term_id="node" >}}.
40
42
-->
41
- {{< note >}}
42
- Cassandra 和 Kubernetes 都使用术语 _ node_ 来表示集群的成员。
43
- 在本教程中,属于 StatefulSet 的 Pod 是 Cassandra 节点,并且是 Cassandra 集群的成员(称为 _ ring_ )。
43
+ Cassandra 和 Kubernetes 都使用术语“节点(node)”来表示集群的成员。
44
+ 在本教程中,属于 StatefulSet 的 Pod 是 Cassandra 节点,并且是 Cassandra 集群的成员(称为 “ring”)。
44
45
当这些 Pod 在你的 Kubernetes 集群中运行时,Kubernetes 控制平面会将这些 Pod 调度到 Kubernetes 的
45
46
{{< glossary_tooltip text="节点" term_id="node" >}}上。
46
47
@@ -51,7 +52,8 @@ This tutorial deploys a custom Cassandra seed provider that lets the database di
51
52
new Cassandra Pods as they appear inside your Kubernetes cluster.
52
53
-->
53
54
当 Cassandra 节点启动时,使用 _ seed列表_ 来引导发现 ring 中其他节点。
54
- 本教程部署了一个自定义的 Cassandra seed provider,使数据库可以发现新的 Cassandra Pod 出现在 Kubernetes 集群中。
55
+ 本教程部署了一个自定义的 Cassandra seed provider,使数据库可以发现新的 Cassandra Pod
56
+ 出现在 Kubernetes 集群中。
55
57
{{< /note >}}
56
58
57
59
## {{% heading "objectives" %}}
@@ -69,7 +71,6 @@ new Cassandra Pods as they appear inside your Kubernetes cluster.
69
71
* 修改 StatefulSet。
70
72
* 删除 StatefulSet 及其 {{< glossary_tooltip text="Pod" term_id="pod" >}}.
71
73
72
-
73
74
## {{% heading "prerequisites" %}}
74
75
75
76
{{< include "task-tutorial-prereqs.md" >}}
@@ -81,7 +82,8 @@ To complete this tutorial, you should already have a basic familiarity with
81
82
{{< glossary_tooltip text="StatefulSets" term_id="StatefulSet" >}}.
82
83
-->
83
84
要完成本教程,你应该已经熟悉 {{< glossary_tooltip text="Pod" term_id="pod" >}},
84
- {{< glossary_tooltip text="Service" term_id="service" >}}和 {{< glossary_tooltip text="StatefulSet" term_id="StatefulSet" >}}。
85
+ {{< glossary_tooltip text="Service" term_id="service" >}} 和
86
+ {{< glossary_tooltip text="StatefulSet" term_id="StatefulSet" >}}。
85
87
86
88
<!--
87
89
### Additional Minikube setup instructions
@@ -158,7 +160,7 @@ If you don't see a Service named `cassandra`, that means creation failed. Read
158
160
for help troubleshooting common issues.
159
161
-->
160
162
如果没有看到名为 ` cassandra ` 的服务,则表示创建失败。
161
- 请阅读[ Debug Services ] ( /zh/docs/tasks/debug-application-cluster/debug-service/ ) ,以解决常见问题。
163
+ 请阅读[ 调试服务 ] ( /zh/docs/tasks/debug-application-cluster/debug-service/ ) ,以解决常见问题。
162
164
163
165
<!--
164
166
## Using a StatefulSet to create a Cassandra ring
@@ -212,83 +214,85 @@ kubectl apply -f cassandra-statefulset.yaml
212
214
-->
213
215
## 验证 Cassandra StatefulSet
214
216
215
- 1.获取 Cassandra StatefulSet:
217
+ 1 . 获取 Cassandra StatefulSet:
216
218
217
- ```shell
218
- kubectl get statefulset cassandra
219
- ```
219
+ ``` shell
220
+ kubectl get statefulset cassandra
221
+ ```
220
222
221
- <!--
223
+ <!--
222
224
The response should be similar to:
223
- -->
225
+ -->
224
226
响应应该与此类似:
225
227
226
- ```
227
- NAME DESIRED CURRENT AGE
228
- cassandra 3 0 13s
229
- ```
228
+ ```
229
+ NAME DESIRED CURRENT AGE
230
+ cassandra 3 0 13s
231
+ ```
230
232
231
- <!--
233
+ <!--
232
234
The `StatefulSet` resource deploys Pods sequentially.
235
+ -->
236
+ ` StatefulSet ` 资源会按顺序部署 Pod。
233
237
238
+ <!--
234
239
1. Get the Pods to see the ordered creation status:
235
240
-->
236
- ` StatefulSet ` 资源会按顺序部署 Pod。
237
-
238
- 2.获取 Pod 查看已排序的创建状态:
241
+ 2 . 获取 Pod 查看已排序的创建状态:
239
242
240
- ```shell
241
- kubectl get pods -l="app=cassandra"
242
- ```
243
+ ``` shell
244
+ kubectl get pods -l=" app=cassandra"
245
+ ```
243
246
244
- <!--
247
+ <!--
245
248
The response should be similar to:
246
- -->
249
+ -->
247
250
响应应该与此类似:
248
251
249
- ```shell
250
- NAME READY STATUS RESTARTS AGE
251
- cassandra-0 1/1 Running 0 1m
252
- cassandra-1 0/1 ContainerCreating 0 8s
253
- ```
252
+ ```
253
+ NAME READY STATUS RESTARTS AGE
254
+ cassandra-0 1/1 Running 0 1m
255
+ cassandra-1 0/1 ContainerCreating 0 8s
256
+ ```
254
257
255
- <!--
258
+ <!--
256
259
It can take several minutes for all three Pods to deploy. Once they are deployed, the same command
257
260
returns output similar to:
258
- -->
261
+ -->
259
262
这三个 Pod 要花几分钟的时间才能部署。部署之后,相同的命令将返回类似于以下的输出:
260
263
261
- ```
262
- NAME READY STATUS RESTARTS AGE
263
- cassandra-0 1/1 Running 0 10m
264
- cassandra-1 1/1 Running 0 9m
265
- cassandra-2 1/1 Running 0 8m
266
- ```
264
+ ```
265
+ NAME READY STATUS RESTARTS AGE
266
+ cassandra-0 1/1 Running 0 10m
267
+ cassandra-1 1/1 Running 0 9m
268
+ cassandra-2 1/1 Running 0 8m
269
+ ```
267
270
<!--
268
271
3. Run the Cassandra [nodetool](https://cwiki.apache.org/confluence/display/CASSANDRA2/NodeTool) inside the first Pod, to
269
272
display the status of the ring.
270
273
-->
271
- 3.运行第一个 Pod 中的 Cassandra [ nodetool] ( https://cwiki.apache.org/confluence/display/CASSANDRA2/NodeTool ) ,以显示 ring 的状态。
274
+ 3 . 运行第一个 Pod 中的 Cassandra [ nodetool] ( https://cwiki.apache.org/confluence/display/CASSANDRA2/NodeTool ) ,
275
+ 以显示 ring 的状态。
272
276
273
- ```shell
274
- kubectl exec -it cassandra-0 -- nodetool status
275
- ```
277
+ ``` shell
278
+ kubectl exec -it cassandra-0 -- nodetool status
279
+ ```
276
280
277
- <!--
281
+ <!--
278
282
The response should be similar to:
279
- -->
283
+ -->
280
284
响应应该与此类似:
281
285
282
- ```
283
- Datacenter: DC1-K8Demo
284
- ======================
285
- Status=Up/Down
286
- |/ State=Normal/Leaving/Joining/Moving
287
- -- Address Load Tokens Owns (effective) Host ID Rack
288
- UN 172.17.0.5 83.57 KiB 32 74.0% e2dd09e6-d9d3-477e-96c5-45094c08db0f Rack1-K8Demo
289
- UN 172.17.0.4 101.04 KiB 32 58.8% f89d6835-3a42-4419-92b3-0e62cae1479c Rack1-K8Demo
290
- UN 172.17.0.6 84.74 KiB 32 67.1% a6a1e8c2-3dc5-4417-b1a0-26507af2aaad Rack1-K8Demo
291
- ```
286
+ ```
287
+ Datacenter: DC1-K8Demo
288
+ ======================
289
+ Status=Up/Down
290
+ |/ State=Normal/Leaving/Joining/Moving
291
+ -- Address Load Tokens Owns (effective) Host ID Rack
292
+ UN 172.17.0.5 83.57 KiB 32 74.0% e2dd09e6-d9d3-477e-96c5-45094c08db0f Rack1-K8Demo
293
+ UN 172.17.0.4 101.04 KiB 32 58.8% f89d6835-3a42-4419-92b3-0e62cae1479c Rack1-K8Demo
294
+ UN 172.17.0.6 84.74 KiB 32 67.1% a6a1e8c2-3dc5-4417-b1a0-26507af2aaad Rack1-K8Demo
295
+ ```
292
296
293
297
<!--
294
298
## Modifying the Cassandra StatefulSet
@@ -301,16 +305,16 @@ Use `kubectl edit` to modify the size of a Cassandra StatefulSet.
301
305
302
306
使用 ` kubectl edit ` 修改 Cassandra StatefulSet 的大小。
303
307
304
- 1.运行以下命令:
308
+ 1 . 运行以下命令:
305
309
306
- ```shell
307
- kubectl edit statefulset cassandra
308
- ```
310
+ ``` shell
311
+ kubectl edit statefulset cassandra
312
+ ```
309
313
310
- <!--
314
+ <!--
311
315
This command opens an editor in your terminal. The line you need to change is the `replicas` field.
312
316
The following sample is an excerpt of the StatefulSet file:
313
- -->
317
+ -->
314
318
此命令你的终端中打开一个编辑器。需要更改的是 ` replicas ` 字段。下面是 StatefulSet 文件的片段示例:
315
319
316
320
``` yaml
@@ -340,65 +344,65 @@ Use `kubectl edit` to modify the size of a Cassandra StatefulSet.
340
344
341
345
1. Get the Cassandra StatefulSet to verify your change:
342
346
-->
343
- 2.将副本数 ( replicas) 更改为 4,然后保存清单。
347
+ 2. 将副本数( replicas) 更改为 4,然后保存清单。
344
348
345
349
StatefulSet 现在可以扩展到运行 4 个 Pod。
346
350
347
- 3.获取 Cassandra StatefulSet 验证更改:
351
+ 3. 获取 Cassandra StatefulSet 验证更改:
348
352
349
- ```shell
350
- kubectl get statefulset cassandra
351
- ```
353
+ ` ` ` shell
354
+ kubectl get statefulset cassandra
355
+ ```
352
356
353
- <!--
357
+ <!--
354
358
The response should be similar to:
355
- -->
359
+ -->
356
360
响应应该与此类似:
357
361
358
- ```
359
- NAME DESIRED CURRENT AGE
360
- cassandra 4 4 36m
361
- ```
362
+ ```
363
+ NAME DESIRED CURRENT AGE
364
+ cassandra 4 4 36m
365
+ ```
362
366
363
367
## {{% heading "cleanup" %}}
364
368
365
369
<!--
366
370
Deleting or scaling a StatefulSet down does not delete the volumes associated with the StatefulSet.
367
371
This setting is for your safety because your data is more valuable than automatically purging all related StatefulSet resources.
368
-
369
- {{< warning >}}
370
- Depending on the storage class and reclaim policy, deleting the *PersistentVolumeClaims* may cause the associated volumes
371
- to also be deleted. Never assume you'll be able to access data if its volume claims are deleted.
372
- {{< /warning >}}
373
-
374
- 1. Run the following commands (chained together into a single command) to delete everything in the Cassandra StatefulSet:
375
372
-->
376
373
删除或缩小 StatefulSet 不会删除与 StatefulSet 关联的卷。
377
374
这个设置是出于安全考虑,因为你的数据比自动清除所有相关的 StatefulSet 资源更有价值。
378
375
379
376
{{< warning >}}
377
+ <!--
378
+ Depending on the storage class and reclaim policy, deleting the *PersistentVolumeClaims* may cause the associated volumes
379
+ to also be deleted. Never assume you'll be able to access data if its volume claims are deleted.
380
+ -->
380
381
根据存储类和回收策略,删除 * PersistentVolumeClaims* 可能导致关联的卷也被删除。
381
382
千万不要认为其容量声明被删除,你就能访问数据。
382
383
{{< /warning >}}
383
384
384
- 1.运行以下命令(连在一起成为一个单独的命令)删除 Cassandra StatefulSet 中的所有内容:
385
+ <!--
386
+ 1. Run the following commands (chained together into a single command) to delete everything in the Cassandra StatefulSet:
387
+ -->
388
+ 1 . 运行以下命令(连在一起成为一个单独的命令)删除 Cassandra StatefulSet 中的所有内容:
385
389
386
- ```shell
387
- grace=$(kubectl get pod cassandra-0 -o=jsonpath='{.spec.terminationGracePeriodSeconds}') \
388
- && kubectl delete statefulset -l app=cassandra \
389
- && echo "Sleeping ${grace} seconds" 1>&2 \
390
- && sleep $grace \
391
- && kubectl delete persistentvolumeclaim -l app=cassandra
392
- ```
390
+ ``` shell
391
+ grace=$( kubectl get pod cassandra-0 -o=jsonpath=' {.spec.terminationGracePeriodSeconds}' ) \
392
+ && kubectl delete statefulset -l app=cassandra \
393
+ && echo " Sleeping ${grace} seconds" 1>&2 \
394
+ && sleep $grace \
395
+ && kubectl delete persistentvolumeclaim -l app=cassandra
396
+ ```
393
397
394
398
<!--
395
399
1. Run the following command to delete the Service you set up for Cassandra:
396
400
-->
397
- 2.运行以下命令,删除你为 Cassandra 设置的 Service:
401
+ 2 . 运行以下命令,删除你为 Cassandra 设置的 Service:
398
402
399
- ```shell
400
- kubectl delete service -l app=cassandra
401
- ```
403
+ ``` shell
404
+ kubectl delete service -l app=cassandra
405
+ ```
402
406
403
407
<!--
404
408
## Cassandra container environment variables
@@ -412,21 +416,21 @@ This image includes a standard Cassandra installation from the Apache Debian rep
412
416
By using environment variables you can change values that are inserted into `cassandra.yaml`.
413
417
-->
414
418
## Cassandra 容器环境变量
415
- 本教程中的 Pod 使用来自 Google [ container registry] ( https://cloud.google.com/container-registry/docs/ )
416
- 的 [ ` gcr.io/google-samples/cassandra:v13 ` ] ( https://github.com/kubernetes/examples/blob/master/cassandra/image/Dockerfile ) 镜像。
417
- 上面的 Docker 镜像基于 [ debian-base] ( https://github.com/kubernetes/release/tree/master/images/build/debian-base ) ,并且包含 OpenJDK 8。
419
+
420
+ 本教程中的 Pod 使用来自 Google [ 容器镜像库] ( https://cloud.google.com/container-registry/docs/ )
421
+ 的 [ ` gcr.io/google-samples/cassandra:v13 ` ] ( https://github.com/kubernetes/examples/blob/master/cassandra/image/Dockerfile )
422
+ 镜像。上面的 Docker 镜像基于 [ debian-base] ( https://github.com/kubernetes/release/tree/master/images/build/debian-base ) ,
423
+ 并且包含 OpenJDK 8。
418
424
419
425
该映像包括来自 Apache Debian 存储库的标准 Cassandra 安装。
420
426
通过使用环境变量,您可以更改插入到 ` cassandra.yaml ` 中的值。
421
427
422
- | Environment variable | Default value |
428
+ | 环境变量 | 默认值 |
423
429
| ------------------------ | :---------------: |
424
430
| ` CASSANDRA_CLUSTER_NAME ` | ` 'Test Cluster' ` |
425
431
| ` CASSANDRA_NUM_TOKENS ` | ` 32 ` |
426
432
| ` CASSANDRA_RPC_ADDRESS ` | ` 0.0.0.0 ` |
427
433
428
-
429
-
430
434
## {{% heading "whatsnext" %}}
431
435
432
436
<!--
@@ -437,3 +441,4 @@ By using environment variables you can change values that are inserted into `cas
437
441
* 了解如何[ 扩缩 StatefulSet] ( /docs/tasks/run-application/scale-stateful-set/ ) 。
438
442
* 了解有关 [ * KubernetesSeedProvider* ] ( https://github.com/kubernetes/examples/blob/master/cassandra/java/src/main/java/io/k8s/cassandra/KubernetesSeedProvider.java ) 的更多信息
439
443
* 查看更多自定义 [ Seed Provider Configurations] ( https://git.k8s.io/examples/cassandra/java/README.md )
444
+
0 commit comments