@@ -233,57 +233,87 @@ When a Pod's containers are Ready but at least one custom condition is missing o
233
233
234
234
## Container probes
235
235
236
- A [ Probe ] (/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#probe-v1-core) is a diagnostic
236
+ A _ probe _ is a diagnostic
237
237
performed periodically by the
238
238
[ kubelet] ( /docs/reference/command-line-tools-reference/kubelet/ )
239
- on a Container. To perform a diagnostic,
240
- the kubelet calls a
241
- [ Handler] (/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#handler-v1-core) implemented by
242
- the container. There are three types of handlers:
239
+ on a container. To perform a diagnostic,
240
+ the kubelet either executes code within the container, or makes
241
+ a network request.
243
242
244
- * [ ExecAction] (/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#execaction-v1-core):
245
- Executes a specified command inside the container. The diagnostic
246
- is considered successful if the command exits with a status code of 0.
243
+ ### Check mechanisms {#probe-check-methods}
244
+
245
+ There are four different ways to check a container using a probe.
246
+ Each probe must define exactly one of these four mechanisms:
247
247
248
- * [ TCPSocketAction ] (/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#tcpsocketaction-v1-core):
249
- Performs a TCP check against the Pod's IP address on
250
- a specified port. The diagnostic is considered successful if the port is open .
248
+ ` exec `
249
+ : Executes a specified command inside the container. The diagnostic
250
+ is considered successful if the command exits with a status code of 0 .
251
251
252
- * [ HTTPGetAction] (/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#httpgetaction-v1-core):
253
- Performs an HTTP ` GET ` request against the Pod's IP
254
- address on a specified port and path. The diagnostic is considered successful
255
- if the response has a status code greater than or equal to 200 and less than 400.
252
+ ` grpc `
253
+ : Performs a remote procedure call using [ gRPC] ( https://grpc.io/ ) .
254
+ The target should implement
255
+ [ gRPC health checks] ( https://grpc.io/grpc/core/md_doc_health-checking.html ) .
256
+ The diagnostic is considered successful if the ` status `
257
+ of the response is ` SERVING ` .
258
+ gRPC probes are an alpha feature and are only available if you
259
+ enable the ` GRPCContainerProbe `
260
+ [ feature gate] ( /docs/reference/command-line-tools-reference/feature-gates/ ) .
261
+
262
+ ` httpGet `
263
+ : Performs an HTTP ` GET ` request against the Pod's IP
264
+ address on a specified port and path. The diagnostic is
265
+ considered successful if the response has a status code
266
+ greater than or equal to 200 and less than 400.
267
+
268
+ ` tcpSocket `
269
+ : Performs a TCP check against the Pod's IP address on
270
+ a specified port. The diagnostic is considered successful if
271
+ the port is open. If the remote system (the container) closes
272
+ the connection immediately after it opens, this counts as healthy.
273
+
274
+ ### Probe outcome
256
275
257
276
Each probe has one of three results:
258
277
259
- * ` Success ` : The container passed the diagnostic.
260
- * ` Failure ` : The container failed the diagnostic.
261
- * ` Unknown ` : The diagnostic failed, so no action should be taken.
278
+ ` Success `
279
+ : The container passed the diagnostic.
262
280
263
- The kubelet can optionally perform and react to three kinds of probes on running
264
- containers:
281
+ ` Failure `
282
+ : The container failed the diagnostic.
283
+
284
+ ` Unknown `
285
+ : The diagnostic failed (no action should be taken, and the kubelet
286
+ will make further checks).
265
287
266
- * ` livenessProbe ` : Indicates whether the container is running. If
267
- the liveness probe fails, the kubelet kills the container, and the container
268
- is subjected to its [ restart policy] ( #restart-policy ) . If a Container does not
269
- provide a liveness probe, the default state is ` Success ` .
288
+ ### Types of probe
270
289
271
- * ` readinessProbe ` : Indicates whether the container is ready to respond to requests.
272
- If the readiness probe fails, the endpoints controller removes the Pod's IP
273
- address from the endpoints of all Services that match the Pod. The default
274
- state of readiness before the initial delay is ` Failure ` . If a Container does
275
- not provide a readiness probe, the default state is ` Success ` .
290
+ The kubelet can optionally perform and react to three kinds of probes on running
291
+ containers:
276
292
277
- * ` startupProbe ` : Indicates whether the application within the container is started.
278
- All other probes are disabled if a startup probe is provided, until it succeeds.
279
- If the startup probe fails, the kubelet kills the container, and the container
280
- is subjected to its [ restart policy] ( #restart-policy ) . If a Container does not
281
- provide a startup probe, the default state is ` Success ` .
293
+ ` livenessProbe `
294
+ : Indicates whether the container is running. If
295
+ the liveness probe fails, the kubelet kills the container, and the container
296
+ is subjected to its [ restart policy] ( #restart-policy ) . If a container does not
297
+ provide a liveness probe, the default state is ` Success ` .
298
+
299
+ ` readinessProbe `
300
+ : Indicates whether the container is ready to respond to requests.
301
+ If the readiness probe fails, the endpoints controller removes the Pod's IP
302
+ address from the endpoints of all Services that match the Pod. The default
303
+ state of readiness before the initial delay is ` Failure ` . If a container does
304
+ not provide a readiness probe, the default state is ` Success ` .
305
+
306
+ ` startupProbe `
307
+ : Indicates whether the application within the container is started.
308
+ All other probes are disabled if a startup probe is provided, until it succeeds.
309
+ If the startup probe fails, the kubelet kills the container, and the container
310
+ is subjected to its [ restart policy] ( #restart-policy ) . If a container does not
311
+ provide a startup probe, the default state is ` Success ` .
282
312
283
313
For more information about how to set up a liveness, readiness, or startup probe,
284
314
see [ Configure Liveness, Readiness and Startup Probes] ( /docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/ ) .
285
315
286
- ### When should you use a liveness probe?
316
+ #### When should you use a liveness probe?
287
317
288
318
{{< feature-state for_k8s_version="v1.0" state="stable" >}}
289
319
@@ -295,7 +325,7 @@ with the Pod's `restartPolicy`.
295
325
If you'd like your container to be killed and restarted if a probe fails, then
296
326
specify a liveness probe, and specify a ` restartPolicy ` of Always or OnFailure.
297
327
298
- ### When should you use a readiness probe?
328
+ #### When should you use a readiness probe?
299
329
300
330
{{< feature-state for_k8s_version="v1.0" state="stable" >}}
301
331
@@ -329,7 +359,7 @@ The Pod remains in the unready state while it waits for the containers in the Po
329
359
to stop.
330
360
{{< /note >}}
331
361
332
- ### When should you use a startup probe?
362
+ #### When should you use a startup probe?
333
363
334
364
{{< feature-state for_k8s_version="v1.20" state="stable" >}}
335
365
@@ -451,13 +481,13 @@ This avoids a resource leak as Pods are created and terminated over time.
451
481
## {{% heading "whatsnext" %}}
452
482
453
483
* Get hands-on experience
454
- [ attaching handlers to Container lifecycle events] ( /docs/tasks/configure-pod-container/attach-handler-lifecycle-event/ ) .
484
+ [ attaching handlers to container lifecycle events] ( /docs/tasks/configure-pod-container/attach-handler-lifecycle-event/ ) .
455
485
456
486
* Get hands-on experience
457
487
[ configuring Liveness, Readiness and Startup Probes] ( /docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/ ) .
458
488
459
489
* Learn more about [ container lifecycle hooks] ( /docs/concepts/containers/container-lifecycle-hooks/ ) .
460
490
461
- * For detailed information about Pod / Container status in the API, see [ PodStatus ] (/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#podstatus-v1-core)
462
- and
463
- [ ContainerStatus ] (/docs/reference/generated/ kubernetes-api/{{< param "version" >}}/#containerstatus -v1-core) .
491
+ * For detailed information about Pod and container status in the API, see
492
+ the API reference documentation covering
493
+ [ ` .status ` ] ( /docs/reference/kubernetes-api/workload-resources/pod -v1/#PodStatus ) for Pod .
0 commit comments