Configure liveness and readiness probes
In Astronomer Software, you can create liveness and readiness probes to assess whether your Kubernetes Pods or network are healthy and can process requests.
Some components in Astronomer Software include liveness and readiness probes by default, but all components support adding and configuring them. Astronomer Software allows you to use the Kubernetes liveness and readiness probe definitions so you can monitor the state of your Pods.
Liveness probes can be useful in all cases. However, readiness probes might be most useful for the following scenarios:
- If you have network ports open on the container
- Containers that do not have open ports, but have multiple processes within the container
- A setup where a process in a container might never reach a
healthy
state because it is waiting for some state to be achieved.
Default probe behavior
You can use the following structure to define your probes in your values.yaml
file. For example, you might want to adjust any default values by configuring the amount of time until a timeout.
You can add any definitions that are compatible with Kubernetes probes.
Liveness probe template
livenessProbe:
enabled: true
exec:
command:
- curl
- http://example.com
httpGet:
path: /index.html
port: 443
Readiness probe template
readinessProbe:
enabled: true
exec:
command:
- curl
- http://example.com
httpGet:
path: /index.html
port: 444
Retrieve existing probe definitions
You can retrieve the default probe definitions from the Kubernetes manifest. The following example shows how to retrieve the definitions for Houston.
kubectl -n "${NAMESPACE}" get deployment -l component=houston -o yaml
This command produces a large amount of yaml output describing your Houston configuration. Within this output, is a section describing the livenessProbe
, which looks like the following:
livenessProbe:
failureThreshold: 10
httpGet:
path: /v1/healthz
port: 8871
scheme: HTTP
initialDelaySeconds: 30
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 1
You can copy and paste this output into your values.yaml
file for your Houston configuration, then adjust the values you want to customize. Then apply a platform config change.
Reference Helm values within your probes
Because values for the liveness and readiness probes are passed through the Helm template function, you can reference Helm values within the probes. Specifically, the livenessProbe
and readiness
values are rendered to yaml, then passed through the Helm template function, which renders any Helm template syntaxes into the produced yaml.
For example, instead of hardcoding values for your probes to match values defined by other configurations in your values.yaml
file, you can use the configuration variable itself.
The following example, using the alertsmanager
yaml configuration, shows how the path and ports are defined by Values.ports.http
and Values.prefixURL
elsewhere in the values.yaml
file.
readinessProbe:
httpGet:
path: {{ .Values.prefixURL }}/#/status
port: {{ .Values.ports.http }}
initialDelaySeconds: 30
timeoutSeconds: 30