Skip to content

Commit 4cef459

Browse files
authored
pod probe marker proposal (#1053)
Signed-off-by: liheng.zms <[email protected]> Signed-off-by: liheng.zms <[email protected]>
1 parent 12f874a commit 4cef459

File tree

1 file changed

+128
-0
lines changed

1 file changed

+128
-0
lines changed
+128
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
---
2+
title: PodProbeMarker
3+
authors:
4+
- "@zmberg"
5+
reviewers:
6+
- "@furykerry"
7+
- "@FillZpp"
8+
creation-date: 2022-08-09
9+
last-updated: 2021-09-26
10+
status: implementable
11+
---
12+
13+
# Pod Probe Marker
14+
15+
## Table of Contents
16+
17+
A table of contents is helpful for quickly jumping to sections of a proposal and for highlighting
18+
any additional information provided beyond the standard proposal template.
19+
[Tools for generating](https://github.com/ekalinin/github-markdown-toc) a table of contents from markdown are available.
20+
21+
- [Title](#title)
22+
- [Table of Contents](#table-of-contents)
23+
- [Motivation](#motivation)
24+
- [Proposal](#proposal)
25+
- [API Definition](#api-definition)
26+
- [Implementation](#implementation)
27+
- [Relationship With Startup Probe](#relationship-with-startup-probe)
28+
29+
## Motivation
30+
Kubernetes provides two probes by default for Pod lifecycle management:
31+
- **Readiness Probe** is used to determine whether the business container is ready to respond to requests, and if it fails, the Pod will be removed from the Service Endpoints.
32+
- **Liveness Probe** is used to determine the health status of the container, and if it fails, Kebelet will restart the Container.
33+
34+
**So K8S on the provision of Probe capabilities are limited to specific semantics and behavior. In addition, there are some business applications that have the need to customize the semantics and behavior of the Probe**, such as:
35+
- GameServer defines Idle Probe to determine whether there is a game match for the current Pod, if there is no match, from cost optimization considerations can be given priority to offline this Pod
36+
- Operator defines Master-Slave Probe to determine the role of the current Pod (master or slave), and upgrade the Slave node in priority
37+
38+
## Proposal
39+
OpenKruise provides the ability to customize Container Probe, Kruise Daemon executes customize Probe scripts and returns the results to the Pod yaml.
40+
41+
### API Definition
42+
```yaml
43+
apiVersion: apps.kruise.io/v1alpha1
44+
kind: PodProbeMarker
45+
metadata:
46+
name: game-server-probe
47+
namespace: ns
48+
spec:
49+
selector:
50+
matchLabels:
51+
app: game-server
52+
probes:
53+
- name: Idle
54+
containerName: game-server
55+
probe:
56+
exec: /home/game/idle.sh
57+
initialDelaySeconds: 10
58+
timeoutSeconds: 3
59+
periodSeconds: 10
60+
successThreshold: 1
61+
failureThreshold: 3
62+
markerPolicy:
63+
- state: Succeeded
64+
labels:
65+
gameserver-idle: 'true'
66+
annotations:
67+
controller.kubernetes.io/pod-deletion-cost: '-10'
68+
- state: Failed
69+
labels:
70+
gameserver-idle: 'false'
71+
annotations:
72+
controller.kubernetes.io/pod-deletion-cost: '10'
73+
podConditionType: game.io/idle
74+
75+
# for kruise daemon
76+
apiVersion: apps.kruise.io/v1alpha1
77+
kind: NodePodProbe
78+
metadata:
79+
name: node-name
80+
spec:
81+
podContainerProbes:
82+
- podName: gameserver-0
83+
containerProbes:
84+
- name: game-server-probe#Idle
85+
containerName: gameserver
86+
probes:
87+
exec: /home/game/idle.sh
88+
initialDelaySeconds: 10
89+
timeoutSeconds: 3
90+
periodSeconds: 10
91+
successThreshold: 1
92+
failureThreshold: 3
93+
94+
status:
95+
podProbeResults:
96+
- podName: gameserver-0
97+
containerProbes:
98+
- name: game-server-probe#Idle
99+
status: 'Failed'
100+
101+
102+
// probe result
103+
apiVersion: v1
104+
kind: Pod
105+
metadata:
106+
name: gameserver-0
107+
labels:
108+
gameserver-idle: 'false'
109+
annotations:
110+
controller.kubernetes.io/pod-deletion-cost: '10'
111+
spec:
112+
...
113+
status:
114+
conditions:
115+
- type: game.io/idle
116+
status: 'False'
117+
```
118+
119+
### Implementation
120+
- **pod-probe-controller**: Responsible for automatically generating and cleaning NodePodProbe resources (one per Node) based on PodProbeMarker
121+
and writing the results back to Pod yaml based on NodePodProbe Status
122+
- **kruise-daemon**: Responsible for executing the probe (EXEC, HTTP) and returning the results to NodePodProbe Status
123+
124+
### Relationship With Startup Probe
125+
StartupProbe indicates that the Pod has successfully initialized. If specified, no other probes are executed until this completes successfully.
126+
So Kruise PodProbeMarker will be executed until StartupProbe succeed.
127+
128+

0 commit comments

Comments
 (0)