Improvements for markdown formatting (#12193)
* Fixed markdown formatting * Resolved usage of 'shell' instead of 'yaml' * Removed unknown 'log' keywordpull/12206/head
parent
10a75e3d72
commit
1bc0d7c385
|
@ -160,11 +160,11 @@ at `/var/run/secrets/kubernetes.io/serviceaccount/namespace` in each container.
|
||||||
|
|
||||||
From within a pod the recommended ways to connect to API are:
|
From within a pod the recommended ways to connect to API are:
|
||||||
|
|
||||||
- run `kubectl proxy` in a sidecar container in the pod, or as a background
|
- Run `kubectl proxy` in a sidecar container in the pod, or as a background
|
||||||
process within the container. This proxies the
|
process within the container. This proxies the
|
||||||
Kubernetes API to the localhost interface of the pod, so that other processes
|
Kubernetes API to the localhost interface of the pod, so that other processes
|
||||||
in any container of the pod can access it.
|
in any container of the pod can access it.
|
||||||
- use the Go client library, and create a client using the `rest.InClusterConfig()` and `kubernetes.NewForConfig()` functions.
|
- Use the Go client library, and create a client using the `rest.InClusterConfig()` and `kubernetes.NewForConfig()` functions.
|
||||||
They handle locating and authenticating to the apiserver. [example](https://git.k8s.io/client-go/examples/in-cluster-client-configuration/main.go)
|
They handle locating and authenticating to the apiserver. [example](https://git.k8s.io/client-go/examples/in-cluster-client-configuration/main.go)
|
||||||
|
|
||||||
In each case, the credentials of the pod are used to communicate securely with the apiserver.
|
In each case, the credentials of the pod are used to communicate securely with the apiserver.
|
||||||
|
|
|
@ -46,11 +46,15 @@ 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:
|
||||||
|
|
||||||
kubectl create -f https://k8s.io/examples/pods/commands.yaml
|
```shell
|
||||||
|
kubectl create -f https://k8s.io/examples/pods/commands.yaml
|
||||||
|
```
|
||||||
|
|
||||||
1. List the running Pods:
|
1. List the running Pods:
|
||||||
|
|
||||||
kubectl get pods
|
```shell
|
||||||
|
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.
|
||||||
|
@ -58,13 +62,17 @@ file for the Pod defines a command and two arguments:
|
||||||
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:
|
||||||
|
|
||||||
kubectl logs command-demo
|
```shell
|
||||||
|
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
|
```
|
||||||
tcp://10.3.240.1:443
|
command-demo
|
||||||
|
tcp://10.3.240.1:443
|
||||||
|
```
|
||||||
|
|
||||||
## Use environment variables to define arguments
|
## Use environment variables to define arguments
|
||||||
|
|
||||||
|
@ -72,11 +80,13 @@ In the preceding example, you defined the arguments directly by
|
||||||
providing strings. As an alternative to providing strings directly,
|
providing strings. As an alternative to providing strings directly,
|
||||||
you can define arguments by using environment variables:
|
you can define arguments by using environment variables:
|
||||||
|
|
||||||
env:
|
```yaml
|
||||||
- name: MESSAGE
|
env:
|
||||||
value: "hello world"
|
- name: MESSAGE
|
||||||
command: ["/bin/echo"]
|
value: "hello world"
|
||||||
args: ["$(MESSAGE)"]
|
command: ["/bin/echo"]
|
||||||
|
args: ["$(MESSAGE)"]
|
||||||
|
```
|
||||||
|
|
||||||
This means you can define an argument for a Pod using any of
|
This means you can define an argument for a Pod using any of
|
||||||
the techniques available for defining environment variables, including
|
the techniques available for defining environment variables, including
|
||||||
|
@ -95,8 +105,10 @@ In some cases, you need your command to run in a shell. For example, your
|
||||||
command might consist of several commands piped together, or it might be a shell
|
command might consist of several commands piped together, or it might be a shell
|
||||||
script. To run your command in a shell, wrap it like this:
|
script. To run your command in a shell, wrap it like this:
|
||||||
|
|
||||||
command: ["/bin/sh"]
|
```shell
|
||||||
args: ["-c", "while true; do echo hello; sleep 10;done"]
|
command: ["/bin/sh"]
|
||||||
|
args: ["-c", "while true; do echo hello; sleep 10;done"]
|
||||||
|
```
|
||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ Pod:
|
||||||
|
|
||||||
The output is similar to this:
|
The output is similar to this:
|
||||||
|
|
||||||
```log
|
```
|
||||||
NAME READY STATUS RESTARTS AGE
|
NAME READY STATUS RESTARTS AGE
|
||||||
envar-demo 1/1 Running 0 9s
|
envar-demo 1/1 Running 0 9s
|
||||||
```
|
```
|
||||||
|
@ -67,7 +67,7 @@ Pod:
|
||||||
|
|
||||||
The output is similar to this:
|
The output is similar to this:
|
||||||
|
|
||||||
```log
|
```
|
||||||
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
|
||||||
|
|
|
@ -24,8 +24,10 @@ Suppose you want to have two pieces of secret data: a username `my-app` and a pa
|
||||||
convert your username and password to a base-64 representation. Here's a Linux
|
convert your username and password to a base-64 representation. Here's a Linux
|
||||||
example:
|
example:
|
||||||
|
|
||||||
echo -n 'my-app' | base64
|
```shell
|
||||||
echo -n '39528$vdg7Jb' | base64
|
echo -n 'my-app' | base64
|
||||||
|
echo -n '39528$vdg7Jb' | base64
|
||||||
|
```
|
||||||
|
|
||||||
The output shows that the base-64 representation of your username is `bXktYXBw`,
|
The output shows that the base-64 representation of your username is `bXktYXBw`,
|
||||||
and the base-64 representation of your password is `Mzk1MjgkdmRnN0pi`.
|
and the base-64 representation of your password is `Mzk1MjgkdmRnN0pi`.
|
||||||
|
@ -45,32 +47,38 @@ username and password:
|
||||||
|
|
||||||
1. View information about the Secret:
|
1. View information about the Secret:
|
||||||
|
|
||||||
kubectl get secret test-secret
|
```shell
|
||||||
|
kubectl get secret test-secret
|
||||||
|
```
|
||||||
|
|
||||||
Output:
|
Output:
|
||||||
|
|
||||||
NAME TYPE DATA AGE
|
```
|
||||||
test-secret Opaque 2 1m
|
NAME TYPE DATA AGE
|
||||||
|
test-secret Opaque 2 1m
|
||||||
|
```
|
||||||
|
|
||||||
1. View more detailed information about the Secret:
|
1. View more detailed information about the Secret:
|
||||||
|
|
||||||
kubectl describe secret test-secret
|
```shell
|
||||||
|
kubectl describe secret test-secret
|
||||||
|
```
|
||||||
|
|
||||||
Output:
|
Output:
|
||||||
|
|
||||||
Name: test-secret
|
```
|
||||||
Namespace: default
|
Name: test-secret
|
||||||
Labels: <none>
|
Namespace: default
|
||||||
Annotations: <none>
|
Labels: <none>
|
||||||
|
Annotations: <none>
|
||||||
|
|
||||||
Type: Opaque
|
Type: Opaque
|
||||||
|
|
||||||
Data
|
|
||||||
====
|
|
||||||
password: 13 bytes
|
|
||||||
username: 7 bytes
|
|
||||||
|
|
||||||
|
Data
|
||||||
|
====
|
||||||
|
password: 13 bytes
|
||||||
|
username: 7 bytes
|
||||||
|
```
|
||||||
|
|
||||||
{{< note >}}
|
{{< note >}}
|
||||||
If you want to skip the Base64 encoding step, you can create a Secret
|
If you want to skip the Base64 encoding step, you can create a Secret
|
||||||
|
|
|
@ -84,7 +84,7 @@ builder="john-doe"
|
||||||
|
|
||||||
Get a shell into the Container that is running in your Pod:
|
Get a shell into the Container that is running in your Pod:
|
||||||
|
|
||||||
```
|
```shell
|
||||||
kubectl exec -it kubernetes-downwardapi-volume-example -- sh
|
kubectl exec -it kubernetes-downwardapi-volume-example -- sh
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -177,7 +177,7 @@ kubectl create -f https://k8s.io/examples/pods/inject/dapi-volume-resources.yaml
|
||||||
|
|
||||||
Get a shell into the Container that is running in your Pod:
|
Get a shell into the Container that is running in your Pod:
|
||||||
|
|
||||||
```
|
```shell
|
||||||
kubectl exec -it kubernetes-downwardapi-volume-example-2 -- sh
|
kubectl exec -it kubernetes-downwardapi-volume-example-2 -- sh
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -60,13 +60,13 @@ kubectl create -f https://k8s.io/examples/pods/inject/dapi-envars-pod.yaml
|
||||||
|
|
||||||
Verify that the Container in the Pod is running:
|
Verify that the Container in the Pod is running:
|
||||||
|
|
||||||
```
|
```shell
|
||||||
kubectl get pods
|
kubectl get pods
|
||||||
```
|
```
|
||||||
|
|
||||||
View the Container's logs:
|
View the Container's logs:
|
||||||
|
|
||||||
```
|
```shell
|
||||||
kubectl logs dapi-envars-fieldref
|
kubectl logs dapi-envars-fieldref
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -86,13 +86,13 @@ five environment variables to stdout. It repeats this every ten seconds.
|
||||||
|
|
||||||
Next, get a shell into the Container that is running in your Pod:
|
Next, get a shell into the Container that is running in your Pod:
|
||||||
|
|
||||||
```
|
```shell
|
||||||
kubectl exec -it dapi-envars-fieldref -- sh
|
kubectl exec -it dapi-envars-fieldref -- sh
|
||||||
```
|
```
|
||||||
|
|
||||||
In your shell, view the environment variables:
|
In your shell, view the environment variables:
|
||||||
|
|
||||||
```
|
```shell
|
||||||
/# printenv
|
/# printenv
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -135,13 +135,13 @@ kubectl create -f https://k8s.io/examples/pods/inject/dapi-envars-container.yaml
|
||||||
|
|
||||||
Verify that the Container in the Pod is running:
|
Verify that the Container in the Pod is running:
|
||||||
|
|
||||||
```
|
```shell
|
||||||
kubectl get pods
|
kubectl get pods
|
||||||
```
|
```
|
||||||
|
|
||||||
View the Container's logs:
|
View the Container's logs:
|
||||||
|
|
||||||
```
|
```shell
|
||||||
kubectl logs dapi-envars-resourcefieldref
|
kubectl logs dapi-envars-resourcefieldref
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue