Merge pull request #37848 from windsonsea/conven
Make layout prettier in /configure-volume-storage.mdpull/37878/head
commit
e2a139c1fa
|
@ -12,17 +12,12 @@ A Container's file system lives only as long as the Container does. So when a
|
||||||
Container terminates and restarts, filesystem changes are lost. For more
|
Container terminates and restarts, filesystem changes are lost. For more
|
||||||
consistent storage that is independent of the Container, you can use a
|
consistent storage that is independent of the Container, you can use a
|
||||||
[Volume](/docs/concepts/storage/volumes/). This is especially important for stateful
|
[Volume](/docs/concepts/storage/volumes/). This is especially important for stateful
|
||||||
applications, such as key-value stores (such as Redis) and databases.
|
applications, such as key-value stores (such as Redis) and databases.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## {{% heading "prerequisites" %}}
|
## {{% heading "prerequisites" %}}
|
||||||
|
|
||||||
|
|
||||||
{{< include "task-tutorial-prereqs.md" >}} {{< version-check >}}
|
{{< include "task-tutorial-prereqs.md" >}} {{< version-check >}}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- steps -->
|
<!-- steps -->
|
||||||
|
|
||||||
## Configure a volume for a Pod
|
## Configure a volume for a Pod
|
||||||
|
@ -37,71 +32,71 @@ restarts. Here is the configuration file for the Pod:
|
||||||
|
|
||||||
1. Create the Pod:
|
1. Create the Pod:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
kubectl apply -f https://k8s.io/examples/pods/storage/redis.yaml
|
kubectl apply -f https://k8s.io/examples/pods/storage/redis.yaml
|
||||||
```
|
```
|
||||||
|
|
||||||
1. Verify that the Pod's Container is running, and then watch for changes to
|
1. Verify that the Pod's Container is running, and then watch for changes to
|
||||||
the Pod:
|
the Pod:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
kubectl get pod redis --watch
|
kubectl get pod redis --watch
|
||||||
```
|
```
|
||||||
|
|
||||||
The output looks like this:
|
|
||||||
|
|
||||||
```shell
|
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:
|
1. In another terminal, get a shell to the running Container:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
kubectl exec -it redis -- /bin/bash
|
kubectl exec -it redis -- /bin/bash
|
||||||
```
|
```
|
||||||
|
|
||||||
1. In your shell, go to `/data/redis`, and then create a file:
|
1. In your shell, go to `/data/redis`, and then create a file:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
root@redis:/data# cd /data/redis/
|
root@redis:/data# cd /data/redis/
|
||||||
root@redis:/data/redis# echo Hello > test-file
|
root@redis:/data/redis# echo Hello > test-file
|
||||||
```
|
```
|
||||||
|
|
||||||
1. In your shell, list the running processes:
|
1. In your shell, list the running processes:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
root@redis:/data/redis# apt-get update
|
root@redis:/data/redis# apt-get update
|
||||||
root@redis:/data/redis# apt-get install procps
|
root@redis:/data/redis# apt-get install procps
|
||||||
root@redis:/data/redis# ps aux
|
root@redis:/data/redis# ps aux
|
||||||
```
|
```
|
||||||
|
|
||||||
The output is similar to this:
|
The output is similar to this:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
|
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
|
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 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
|
root 15 0.0 0.0 17500 2072 ? R+ 00:48 0:00 ps aux
|
||||||
```
|
```
|
||||||
|
|
||||||
1. In your shell, kill the Redis process:
|
1. In your shell, kill the Redis process:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
root@redis:/data/redis# kill <pid>
|
root@redis:/data/redis# kill <pid>
|
||||||
```
|
```
|
||||||
|
|
||||||
where `<pid>` is the Redis process ID (PID).
|
where `<pid>` is the Redis process ID (PID).
|
||||||
|
|
||||||
1. In your original terminal, watch for changes to the Redis Pod. Eventually,
|
1. In your original terminal, watch for changes to the Redis Pod. Eventually,
|
||||||
you will see something like this:
|
you will see something like this:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
NAME READY STATUS RESTARTS AGE
|
NAME READY STATUS RESTARTS AGE
|
||||||
redis 1/1 Running 0 13s
|
redis 1/1 Running 0 13s
|
||||||
redis 0/1 Completed 0 6m
|
redis 0/1 Completed 0 6m
|
||||||
redis 1/1 Running 1 6m
|
redis 1/1 Running 1 6m
|
||||||
```
|
```
|
||||||
|
|
||||||
At this point, the Container has terminated and restarted. This is because the
|
At this point, the Container has terminated and restarted. This is because the
|
||||||
Redis Pod has a
|
Redis Pod has a
|
||||||
|
@ -110,38 +105,32 @@ of `Always`.
|
||||||
|
|
||||||
1. Get a shell into the restarted Container:
|
1. Get a shell into the restarted Container:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
kubectl exec -it redis -- /bin/bash
|
kubectl exec -it redis -- /bin/bash
|
||||||
```
|
```
|
||||||
|
|
||||||
1. In your shell, go to `/data/redis`, and verify that `test-file` is still there.
|
1. In your shell, go to `/data/redis`, and verify that `test-file` is still there.
|
||||||
```shell
|
|
||||||
root@redis:/data/redis# cd /data/redis/
|
```shell
|
||||||
root@redis:/data/redis# ls
|
root@redis:/data/redis# cd /data/redis/
|
||||||
test-file
|
root@redis:/data/redis# ls
|
||||||
```
|
test-file
|
||||||
|
```
|
||||||
|
|
||||||
1. Delete the Pod that you created for this exercise:
|
1. Delete the Pod that you created for this exercise:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
kubectl delete pod redis
|
kubectl delete pod redis
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## {{% heading "whatsnext" %}}
|
## {{% heading "whatsnext" %}}
|
||||||
|
|
||||||
|
- See [Volume](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#volume-v1-core).
|
||||||
|
|
||||||
* See [Volume](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#volume-v1-core).
|
- See [Pod](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#pod-v1-core).
|
||||||
|
|
||||||
* See [Pod](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#pod-v1-core).
|
|
||||||
|
|
||||||
* In addition to the local disk storage provided by `emptyDir`, Kubernetes
|
|
||||||
supports many different network-attached storage solutions, including PD on
|
|
||||||
GCE and EBS on EC2, which are preferred for critical data and will handle
|
|
||||||
details such as mounting and unmounting the devices on the nodes. See
|
|
||||||
[Volumes](/docs/concepts/storage/volumes/) for more details.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
- In addition to the local disk storage provided by `emptyDir`, Kubernetes
|
||||||
|
supports many different network-attached storage solutions, including PD on
|
||||||
|
GCE and EBS on EC2, which are preferred for critical data and will handle
|
||||||
|
details such as mounting and unmounting the devices on the nodes. See
|
||||||
|
[Volumes](/docs/concepts/storage/volumes/) for more details.
|
||||||
|
|
Loading…
Reference in New Issue