Update cli commands (#15268)

* Update cli commands

* Small fixes

* Update snippet
pull/15414/head
Nikita Potapenko 2019-07-14 06:09:01 +03:00 committed by Kubernetes Prow Robot
parent 62656313f1
commit 4a1203a941
1 changed files with 20 additions and 22 deletions

View File

@ -34,20 +34,18 @@ content_template: templates/task
{{< code file="commands.yaml" >}}
1. 基于YAML文件创建一个Pod
```shell
kubectl create -f https://k8s.io/docs/tasks/inject-data-application/commands.yaml
```
<!--
2. List the running Pods:
-->
获取正在运行的 pod
```shell
kubectl get pods
```
2. List the running Pods:
获取正在运行的 pod
```shell
kubectl get pods
```
查询结果显示在command-demo这个Pod下运行的容器已经启动完成
@ -59,7 +57,7 @@ content_template: templates/task
日志中显示了HOSTNAME 与KUBERNETES_PORT 这两个环境变量的值:
```shell
```
command-demo
tcp://10.3.240.1:443
```
@ -69,13 +67,13 @@ content_template: templates/task
在上面的示例中,我们直接将一串字符作为命令的入参。除此之外,我们还可以
将环境变量作为命令的入参。
```shell
env:
- name: MESSAGE
value: "hello world"
command: ["/bin/echo"]
args: ["$(MESSAGE)"]
```
```yaml
env:
- name: MESSAGE
value: "hello world"
command: ["/bin/echo"]
args: ["$(MESSAGE)"]
```
这样一来,我们就可以将那些用来设置环境变量的方法应用于设置命令的入参,其
中包括了[ConfigMaps](/docs/tasks/configure-pod-container/configure-pod-configmap/)
@ -92,10 +90,10 @@ content_template: templates/task
有时候需要通过shell来执行命令。 例如,命令可能由多个命令组合而成,抑或包含
在一个shell脚本中。这时就可以通过如下方式在shell中执行命令
```shell
command: ["/bin/sh"]
args: ["-c", "while true; do echo hello; sleep 10;done"]
```
```shell
command: ["/bin/sh"]
args: ["-c", "while true; do echo hello; sleep 10;done"]
```
## 注意