Skip to content

Commit bf326bb

Browse files
authored
Add documentation for Serving probes (#5855)
* Add documentation for probing * Use white diagram background * Add more details about probing * Review improvements
1 parent f96487d commit bf326bb

File tree

4 files changed

+117
-0
lines changed

4 files changed

+117
-0
lines changed

config/nav.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ nav:
131131
- Using extensions enabled by QPOptions: serving/services/using-queue-extensions.md
132132
# TODO: Add security section to docs?
133133
- Configure resource requests and limits: serving/services/configure-requests-limits-services.md
134+
- Configuring probes: serving/services/configure-probing.md
134135
- Configuring HTTP: serving/services/http-protocol.md
135136
- Volume Support: serving/services/storage.md
136137
- Traffic management: serving/traffic-management.md

docs/serving/configuration/feature-flags.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,36 @@ spec:
105105
image: gcr.io/knative-samples/helloworld-java
106106
```
107107
108+
### Multiple Container Probing
109+
110+
* **Type**: Feature
111+
* **ConfigMap key:** `multi-container-probing`
112+
113+
This flag allows specifying probes (readiness/liveness) for multiple containers in a Knative Service spec.
114+
Please use this feature flag in combination with [multiple containers](#multiple-containers) above.
115+
116+
```yaml
117+
apiVersion: serving.knative.dev/v1
118+
kind: Service
119+
...
120+
spec:
121+
template:
122+
spec:
123+
containers:
124+
- name: first-container
125+
image: ghcr.io/knative/helloworld-go:latest
126+
ports:
127+
- containerPort: 8080
128+
readinessProbe:
129+
httpGet:
130+
port: 8080
131+
- name: second-container
132+
image: gcr.io/knative-samples/helloworld-java
133+
readinessProbe:
134+
httpGet:
135+
port: 8090
136+
```
137+
108138
### Kubernetes EmptyDir Volume
109139

110140
* **Type**: Extension
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# Configuring Probing
2+
3+
## General understanding of Knative Probing
4+
5+
It is important to note that Knative probing is different from Kubernetes probing.
6+
One reason for this is that Knative tries to minimize cold-start time and thus is probing
7+
in a vastly higher interval than Kubernetes does.
8+
9+
The general probing architecture looks like this:
10+
11+
![probing-overview](./probes-overview.drawio.svg)
12+
13+
* Users can optionally define Readiness and/or Liveness probes in the `KnativeService` CR.
14+
* The Liveness probes are directly executed by the Kubelet against the according container.
15+
* Readiness probes, on the other hand, are rewritten by Knative to be executed by the Queue-Proxy container.
16+
* Knative does probing from in places (e.g. Activator, net-* controller, and from Queue-Proxy), to make sure the whole network stack is configured and ready. Compared to vanilla Kubernetes, Knative uses faster (called aggressive probing) probing interval to shorten the cold-start times when a Pod is already up and running while Kubernetes itself has not yet reflected that readiness.
17+
* Knative will define a default Readiness probe for the primary user container when no probe is defined by the user. It will check for a TCP socket on the traffic port of the Knative Service.
18+
* Knative will also define a Readiness probe for the Queue-Proxy container itself. Queue-Proxy's health endpoint aggregates all results from it's rewritten Readiness probes for all user containers (primary + sidecars). For the aggregated status, Queue-Proxy will call each container's Readiness probe in parallel, wait for their response (or timeout) and report an aggregated result back to Kubernetes.
19+
20+
Knative will see a Pod as healthy and ready to serve traffic once the Queue-Proxy probe returns a success response and once the Knative networking layer reconfiguration has finished.
21+
22+
!!! note
23+
Keep in mind, that Knative could see your Pod as healthy and ready while Kubernetes still thinks it is not or vice versa.
24+
The `Deployment` and `Pod` statuses do not reflect the status in `Knative`. To fully check the status that Knative sees, you have to check
25+
all the conditions on the object hierarchy of Knative (e.g. `Service`, `Configuration`, `Revision`, `PodAutoscaler`, `ServerlessService`, `Route`, `Ingress`).
26+
27+
28+
## Configuring custom probes
29+
30+
!!! note
31+
If you are using multiple containers in your Knative Service, make sure to enable [multi-container probing](../configuration/feature-flags.md#multiple-container-probing).
32+
33+
You can define Readiness and Liveness probes in your Knative Service the same way you would in Kubernetes:
34+
35+
```yaml
36+
apiVersion: serving.knative.dev/v1
37+
kind: Service
38+
metadata:
39+
name: runtime
40+
namespace: default
41+
spec:
42+
template:
43+
spec:
44+
containers:
45+
46+
- name: first-container
47+
image: <your-image>
48+
ports:
49+
- containerPort: 8080
50+
readinessProbe:
51+
httpGet:
52+
port: 8080 # you can also check on a different port than the containerPort (traffic-port)
53+
path: "/health"
54+
livenessProbe:
55+
tcpSocket:
56+
port: 8080
57+
58+
- name: second-container
59+
image: <your-image>
60+
readinessProbe:
61+
httpGet:
62+
port: 8089
63+
path: "/health"
64+
livenessProbe:
65+
tcpSocket:
66+
port: 8089
67+
```
68+
69+
Supported probe types are:
70+
71+
* httpGet
72+
* tcpSocket
73+
* exec
74+
* grpc
75+
76+
77+
!!! note
78+
Be aware that Knative also does some defaulting (checking readiness on the traffic port using an HTTP check) and additional validation to make aggressive probing work.
79+
80+
!!! warning
81+
As the Queue-Proxy container does not rewrite or check defined Liveness probes, it is important to know that Kubernetes can and will restart specific containers once a Liveness probe fails. Make sure to also include the same check that you define as a Liveness probe as a Readiness probe to make sure Knative is aware of the failing container in the Pod. Otherwise, you may see, it is possible that you see connection errors during the restart of a container caused by the Liveness probe failure.
82+
Lines changed: 4 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)