Skip to content

Commit f17f388

Browse files
authored
Merge pull request #29740 from SergeyKanzhelev/grpcProbeDocsPlaceholder
gRPC probes support (KEP 2727)
2 parents 6a68446 + ef66685 commit f17f388

File tree

4 files changed

+71
-6
lines changed

4 files changed

+71
-6
lines changed

content/en/blog/_posts/2018-10-01-health-checking-grpc.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ title: 'Health checking gRPC servers on Kubernetes'
44
date: 2018-10-01
55
---
66

7+
_Built-in gRPC probes were introduced in Kubernetes 1.23. To learn more, see [Configure Liveness, Readiness and Startup Probes](/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#define-a-grpc-liveness-probe)._
8+
79
**Author**: [Ahmet Alp Balkan](https://twitter.com/ahmetb) (Google)
810

911
[gRPC](https://grpc.io) is on its way to becoming the lingua franca for

content/en/docs/reference/command-line-tools-reference/feature-gates.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ different Kubernetes components.
124124
| `ExperimentalHostUserNamespaceDefaulting` | `false` | Beta | 1.5 | |
125125
| `GracefulNodeShutdown` | `false` | Alpha | 1.20 | 1.20 |
126126
| `GracefulNodeShutdown` | `true` | Beta | 1.21 | |
127+
| `GRPCContainerProbe` | `false` | Alpha | 1.23 | |
127128
| `HPAContainerMetrics` | `false` | Alpha | 1.20 | |
128129
| `HPAScaleToZero` | `false` | Alpha | 1.16 | |
129130
| `IdentifyPodOS` | `false` | Alpha | 1.23 | |
@@ -578,10 +579,10 @@ Each feature gate is designed for enabling/disabling a specific feature:
578579
extended tokens by starting `kube-apiserver` with flag `--service-account-extend-token-expiration=false`.
579580
Check [Bound Service Account Tokens](https://github.com/kubernetes/enhancements/blob/master/keps/sig-auth/1205-bound-service-account-tokens/README.md)
580581
for more details.
581-
- `ControllerManagerLeaderMigration`: Enables Leader Migration for
582-
[kube-controller-manager](/docs/tasks/administer-cluster/controller-manager-leader-migration/#initial-leader-migration-configuration) and
583-
[cloud-controller-manager](/docs/tasks/administer-cluster/controller-manager-leader-migration/#deploy-cloud-controller-manager) which allows a cluster operator to live migrate
584-
controllers from the kube-controller-manager into an external controller-manager
582+
- `ControllerManagerLeaderMigration`: Enables Leader Migration for
583+
[kube-controller-manager](/docs/tasks/administer-cluster/controller-manager-leader-migration/#initial-leader-migration-configuration) and
584+
[cloud-controller-manager](/docs/tasks/administer-cluster/controller-manager-leader-migration/#deploy-cloud-controller-manager) which allows a cluster operator to live migrate
585+
controllers from the kube-controller-manager into an external controller-manager
585586
(e.g. the cloud-controller-manager) in an HA cluster without downtime.
586587
- `CPUManager`: Enable container level CPU affinity support, see
587588
[CPU Management Policies](/docs/tasks/administer-cluster/cpu-management-policies/).
@@ -791,6 +792,7 @@ Each feature gate is designed for enabling/disabling a specific feature:
791792
and gracefully terminate pods running on the node. See
792793
[Graceful Node Shutdown](/docs/concepts/architecture/nodes/#graceful-node-shutdown)
793794
for more details.
795+
- `GRPCContainerProbe`: Enables gPRC probe method for {Liveness,Readiness,Startup}Probe. See [Configure Liveness, Readiness and Startup Probes](/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#define-a-grpc-liveness-probe).
794796
- `HPAContainerMetrics`: Enable the `HorizontalPodAutoscaler` to scale based on
795797
metrics from individual containers in target pods.
796798
- `HPAScaleToZero`: Enables setting `minReplicas` to 0 for `HorizontalPodAutoscaler`

content/en/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes.md

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,11 +220,57 @@ After 15 seconds, view Pod events to verify that liveness probes:
220220
kubectl describe pod goproxy
221221
```
222222

223+
## Define a gRPC liveness probe
224+
225+
{{< feature-state for_k8s_version="v1.23" state="alpha" >}}
226+
227+
If your application implements [gRPC Health Checking Protocol](https://github.com/grpc/grpc/blob/master/doc/health-checking.md),
228+
kubelet can be configured to use it for application liveness checks.
229+
230+
{{< codenew file="pods/probe/grpc-liveness.yaml">}}
231+
232+
To use a gRPC probe, `port` must be configured. If the health endpoint is configured
233+
on a non-default service, `service` must be configured.
234+
235+
{{< note >}}
236+
Unlike HTTP and TCP probes, named ports cannot be used and custom host cannot be configured.
237+
{{< /note >}}
238+
239+
Configuration problems (e.g. incorrect port and service, unimplemented health checking protocol)
240+
are considered a probe failure, similar to HTTP and TCP probes.
241+
242+
Before Kubernetes 1.23, gRPC health probes were often implemented using [grpc-health-probe](https://github.com/grpc-ecosystem/grpc-health-probe/),
243+
as described in the blog post [Health checking gRPC servers on Kubernetes](/blog/2018/10/01/health-checking-grpc-servers-on-kubernetes/).
244+
The built-in gRPC probes behavior is similar to one implemented by grpc-health-probe.
245+
When migrating from grpc-health-probe to built-in probes, remember the following differences:
246+
247+
- Built-in probes will run against pod IP, unlike grpc-health-probe that often runs against `127.0.0.1`.
248+
Be sure to configure your gRPC endpoint to listen for pod IP address.
249+
- Built-in probes do not currently support any authentication parameters (like `-tls`).
250+
- There are no error codes in built-in probes. All errors are considered as probe failures.
251+
- If `ExecProbeTimeout` feature gate is set to `false`, grpc-health-probe will NOT
252+
respect `timeoutSeconds` setting (which defaults to 1s),
253+
while built-in probe will fail on timeout.
254+
255+
To try the gRPC liveness check, create a Pod using the command below.
256+
In the example below, etcd pod is configured to use gRPC liveness probe.
257+
258+
259+
```shell
260+
kubectl apply -f https://k8s.io/examples/pods/probe/content/en/examples/pods/probe/grpc-liveness.yaml
261+
```
262+
263+
After 15 seconds, view Pod events to verify that the liveness probes has not failed:
264+
265+
```shell
266+
kubectl describe pod etcd-with-grpc
267+
```
268+
223269
## Use a named port
224270

225271
You can use a named
226272
[ContainerPort](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#containerport-v1-core)
227-
for HTTP or TCP liveness checks:
273+
for HTTP and TCP probes. Note, gRPC probe does not support named port.
228274

229275
```yaml
230276
ports:
@@ -349,7 +395,7 @@ This defect was corrected in Kubernetes v1.20. You may have been relying on the
349395
even without realizing it, as the default timeout is 1 second.
350396
As a cluster administrator, you can disable the [feature gate](/docs/reference/command-line-tools-reference/feature-gates/) `ExecProbeTimeout` (set it to `false`)
351397
on each kubelet to restore the behavior from older versions, then remove that override
352-
once all the exec probes in the cluster have a `timeoutSeconds` value set.
398+
once all the exec probes in the cluster have a `timeoutSeconds` value set.
353399
If you have pods that are impacted from the default 1 second timeout,
354400
you should update their probe timeout so that you're ready for the
355401
eventual removal of that feature gate.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: v1
2+
kind: Pod
3+
metadata:
4+
name: etcd-with-grpc
5+
spec:
6+
containers:
7+
- name: etcd
8+
image: k8s.gcr.io/etcd:3.5.1-0
9+
command: [ "/usr/local/bin/etcd", "--data-dir", "/var/lib/etcd", "--listen-client-urls", "http://0.0.0.0:2379", "--advertise-client-urls", "http://127.0.0.1:2379", "--log-level", "debug"]
10+
ports:
11+
- containerPort: 2379
12+
livenessProbe:
13+
gRPC:
14+
port: 2379
15+
initialDelaySeconds: 10

0 commit comments

Comments
 (0)