fix some layout
parent
104f34049d
commit
f6fa07357d
|
@ -46,33 +46,33 @@ file for the Pod defines a command and two arguments:
|
||||||
|
|
||||||
1. Create a Pod based on the YAML configuration file:
|
1. Create a Pod based on the YAML configuration file:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
kubectl apply -f https://k8s.io/examples/pods/commands.yaml
|
kubectl apply -f https://k8s.io/examples/pods/commands.yaml
|
||||||
```
|
```
|
||||||
|
|
||||||
1. List the running Pods:
|
1. List the running Pods:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
kubectl get pods
|
kubectl get pods
|
||||||
```
|
```
|
||||||
|
|
||||||
The output shows that the container that ran in the command-demo Pod has
|
The output shows that the container that ran in the command-demo Pod has
|
||||||
completed.
|
completed.
|
||||||
|
|
||||||
1. To see the output of the command that ran in the container, view the logs
|
1. To see the output of the command that ran in the container, view the logs
|
||||||
from the Pod:
|
from the Pod:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
kubectl logs command-demo
|
kubectl logs command-demo
|
||||||
```
|
```
|
||||||
|
|
||||||
The output shows the values of the HOSTNAME and KUBERNETES_PORT environment
|
The output shows the values of the HOSTNAME and KUBERNETES_PORT environment
|
||||||
variables:
|
variables:
|
||||||
|
|
||||||
```
|
```
|
||||||
command-demo
|
command-demo
|
||||||
tcp://10.3.240.1:443
|
tcp://10.3.240.1:443
|
||||||
```
|
```
|
||||||
|
|
||||||
## Use environment variables to define arguments
|
## Use environment variables to define arguments
|
||||||
|
|
||||||
|
|
|
@ -30,39 +30,39 @@ Pod:
|
||||||
|
|
||||||
1. Create a Pod based on that manifest:
|
1. Create a Pod based on that manifest:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
kubectl apply -f https://k8s.io/examples/pods/inject/envars.yaml
|
kubectl apply -f https://k8s.io/examples/pods/inject/envars.yaml
|
||||||
```
|
```
|
||||||
|
|
||||||
1. List the running Pods:
|
1. List the running Pods:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
kubectl get pods -l purpose=demonstrate-envars
|
kubectl get pods -l purpose=demonstrate-envars
|
||||||
```
|
```
|
||||||
|
|
||||||
The output is similar to:
|
The output is similar to:
|
||||||
|
|
||||||
```
|
```
|
||||||
NAME READY STATUS RESTARTS AGE
|
NAME READY STATUS RESTARTS AGE
|
||||||
envar-demo 1/1 Running 0 9s
|
envar-demo 1/1 Running 0 9s
|
||||||
```
|
```
|
||||||
|
|
||||||
1. List the Pod's container environment variables:
|
1. List the Pod's container environment variables:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
kubectl exec envar-demo -- printenv
|
kubectl exec envar-demo -- printenv
|
||||||
```
|
```
|
||||||
|
|
||||||
The output is similar to this:
|
The output is similar to this:
|
||||||
|
|
||||||
```
|
```
|
||||||
NODE_VERSION=4.4.2
|
NODE_VERSION=4.4.2
|
||||||
EXAMPLE_SERVICE_PORT_8080_TCP_ADDR=10.3.245.237
|
EXAMPLE_SERVICE_PORT_8080_TCP_ADDR=10.3.245.237
|
||||||
HOSTNAME=envar-demo
|
HOSTNAME=envar-demo
|
||||||
...
|
...
|
||||||
DEMO_GREETING=Hello from the environment
|
DEMO_GREETING=Hello from the environment
|
||||||
DEMO_FAREWELL=Such a sweet sorrow
|
DEMO_FAREWELL=Such a sweet sorrow
|
||||||
```
|
```
|
||||||
|
|
||||||
{{< note >}}
|
{{< note >}}
|
||||||
The environment variables set using the `env` or `envFrom` field
|
The environment variables set using the `env` or `envFrom` field
|
||||||
|
|
|
@ -30,34 +30,34 @@ Pod:
|
||||||
|
|
||||||
1. Create a Pod based on that manifest:
|
1. Create a Pod based on that manifest:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
kubectl apply -f https://k8s.io/examples/pods/inject/dependent-envars.yaml
|
kubectl apply -f https://k8s.io/examples/pods/inject/dependent-envars.yaml
|
||||||
```
|
```
|
||||||
```
|
```
|
||||||
pod/dependent-envars-demo created
|
pod/dependent-envars-demo created
|
||||||
```
|
```
|
||||||
|
|
||||||
2. List the running Pods:
|
2. List the running Pods:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
kubectl get pods dependent-envars-demo
|
kubectl get pods dependent-envars-demo
|
||||||
```
|
```
|
||||||
```
|
```
|
||||||
NAME READY STATUS RESTARTS AGE
|
NAME READY STATUS RESTARTS AGE
|
||||||
dependent-envars-demo 1/1 Running 0 9s
|
dependent-envars-demo 1/1 Running 0 9s
|
||||||
```
|
```
|
||||||
|
|
||||||
3. Check the logs for the container running in your Pod:
|
3. Check the logs for the container running in your Pod:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
kubectl logs pod/dependent-envars-demo
|
kubectl logs pod/dependent-envars-demo
|
||||||
```
|
```
|
||||||
```
|
```
|
||||||
|
|
||||||
UNCHANGED_REFERENCE=$(PROTOCOL)://172.17.0.1:80
|
UNCHANGED_REFERENCE=$(PROTOCOL)://172.17.0.1:80
|
||||||
SERVICE_ADDRESS=https://172.17.0.1:80
|
SERVICE_ADDRESS=https://172.17.0.1:80
|
||||||
ESCAPED_REFERENCE=$(PROTOCOL)://172.17.0.1:80
|
ESCAPED_REFERENCE=$(PROTOCOL)://172.17.0.1:80
|
||||||
```
|
```
|
||||||
|
|
||||||
As shown above, you have defined the correct dependency reference of `SERVICE_ADDRESS`, bad dependency reference of `UNCHANGED_REFERENCE` and skip dependent references of `ESCAPED_REFERENCE`.
|
As shown above, you have defined the correct dependency reference of `SERVICE_ADDRESS`, bad dependency reference of `UNCHANGED_REFERENCE` and skip dependent references of `ESCAPED_REFERENCE`.
|
||||||
|
|
||||||
|
|
|
@ -43,44 +43,44 @@ username and password:
|
||||||
|
|
||||||
1. Create the Secret
|
1. Create the Secret
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
kubectl apply -f https://k8s.io/examples/pods/inject/secret.yaml
|
kubectl apply -f https://k8s.io/examples/pods/inject/secret.yaml
|
||||||
```
|
```
|
||||||
|
|
||||||
1. View information about the Secret:
|
1. View information about the Secret:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
kubectl get secret test-secret
|
kubectl get secret test-secret
|
||||||
```
|
```
|
||||||
|
|
||||||
Output:
|
Output:
|
||||||
|
|
||||||
```
|
```
|
||||||
NAME TYPE DATA AGE
|
NAME TYPE DATA AGE
|
||||||
test-secret Opaque 2 1m
|
test-secret Opaque 2 1m
|
||||||
```
|
```
|
||||||
|
|
||||||
1. View more detailed information about the Secret:
|
1. View more detailed information about the Secret:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
kubectl describe secret test-secret
|
kubectl describe secret test-secret
|
||||||
```
|
```
|
||||||
|
|
||||||
Output:
|
Output:
|
||||||
|
|
||||||
```
|
```
|
||||||
Name: test-secret
|
Name: test-secret
|
||||||
Namespace: default
|
Namespace: default
|
||||||
Labels: <none>
|
Labels: <none>
|
||||||
Annotations: <none>
|
Annotations: <none>
|
||||||
|
|
||||||
Type: Opaque
|
Type: Opaque
|
||||||
|
|
||||||
Data
|
Data
|
||||||
====
|
====
|
||||||
password: 13 bytes
|
password: 13 bytes
|
||||||
username: 7 bytes
|
username: 7 bytes
|
||||||
```
|
```
|
||||||
|
|
||||||
### Create a Secret directly with kubectl
|
### Create a Secret directly with kubectl
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue