|
2 | 2 | title: Set up liveness probe on container instance
|
3 | 3 | description: Learn how to configure liveness probes to restart unhealthy containers in Azure Container Instances
|
4 | 4 | ms.topic: article
|
5 |
| -ms.date: 06/08/2018 |
| 5 | +ms.date: 01/30/2020 |
6 | 6 | ---
|
7 | 7 | # Configure liveness probes
|
8 | 8 |
|
@@ -57,41 +57,41 @@ az container create --resource-group myResourceGroup --name livenesstest -f live
|
57 | 57 |
|
58 | 58 | ### Start command
|
59 | 59 |
|
60 |
| -The deployment defines a starting command to be run when the container first starts running, defined by the `command` property, which accepts an array of strings. In this example, it will start a bash session and create a file called `healthy` within the `/tmp` directory by passing this command: |
| 60 | +The deployment includes a `command` property defining a starting command that runs when the container first starts running. This property accepts an array of strings. This command simulates the container entering an unhealthy state. |
| 61 | + |
| 62 | +First, it starts a bash session and creates a file called `healthy` within the `/tmp` directory. It then sleeps for 30 seconds before deleting the file, then enters a 10-minute sleep: |
61 | 63 |
|
62 | 64 | ```bash
|
63 | 65 | /bin/sh -c "touch /tmp/healthy; sleep 30; rm -rf /tmp/healthy; sleep 600"
|
64 | 66 | ```
|
65 | 67 |
|
66 |
| - It will then sleep for 30 seconds before deleting the file, then enters a 10-minute sleep. |
67 |
| - |
68 | 68 | ### Liveness command
|
69 | 69 |
|
70 |
| -This deployment defines a `livenessProbe` that supports an `exec` liveness command that acts as the liveness check. If this command exits with a non-zero value, the container will be killed and restarted, signaling the `healthy` file could not be found. If this command exits successfully with exit code 0, no action will be taken. |
| 70 | +This deployment defines a `livenessProbe` that supports an `exec` liveness command that acts as the liveness check. If this command exits with a non-zero value, the container is killed and restarted, signaling the `healthy` file could not be found. If this command exits successfully with exit code 0, no action is taken. |
71 | 71 |
|
72 | 72 | The `periodSeconds` property designates the liveness command should execute every 5 seconds.
|
73 | 73 |
|
74 | 74 | ## Verify liveness output
|
75 | 75 |
|
76 |
| -Within the first 30 seconds, the `healthy` file created by the start command exists. When the liveness command checks for the `healthy` file's existence, the status code returns a zero, signaling success, so no restarting occurs. |
| 76 | +Within the first 30 seconds, the `healthy` file created by the start command exists. When the liveness command checks for the `healthy` file's existence, the status code returns 0, signaling success, so no restarting occurs. |
77 | 77 |
|
78 |
| -After 30 seconds, the `cat /tmp/healthy` will begin to fail, causing unhealthy and killing events to occur. |
| 78 | +After 30 seconds, the `cat /tmp/healthy` command begins to fail, causing unhealthy and killing events to occur. |
79 | 79 |
|
80 | 80 | These events can be viewed from the Azure portal or Azure CLI.
|
81 | 81 |
|
82 | 82 | ![Portal unhealthy event][portal-unhealthy]
|
83 | 83 |
|
84 |
| -By viewing the events in the Azure portal, events of type `Unhealthy` will be triggered upon the liveness command failing. The subsequent event will be of type `Killing`, signifying a container deletion so a restart can begin. The restart count for the container increments each time this event occurs. |
| 84 | +By viewing the events in the Azure portal, events of type `Unhealthy` are triggered upon the liveness command failing. The subsequent event is of type `Killing`, signifying a container deletion so a restart can begin. The restart count for the container increments each time this event occurs. |
85 | 85 |
|
86 |
| -Restarts are completed in-place so resources like public IP addresses and node-specific contents will be preserved. |
| 86 | +Restarts are completed in-place so resources like public IP addresses and node-specific contents are preserved. |
87 | 87 |
|
88 | 88 | ![Portal restart counter][portal-restart]
|
89 | 89 |
|
90 |
| -If the liveness probe continuously fails and triggers too many restarts, your container will enter an exponential back off delay. |
| 90 | +If the liveness probe continuously fails and triggers too many restarts, your container enters an exponential back-off delay. |
91 | 91 |
|
92 | 92 | ## Liveness probes and restart policies
|
93 | 93 |
|
94 |
| -Restart policies supersede the restart behavior triggered by liveness probes. For example, if you set a `restartPolicy = Never` *and* a liveness probe, the container group will not restart because of a failed liveness check. The container group will instead adhere to the container group's restart policy of `Never`. |
| 94 | +Restart policies supersede the restart behavior triggered by liveness probes. For example, if you set a `restartPolicy = Never` *and* a liveness probe, the container group will not restart because of a failed liveness check. The container group instead adheres to the container group's restart policy of `Never`. |
95 | 95 |
|
96 | 96 | ## Next steps
|
97 | 97 |
|
|
0 commit comments