Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format code style #9055

Merged
merged 4 commits into from
Jul 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ kubectl get pod cpu-demo --output=yaml --namespace=cpu-example
The output shows that the one Container in the Pod has a CPU request of 500 millicpu
and a CPU limit of 1 cpu.

```shell
```yaml
resources:
limits:
cpu: "1"
Expand Down Expand Up @@ -185,7 +185,7 @@ The output shows that the Pod's status is Pending. That is, the Pod has not been
scheduled to run on any Node, and it will remain in the Pending state indefinitely:


```
```shell
kubectl get pod cpu-demo-2 --namespace=cpu-example
NAME READY STATUS RESTARTS AGE
cpu-demo-2 0/1 Pending 0 7m
Expand Down
52 changes: 33 additions & 19 deletions content/en/docs/tasks/configure-pod-container/assign-pods-nodes.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,32 +21,40 @@ Kubernetes cluster.

1. List the nodes in your cluster:

kubectl get nodes
```shell
kubectl get nodes
```

The output is similar to this:

NAME STATUS AGE VERSION
worker0 Ready 1d v1.6.0+fff5156
worker1 Ready 1d v1.6.0+fff5156
worker2 Ready 1d v1.6.0+fff5156

```shell
NAME STATUS AGE VERSION
worker0 Ready 1d v1.6.0+fff5156
worker1 Ready 1d v1.6.0+fff5156
worker2 Ready 1d v1.6.0+fff5156
```
1. Chose one of your nodes, and add a label to it:

kubectl label nodes <your-node-name> disktype=ssd
```shell
kubectl label nodes <your-node-name> disktype=ssd
```

where `<your-node-name>` is the name of your chosen node.

1. Verify that your chosen node has a `disktype=ssd` label:

kubectl get nodes --show-labels

```shell
kubectl get nodes --show-labels
```

The output is similar to this:

NAME STATUS AGE VERSION LABELS
worker0 Ready 1d v1.6.0+fff5156 ...,disktype=ssd,kubernetes.io/hostname=worker0
worker1 Ready 1d v1.6.0+fff5156 ...,kubernetes.io/hostname=worker1
worker2 Ready 1d v1.6.0+fff5156 ...,kubernetes.io/hostname=worker2
```shell
NAME STATUS AGE VERSION LABELS
worker0 Ready 1d v1.6.0+fff5156 ...,disktype=ssd,kubernetes.io/hostname=worker0
worker1 Ready 1d v1.6.0+fff5156 ...,kubernetes.io/hostname=worker1
worker2 Ready 1d v1.6.0+fff5156 ...,kubernetes.io/hostname=worker2
```

In the preceding output, you can see that the `worker0` node has a
`disktype=ssd` label.
Expand All @@ -61,17 +69,23 @@ a `disktype=ssd` label.

1. Use the configuration file to create a pod that will get scheduled on your
chosen node:

kubectl create -f https://k8s.io/examples/pods/pod-nginx.yaml

```shell
kubectl create -f https://k8s.io/docs/tasks/configure-pod-container/pod.yaml
```

1. Verify that the pod is running on your chosen node:

kubectl get pods --output=wide
```shell
kubectl get pods --output=wide
```

The output is similar to this:

NAME READY STATUS RESTARTS AGE IP NODE
nginx 1/1 Running 0 13s 10.200.0.4 worker0

```shell
NAME READY STATUS RESTARTS AGE IP NODE
nginx 1/1 Running 0 13s 10.200.0.4 worker0
```

{{% /capture %}}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,51 +37,69 @@ restarts. Here is the configuration file for the Pod:

1. Create the Pod:

kubectl create -f https://k8s.io/examples/pods/storage/redis.yaml
```shell
kubectl create -f https://k8s.io/docs/tasks/configure-pod-container/pod-redis.yaml
```

1. Verify that the Pod's Container is running, and then watch for changes to
the Pod:

kubectl get pod redis --watch

```shell
kubectl get pod redis --watch
```

The output looks like this:

NAME READY STATUS RESTARTS AGE
redis 1/1 Running 0 13s
```shell
NAME READY STATUS RESTARTS AGE
redis 1/1 Running 0 13s
```

1. In another terminal, get a shell to the running Container:

kubectl exec -it redis -- /bin/bash
```shell
kubectl exec -it redis -- /bin/bash
```

1. In your shell, go to `/data/redis`, and create a file:

root@redis:/data# cd /data/redis/
root@redis:/data/redis# echo Hello > test-file
```shell
root@redis:/data# cd /data/redis/
root@redis:/data/redis# echo Hello > test-file
```

1. In your shell, list the running processes:

root@redis:/data/redis# ps aux
```shell
root@redis:/data/redis# ps aux
```

The output is similar to this:

USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
redis 1 0.1 0.1 33308 3828 ? Ssl 00:46 0:00 redis-server *:6379
root 12 0.0 0.0 20228 3020 ? Ss 00:47 0:00 /bin/bash
root 15 0.0 0.0 17500 2072 ? R+ 00:48 0:00 ps aux
```shell
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
redis 1 0.1 0.1 33308 3828 ? Ssl 00:46 0:00 redis-server *:6379
root 12 0.0 0.0 20228 3020 ? Ss 00:47 0:00 /bin/bash
root 15 0.0 0.0 17500 2072 ? R+ 00:48 0:00 ps aux
```

1. In your shell, kill the redis process:

root@redis:/data/redis# kill <pid>
```shell
root@redis:/data/redis# kill <pid>
```

where `<pid>` is the redis process ID (PID).

1. In your original terminal, watch for changes to the redis Pod. Eventually,
you will see something like this:

NAME READY STATUS RESTARTS AGE
redis 1/1 Running 0 13s
redis 0/1 Completed 0 6m
redis 1/1 Running 1 6m
```shell
NAME READY STATUS RESTARTS AGE
redis 1/1 Running 0 13s
redis 0/1 Completed 0 6m
redis 1/1 Running 1 6m
```

At this point, the Container has terminated and restarted. This is because the
redis Pod has a
Expand All @@ -90,7 +108,9 @@ of `Always`.

1. Get a shell into the restarted Container:

kubectl exec -it redis -- /bin/bash
```shell
kubectl exec -it redis -- /bin/bash
```

1. In your shell, goto `/data/redis`, and verify that `test-file` is still there.

Expand Down