@@ -42,7 +42,7 @@ The `spec` of a static Pod cannot refer to other API objects
42
42
43
43
{{< include "task-tutorial-prereqs.md" >}} {{< version-check >}}
44
44
45
- This page assumes you're using {{< glossary_tooltip term_id="docker " >}} to run Pods,
45
+ This page assumes you're using {{< glossary_tooltip term_id="cri-o " >}} to run Pods,
46
46
and that your nodes are running the Fedora operating system.
47
47
Instructions for other distributions or Kubernetes installations may vary.
48
48
@@ -156,32 +156,36 @@ already be running.
156
156
You can view running containers (including static Pods) by running (on the node):
157
157
` ` ` shell
158
158
# Run this command on the node where the kubelet is running
159
- docker ps
159
+ crictl ps
160
160
` ` `
161
161
162
162
The output might be something like:
163
163
164
+ ` ` ` console
165
+ CONTAINER IMAGE CREATED STATE NAME ATTEMPT POD ID
166
+ 129fd7d382018 docker.io/library/nginx@sha256:... 11 minutes ago Running web 0 34533c6729106
164
167
` ` `
165
- CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
166
- f6d05272b57e nginx:latest " nginx" 8 minutes ago Up 8 minutes k8s_web.6f802af4_static-web-fk-node1_default_67e24ed9466ba55986d120c867395f3c_378e5f3c
167
- ` ` `
168
+
169
+ {{< note > }}
170
+ ` crictl` outputs the image URI and SHA-256 checksum. ` NAME` will look more like:
171
+ ` docker.io/library/nginx@sha256:0d17b565c37bcbd895e9d92315a05c1c3c9a29f762b011a10c54a66cd53c9b31` .
172
+ {{< /note > }}
168
173
169
174
You can see the mirror Pod on the API server:
170
175
171
176
` ` ` shell
172
177
kubectl get pods
173
178
` ` `
174
179
` ` `
175
- NAME READY STATUS RESTARTS AGE
176
- static-web-my-node1 1/1 Running 0 2m
180
+ NAME READY STATUS RESTARTS AGE
181
+ static-web 1/1 Running 0 2m
177
182
` ` `
178
183
179
184
{{< note > }}
180
185
Make sure the kubelet has permission to create the mirror Pod in the API server. If not, the creation request is rejected by the API server. See
181
186
[PodSecurityPolicy](/docs/concepts/policy/pod-security-policy/).
182
187
{{< /note > }}
183
188
184
-
185
189
{{< glossary_tooltip term_id=" label" text=" Labels" > }} from the static Pod are
186
190
propagated into the mirror Pod. You can use those labels as normal via
187
191
{{< glossary_tooltip term_id=" selector" text=" selectors" > }}, etc.
@@ -190,34 +194,33 @@ If you try to use `kubectl` to delete the mirror Pod from the API server,
190
194
the kubelet _doesn' t_ remove the static Pod:
191
195
192
196
```shell
193
- kubectl delete pod static-web-my-node1
197
+ kubectl delete pod static-web
194
198
```
195
199
```
196
- pod "static-web-my-node1 " deleted
200
+ pod "static-web" deleted
197
201
```
198
202
You can see that the Pod is still running:
199
203
```shell
200
204
kubectl get pods
201
205
```
202
206
```
203
- NAME READY STATUS RESTARTS AGE
204
- static-web-my-node1 1/1 Running 0 12s
207
+ NAME READY STATUS RESTARTS AGE
208
+ static-web 1/1 Running 0 4s
205
209
```
206
210
207
- Back on your node where the kubelet is running, you can try to stop the Docker
208
- container manually.
211
+ Back on your node where the kubelet is running, you can try to stop the container manually.
209
212
You' ll see that, after a time, the kubelet will notice and will restart the Pod
210
213
automatically:
211
214
212
215
` ` ` shell
213
216
# Run these commands on the node where the kubelet is running
214
- docker stop f6d05272b57e # replace with the ID of your container
217
+ crictl stop 129fd7d382018 # replace with the ID of your container
215
218
sleep 20
216
- docker ps
217
- ` ` `
219
+ crictl ps
218
220
` ` `
219
- CONTAINER ID IMAGE COMMAND CREATED ...
220
- 5b920cbaf8b1 nginx:latest " nginx -g 'daemon of 2 seconds ago ...
221
+ ` ` ` console
222
+ CONTAINER IMAGE CREATED STATE NAME ATTEMPT POD ID
223
+ 89db4553e1eeb docker.io/library/nginx@sha256:... 19 seconds ago Running web 1 34533c6729106
221
224
` ` `
222
225
223
226
# # Dynamic addition and removal of static pods
@@ -230,14 +233,13 @@ The running kubelet periodically scans the configured directory (`/etc/kubelet.d
230
233
#
231
234
mv /etc/kubelet.d/static-web.yaml /tmp
232
235
sleep 20
233
- docker ps
236
+ crictl ps
234
237
# You see that no nginx container is running
235
238
mv /tmp/static-web.yaml /etc/kubelet.d/
236
239
sleep 20
237
- docker ps
240
+ crictl ps
238
241
` ` `
242
+ ` ` ` console
243
+ CONTAINER IMAGE CREATED STATE NAME ATTEMPT POD ID
244
+ f427638871c35 docker.io/library/nginx@sha256:... 19 seconds ago Running web 1 34533c6729106
239
245
` ` `
240
- CONTAINER ID IMAGE COMMAND CREATED ...
241
- e7a62e3427f1 nginx:latest " nginx -g 'daemon of 27 seconds ago
242
- ` ` `
243
-
0 commit comments