@@ -37,51 +37,53 @@ restarts. Here is the configuration file for the Pod:
37
37
38
38
1 . Create the Pod:
39
39
40
- kubectl create -f https://k8s.io/examples/pods/storage/redis.yaml
40
+ kubectl create -f https://k8s.io/examples/pods/storage/redis.yaml
41
41
42
42
1 . Verify that the Pod's Container is running, and then watch for changes to
43
43
the Pod:
44
44
45
- kubectl get pod redis --watch
45
+ kubectl get pod redis --watch
46
46
47
47
The output looks like this:
48
48
49
- NAME READY STATUS RESTARTS AGE
50
- redis 1/1 Running 0 13s
49
+ NAME READY STATUS RESTARTS AGE
50
+ redis 1/1 Running 0 13s
51
51
52
52
1 . In another terminal, get a shell to the running Container:
53
53
54
- kubectl exec -it redis -- /bin/bash
54
+ kubectl exec -it redis -- /bin/bash
55
55
56
56
1 . In your shell, go to ` /data/redis ` , and create a file:
57
57
58
- root@redis:/data# cd /data/redis/
59
- root@redis:/data/redis# echo Hello > test-file
58
+ root@redis:/data# cd /data/redis/
59
+ root@redis:/data/redis# echo Hello > test-file
60
60
61
61
1 . In your shell, list the running processes:
62
62
63
- root@redis:/data/redis# ps aux
63
+ root@redis:/data/redis# apt-get update
64
+ root@redis:/data/redis# apt-get install procps
65
+ root@redis:/data/redis# ps aux
64
66
65
67
The output is similar to this:
66
68
67
- USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
68
- redis 1 0.1 0.1 33308 3828 ? Ssl 00:46 0:00 redis-server *:6379
69
- root 12 0.0 0.0 20228 3020 ? Ss 00:47 0:00 /bin/bash
70
- root 15 0.0 0.0 17500 2072 ? R+ 00:48 0:00 ps aux
69
+ USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
70
+ redis 1 0.1 0.1 33308 3828 ? Ssl 00:46 0:00 redis-server *:6379
71
+ root 12 0.0 0.0 20228 3020 ? Ss 00:47 0:00 /bin/bash
72
+ root 15 0.0 0.0 17500 2072 ? R+ 00:48 0:00 ps aux
71
73
72
74
1 . In your shell, kill the redis process:
73
75
74
- root@redis:/data/redis# kill <pid>
76
+ root@redis:/data/redis# kill <pid>
75
77
76
78
where ` <pid> ` is the redis process ID (PID).
77
79
78
80
1 . In your original terminal, watch for changes to the redis Pod. Eventually,
79
81
you will see something like this:
80
82
81
- NAME READY STATUS RESTARTS AGE
82
- redis 1/1 Running 0 13s
83
- redis 0/1 Completed 0 6m
84
- redis 1/1 Running 1 6m
83
+ NAME READY STATUS RESTARTS AGE
84
+ redis 1/1 Running 0 13s
85
+ redis 0/1 Completed 0 6m
86
+ redis 1/1 Running 1 6m
85
87
86
88
At this point, the Container has terminated and restarted. This is because the
87
89
redis Pod has a
@@ -90,7 +92,7 @@ of `Always`.
90
92
91
93
1 . Get a shell into the restarted Container:
92
94
93
- kubectl exec -it redis -- /bin/bash
95
+ kubectl exec -it redis -- /bin/bash
94
96
95
97
1 . In your shell, goto ` /data/redis ` , and verify that ` test-file ` is still there.
96
98
0 commit comments