@@ -24,7 +24,7 @@ See also: [Kubectl Overview](/docs/reference/kubectl/overview/) and [JsonPath Gu
24
24
25
25
This page is an overview of the `kubectl` command.
26
26
-->
27
- 另见: [ Kubectl 概述] ( /docs/reference/kubectl/overview/ ) 和 [ JsonPath 指南] ( /docs/reference/kubectl/jsonpath ) 。
27
+ 另见: [ Kubectl 概述] ( /zh/ docs/reference/kubectl/overview/ ) 和 [ JsonPath 指南] ( /zh /docs/reference/kubectl/jsonpath) 。
28
28
29
29
本页面是 ` kubectl ` 命令的概述。
30
30
@@ -85,15 +85,15 @@ detailed config file information.
85
85
## Kubectl 上下文和配置
86
86
87
87
设置 ` kubectl ` 与哪个 Kubernetes 集群进行通信并修改配置信息。查看
88
- [ 使用 kubeconfig 跨集群授权访问] ( /docs/tasks/access-application-cluster/configure-access-multiple-clusters/ )
88
+ [ 使用 kubeconfig 跨集群授权访问] ( /zh/ docs/tasks/access-application-cluster/configure-access-multiple-clusters/ )
89
89
文档获取配置文件详细信息。
90
90
91
- <!--
91
+ <!--
92
92
``bash
93
93
kubectl config view # Show Merged kubeconfig settings.
94
94
95
95
# use multiple kubeconfig files at the same time and view merged config
96
- KUBECONFIG=~/.kube/config:~/.kube/kubconfig2
96
+ KUBECONFIG=~/.kube/config:~/.kube/kubconfig2
97
97
98
98
kubectl config view
99
99
@@ -102,7 +102,7 @@ kubectl config view -o jsonpath='{.users[?(@.name == "e2e")].user.password}'
102
102
103
103
kubectl config view -o jsonpath='{.users[].name}' # display the first user
104
104
kubectl config view -o jsonpath='{.users[*].name}' # get a list of users
105
- kubectl config get-contexts # display list of contexts
105
+ kubectl config get-contexts # display list of contexts
106
106
kubectl config current-context # display the current-context
107
107
kubectl config use-context my-cluster-name # set the default context to my-cluster-name
108
108
@@ -115,7 +115,7 @@ kubectl config set-context --current --namespace=ggckad-s2
115
115
# set a context utilizing a specific username and namespace.
116
116
kubectl config set-context gce --user=cluster-admin --namespace=foo \
117
117
&& kubectl config use-context gce
118
-
118
+
119
119
kubectl config unset users.foo # delete user foo
120
120
```
121
121
-->
@@ -402,7 +402,7 @@ kubectl diff -f ./my-manifest.yaml
402
402
<!--
403
403
```bash
404
404
kubectl set image deployment/frontend www=image:v2 # Rolling update "www" containers of "frontend" deployment, updating the image
405
- kubectl rollout history deployment/frontend # Check the history of deployments including the revision
405
+ kubectl rollout history deployment/frontend # Check the history of deployments including the revision
406
406
kubectl rollout undo deployment/frontend # Rollback to the previous deployment
407
407
kubectl rollout undo deployment/frontend --to-revision=2 # Rollback to a specific revision
408
408
kubectl rollout status -w deployment/frontend # Watch rolling update status of "frontend" deployment until completion
@@ -426,7 +426,7 @@ kubectl autoscale deployment foo --min=2 --max=10 # Auto scale a
426
426
-->
427
427
``` bash
428
428
kubectl set image deployment/frontend www=image:v2 # 滚动更新 "frontend" Deployment 的 "www" 容器镜像
429
- kubectl rollout history deployment/frontend # 检查 Deployment 的历史记录,包括版本
429
+ kubectl rollout history deployment/frontend # 检查 Deployment 的历史记录,包括版本
430
430
kubectl rollout undo deployment/frontend # 回滚到上次部署版本
431
431
kubectl rollout undo deployment/frontend --to-revision=2 # 回滚到特定部署版本
432
432
kubectl rollout status -w deployment/frontend # 监视 "frontend" Deployment 的滚动升级状态直到完成
@@ -465,13 +465,13 @@ kubectl patch pod valid-pod --type='json' -p='[{"op": "replace", "path": "/spec/
465
465
# Disable a deployment livenessProbe using a json patch with positional arrays
466
466
kubectl patch deployment valid-deployment --type json -p='[{"op": "remove", "path": "/spec/template/spec/containers/0/livenessProbe"}]'
467
467
468
- # Add a new element to a positional array
468
+ # Add a new element to a positional array
469
469
kubectl patch sa default --type='json' -p='[{"op": "add", "path": "/secrets/1", "value": {"name": "whatever" } }]'
470
470
```
471
471
-->
472
472
``` bash
473
473
# 部分更新某节点
474
- kubectl patch node k8s-node-1 -p ' {"spec":{"unschedulable":true}}'
474
+ kubectl patch node k8s-node-1 -p ' {"spec":{"unschedulable":true}}'
475
475
476
476
# 更新容器的镜像;spec.containers[*].name 是必须的。因为它是一个合并性质的主键。
477
477
kubectl patch pod valid-pod -p ' {"spec":{"containers":[{"name":"kubernetes-serve-hostname","image":"new image"}]}}'
@@ -482,7 +482,7 @@ kubectl patch pod valid-pod --type='json' -p='[{"op": "replace", "path": "/spec/
482
482
# 使用带位置数组的 JSON patch 禁用某 Deployment 的 livenessProbe
483
483
kubectl patch deployment valid-deployment --type json -p=' [{"op": "remove", "path": "/spec/template/spec/containers/0/livenessProbe"}]'
484
484
485
- # 在带位置数组中添加元素
485
+ # 在带位置数组中添加元素
486
486
kubectl patch sa default --type=' json' -p=' [{"op": "add", "path": "/secrets/1", "value": {"name": "whatever" } }]'
487
487
```
488
488
@@ -567,7 +567,7 @@ kubectl logs -f my-pod # stream pod logs (stdout)
567
567
kubectl logs -f my-pod -c my-container # stream pod container logs (stdout, multi-container case)
568
568
kubectl logs -f -l name=myLabel --all-containers # stream all pods logs with label name=myLabel (stdout)
569
569
kubectl run -i --tty busybox --image=busybox -- sh # Run pod as interactive shell
570
- kubectl run nginx --image=nginx -n
570
+ kubectl run nginx --image=nginx -n
571
571
mynamespace # Run pod nginx in a specific namespace
572
572
kubectl run nginx --image=nginx # Run pod nginx and write its spec into a file called pod.yaml
573
573
--dry-run=client -o yaml > pod.yaml
@@ -641,7 +641,7 @@ kubectl taint nodes foo dedicated=special-user:NoSchedule
641
641
<!--
642
642
List all supported resource types along with their shortnames, [API group](/docs/concepts/overview/kubernetes-api/#api-groups), whether they are [namespaced](/docs/concepts/overview/working-with-objects/namespaces), and [Kind](/docs/concepts/overview/working-with-objects/kubernetes-objects):
643
643
-->
644
- 列出所支持的全部资源类型和它们的简称、[ API 组] ( /docs/concepts/overview/kubernetes-api/#api-groups ) , 是否是[ 名字空间作用域] ( /docs/concepts/overview/working-with-objects/namespaces ) 和 [ Kind] ( /docs/concepts/overview/working-with-objects/kubernetes-objects ) 。
644
+ 列出所支持的全部资源类型和它们的简称、[ API 组] ( /zh/ docs/concepts/overview/kubernetes-api/#api-groups ) , 是否是[ 名字空间作用域] ( /zh/ docs/concepts/overview/working-with-objects/namespaces ) 和 [ Kind] ( /zh /docs/concepts/overview/working-with-objects/kubernetes-objects) 。
645
645
646
646
``` bash
647
647
kubectl api-resources
@@ -697,8 +697,8 @@ utput format | Description
697
697
` -o=custom-columns=<spec> ` | 使用逗号分隔的自定义列来打印表格
698
698
` -o=custom-columns-file=<filename> ` | 使用 ` <filename> ` 文件中的自定义列模板打印表格
699
699
` -o=json ` | 输出 JSON 格式的 API 对象
700
- ` -o=jsonpath=<template> ` | 打印 [ jsonpath] ( /docs/reference/kubectl/jsonpath ) 表达式中定义的字段
701
- ` -o=jsonpath-file=<filename> ` | 打印在 ` <filename> ` 文件中定义的 [ jsonpath] ( /docs/reference/kubectl/jsonpath ) 表达式所指定的字段。
700
+ ` -o=jsonpath=<template> ` | 打印 [ jsonpath] ( /zh/ docs/reference/kubectl/jsonpath ) 表达式中定义的字段
701
+ ` -o=jsonpath-file=<filename> ` | 打印在 ` <filename> ` 文件中定义的 [ jsonpath] ( /zh/ docs/reference/kubectl/jsonpath ) 表达式所指定的字段。
702
702
` -o=name ` | 仅打印资源名称而不打印其他内容
703
703
` -o=wide ` | 以纯文本格式输出额外信息,对于 Pod 来说,输出中包含了节点名称
704
704
` -o=yaml ` | 输出 YAML 格式的 API 对象
@@ -732,7 +732,7 @@ kubectl get pods -A -o=custom-columns='DATA:spec.containers[?(@.image!="k8s.gcr.
732
732
kubectl get pods -A -o=custom-columns=' DATA:metadata.*'
733
733
```
734
734
735
- 有关更多示例,请参看 kubectl [ 参考文档] ( /docs/reference/kubectl/overview/#custom-columns ) 。
735
+ 有关更多示例,请参看 kubectl [ 参考文档] ( /zh/ docs/reference/kubectl/overview/#custom-columns ) 。
736
736
737
737
<!--
738
738
### Kubectl output verbosity and debugging
@@ -778,8 +778,7 @@ Verbosity | Description
778
778
* Also [kubectl Usage Conventions](/docs/reference/kubectl/conventions/) to understand how to use it in reusable scripts.
779
779
* See more community [kubectl cheatsheets](https://github.com/dennyzhang/cheatsheet-kubernetes-A4).
780
780
-->
781
- * 进一步了解 [ kubectl 概述] ( /docs/reference/kubectl/overview/ ) 。
782
- * 参阅 [ kubectl] ( /docs/reference/kubectl/kubectl/ ) 选项.
783
- * 参阅 [ kubectl 使用约定] ( /docs/reference/kubectl/conventions/ ) 来理解如何在可复用的脚本中使用它。
781
+ * 进一步了解 [ kubectl 概述] ( /zh/ docs/reference/kubectl/overview/ ) 。
782
+ * 参阅 [ kubectl] ( /zh/ docs/reference/kubectl/kubectl/ ) 选项.
783
+ * 参阅 [ kubectl 使用约定] ( /zh/ docs/reference/kubectl/conventions/ ) 来理解如何在可复用的脚本中使用它。
784
784
* 查看社区中其他的 [ kubectl 备忘单] ( https://github.com/dennyzhang/cheatsheet-kubernetes-A4 ) 。
785
-
0 commit comments