[zh-cn]sync kubectl_delete kubectl_wait kubectl_create

Signed-off-by: xin.li <xin.li@daocloud.io>
pull/49192/head
xin.li 2024-12-21 15:31:03 +08:00
parent 3afda0722a
commit 5f959112c7
3 changed files with 69 additions and 39 deletions

View File

@ -46,19 +46,19 @@ kubectl create -f FILENAME
```
-->
```shell
# 使用 pod.json 中的数据创建一个 Pod
kubectl create -f ./pod.json
# 基于传入到标准输入的 JSON 创建一个 Pod
cat pod.json | kubectl create -f -
# 以 JSON 编辑 registry.yaml 中的数据,然后使用已编辑的数据来创建资源
kubectl create -f registry.yaml --edit -o json
# 使用 pod.json 中的数据创建一个 Pod
kubectl create -f ./pod.json
# 基于传入到标准输入的 JSON 创建一个 Pod
cat pod.json | kubectl create -f -
# 以 JSON 编辑 registry.yaml 中的数据,然后使用已编辑的数据来创建资源
kubectl create -f registry.yaml --edit -o json
```
## {{% heading "options" %}}
<table style="width: 100%; table-layout: fixed;">
<table style="width: 100%; table-layout: fixed;">
<colgroup>
<col span="1" style="width: 10px;" />
<col span="1" />
@ -245,12 +245,12 @@ Template string or path to template file to use when -o=go-template, -o=go-templ
<tr>
<td></td><td style="line-height: 130%; word-wrap: break-word;"><p>
<!--
Must be one of: strict (or true), warn, ignore (or false).<br/>&quot;true&quot; or &quot;strict&quot; will use a schema to validate the input and fail the request if invalid. It will perform server side validation if ServerSideFieldValidation is enabled on the api-server, but will fall back to less reliable client-side validation if not.<br/>&quot;warn&quot; will warn about unknown or duplicate fields without blocking the request if server-side field validation is enabled on the API server, and behave as &quot;ignore&quot; otherwise.<br/>&quot;false&quot; or &quot;ignore&quot; will not perform any schema validation, silently dropping any unknown or duplicate fields.
Must be one of: strict (or true), warn, ignore (or false). &quot;true&quot; or &quot;strict&quot; will use a schema to validate the input and fail the request if invalid. It will perform server side validation if ServerSideFieldValidation is enabled on the api-server, but will fall back to less reliable client-side validation if not. &quot;warn&quot; will warn about unknown or duplicate fields without blocking the request if server-side field validation is enabled on the API server, and behave as &quot;ignore&quot; otherwise. &quot;false&quot; or &quot;ignore&quot; will not perform any schema validation, silently dropping any unknown or duplicate fields.
-->
必须是以下选项之一strict或 true、warn、ignore或 false<br/>
必须是以下选项之一strict或 true、warn、ignore或 false
"true" 或 "strict" 将使用模式定义来验证输入,如果无效,则请求失败。
如果在 API 服务器上启用了 ServerSideFieldValidation则执行服务器端验证
但如果未启用,它将回退到可靠性较低的客户端验证。<br/>
但如果未启用,它将回退到可靠性较低的客户端验证。
如果在 API 服务器上启用了服务器端字段验证,"warn" 将警告未知或重复的字段而不阻止请求,
否则操作与 "ignore" 的表现相同。<br/>
"false" 或 "ignore" 将不会执行任何模式定义检查,而是静默删除所有未知或重复的字段。
@ -274,7 +274,7 @@ Only relevant if --edit=true. Defaults to the line ending native to your platfor
## {{% heading "parentoptions" %}}
<table style="width: 100%; table-layout: fixed;">
<table style="width: 100%; table-layout: fixed;">
<colgroup>
<col span="1" style="width: 10px;" />
<col span="1" />

View File

@ -63,48 +63,71 @@ kubectl delete ([-f FILENAME] | [-k DIRECTORY] | TYPE [(NAME | -l label | --all)
<!--
```
# Delete a pod using the type and name specified in pod.json
kubectl delete -f ./pod.json
# Delete resources from a directory containing kustomization.yaml - e.g. dir/kustomization.yaml
kubectl delete -k dir
# Delete resources from all files that end with '.json'
kubectl delete -f '*.json'
# Delete a pod based on the type and name in the JSON passed into stdin
cat pod.json | kubectl delete -f -
# Delete pods and services with same names "baz" and "foo"
kubectl delete pod,service baz foo
# Delete pods and services with label name=myLabel
kubectl delete pods,services -l name=myLabel
# Delete a pod with minimal delay
kubectl delete pod foo --now
# Force delete a pod on a dead node
kubectl delete pod foo --force
# Delete all pods
kubectl delete pods --all
# Delete all pods only if the user confirms the deletion
kubectl delete pods --all --interactive
```
-->
```shell
# 使用 pod.json 中指定的类型和名称删除一个 Pod
kubectl delete -f ./pod.json
# 基于包含 kustomization.yaml 的目录(例如 dir/kustomization.yaml中的内容删除资源
kubectl delete -k dir
# 删除所有以 '.json' 结尾的文件中的资源
kubectl delete -f '*.json'
# 基于传递到标准输入的 JSON 中的类型和名称删除一个 Pod
cat pod.json | kubectl delete -f -
# 删除名称为 "baz" 和 "foo" 的 Pod 和 Service
kubectl delete pod,service baz foo
# 删除打了标签 name=myLabel 的 Pod 和 Service
kubectl delete pods,services -l name=myLabel
# 以最小延迟删除一个 Pod
kubectl delete pod foo --now
# 强制删除一个死节点上的 Pod
kubectl delete pod foo --force
# 删除所有 Pod
kubectl delete pods --all
# 仅在用户确认删除的情况下删除所有 Pod
kubectl delete pods --all --interactive
```
## {{% heading "options" %}}
<table style="width: 100%; table-layout: fixed;">
<table style="width: 100%; table-layout: fixed;">
<colgroup>
<col span="1" style="width: 10px;" />
<col span="1" />
@ -353,7 +376,7 @@ If true, wait for resources to be gone before returning. This waits for finalize
## {{% heading "parentoptions" %}}
<table style="width: 100%; table-layout: fixed;">
<table style="width: 100%; table-layout: fixed;">
<colgroup>
<col span="1" style="width: 10px;" />
<col span="1" />

View File

@ -19,7 +19,7 @@ Experimental: Wait for a specific condition on one or many resources.
The command takes multiple resources and waits until the specified condition is seen in the Status field of every given resource.
Alternatively, the command can wait for the given set of resources to be deleted by providing the "delete" keyword as the value to the --for flag.
Alternatively, the command can wait for the given set of resources to be created or deleted by providing the "create" or "delete" keyword as the value to the --for flag.
A successful message will be printed to stdout indicating when the specified condition has been met. You can use -o option to change to output destination.
-->
@ -27,13 +27,12 @@ Experimental: Wait for a specific condition on one or many resources.
- 此命令接受多个资源作为输入,并等待直到在每个给定资源的状态字段中看到所指定的状况。
- 此外,这一命令可以通过提供 "delete" 关键字作为 --for 标志的值来等待给定的一组资源被删除。
- 或者,这一命令可以通过为 `--for` 标志提供 "create" 或 "delete" 关键字值,来等待给定的一组资源被创建或删除。
- 当指定条件被满足时,命令将向 stdout 打印一条成功消息。你可以使用 -o 选项更改输出目标。
```shell
kubectl wait ([-f FILENAME] | resource.group/resource.name | resource.group [(-l label | --all)]) [--for=delete|--for condition=available|--for=jsonpath='{}'[=value]]
kubectl wait ([-f FILENAME] | resource.group/resource.name | resource.group [(-l label | --all)]) [--for=create|--for=delete|--for condition=available|--for=jsonpath='{}'[=value]]
```
## {{% heading "examples" %}}
@ -42,19 +41,23 @@ kubectl wait ([-f FILENAME] | resource.group/resource.name | resource.group [(-l
```
# Wait for the pod "busybox1" to contain the status condition of type "Ready"
kubectl wait --for=condition=Ready pod/busybox1
# The default value of status condition is true; you can wait for other targets after an equal delimiter (compared after Unicode simple case folding, which is a more general form of case-insensitivity)
kubectl wait --for=condition=Ready=false pod/busybox1
# Wait for the pod "busybox1" to contain the status phase to be "Running"
kubectl wait --for=jsonpath='{.status.phase}'=Running pod/busybox1
# Wait for pod "busybox1" to be Ready
kubectl wait --for='jsonpath={.status.conditions[?(@.type=="Ready")].status}=True' pod/busybox1
# Wait for the service "loadbalancer" to have ingress
kubectl wait --for=jsonpath='{.status.loadBalancer.ingress}' service/loadbalancer
# Wait for the secret "busybox1" to be created, with a timeout of 30s
kubectl create secret generic busybox1
kubectl wait --for=create secret/busybox1 --timeout=30s
# Wait for the pod "busybox1" to be deleted, with a timeout of 60s, after having issued the "delete" command
kubectl delete pod/busybox1
kubectl wait --for=delete pod/busybox1 --timeout=60s
@ -63,19 +66,23 @@ kubectl wait ([-f FILENAME] | resource.group/resource.name | resource.group [(-l
```shell
# 等待 Pod "busybox1" 包含 "Ready" 类型的状况值
kubectl wait --for=condition=Ready pod/busybox1
# 状态状况的默认值为真;可以在等号分隔符后给出其他等待目标(用 Unicode 大小写折叠形式转换之后执行比较,这是更通用的大小写不敏感形式)
kubectl wait --for=condition=Ready=false pod/busybox1
# 等待 Pod "busybox1" 的状态阶段包含 "Running"
kubectl wait --for=jsonpath='{.status.phase}'=Running pod/busybox1
# 等待 Pod "busybox1" 状况变为 Ready
kubectl wait --for='jsonpath={.status.conditions[?(@.type=="Ready")].status}=True' pod/busybox1
# 等待 Service "loadbalancer" 具备入站规则
kubectl wait --for=jsonpath='{.status.loadBalancer.ingress}' service/loadbalancer
# 等待名为 "busybox1" 的 Secret 被创建,超时时间为 30 秒
kubectl create secret generic busybox1
kubectl wait --for=create secret/busybox1 --timeout=30s
# 发出 "delete" 命令后,等待 Pod "busybox1" 被删除,超时时间为 60 秒
kubectl delete pod/busybox1
kubectl wait --for=delete pod/busybox1 --timeout=60s
@ -160,9 +167,9 @@ identifying the resource.
<td></td><td style="line-height: 130%; word-wrap: break-word;">
<p>
<!--
The condition to wait on: [delete|condition=condition-name[=condition-value]|jsonpath='{JSONPath expression}'=[JSONPath value]]. The default condition-value is true. Condition values are compared after Unicode simple case folding, which is a more general form of case-insensitivity.
The condition to wait on: [create|delete|condition=condition-name[=condition-value]|jsonpath='{JSONPath expression}'=[JSONPath value]]. The default condition-value is true. Condition values are compared after Unicode simple case folding, which is a more general form of case-insensitivity.
-->
等待的条件:[delete|condition=condition-name[=condition-value]|jsonpath='{JSONPath expression}'=[JSONPath value]]。
等待的条件:[create|delete|condition=condition-name[=condition-value]|jsonpath='{JSONPath expression}'=[JSONPath value]]。
默认的状况值为 true。在执行 Unicode 大小写折叠之后比较条件值,这是更通用的不区分大小写形式。
</p></td>
</tr>
@ -263,7 +270,7 @@ Template string or path to template file to use when -o=go-template, -o=go-templ
<td></td><td style="line-height: 130%; word-wrap: break-word;">
<p>
<!--
The length of time to wait before giving up. Zero means check once and don't wait, negative means wait for a week.
The length of time to wait before giving up. Zero means check once and don't wait, negative means wait for a week.
-->
放弃前等待的时间长度。0 表示检查一次,不等待,负数表示等待一周。
</p></td>