Skip to content

Commit

Permalink
pod probe marker proposal
Browse files Browse the repository at this point in the history
Signed-off-by: liheng.zms <[email protected]>
  • Loading branch information
zmberg committed Aug 9, 2022
1 parent 3153179 commit 3b39850
Showing 1 changed file with 135 additions and 0 deletions.
135 changes: 135 additions & 0 deletions docs/proposals/20220728-pod-probe-marker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
---
title: PodProbeMarker
authors:
- "@zmberg"
reviewers:
- "@furykerry"
- "@FillZpp"
creation-date: 2022-08-09
last-updated: 2021-08-09
status: implementable
---

# Pod Probe Marker

## Table of Contents

A table of contents is helpful for quickly jumping to sections of a proposal and for highlighting
any additional information provided beyond the standard proposal template.
[Tools for generating](https://github.com/ekalinin/github-markdown-toc) a table of contents from markdown are available.

- [Title](#title)
- [Table of Contents](#table-of-contents)
- [Motivation](#motivation)
- [Proposal](#proposal)
- [API Definition](#api-definition)
- [Implementation](#implementation)
- [StaticIP Scheduler Practice](#staticip-scheduler-practice)

## Motivation
Kubernetes provides two probes by default for Pod lifecycle management:
- 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.
- Liveness Probe is used to determine the health status of the container, and if it fails, Kebelet will restart the Container.

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:
- 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
- Operator defines Master-Slave Probe to determine the role of the current Pod (master or slave), and upgrade the Slave node in priority

## Proposal
OpenKruise provides the ability to customize Container Probe, Kruise Daemon executes customize Probe scripts and returns the results to the Pod yaml.

### API Definition
```yaml
apiVersion: apps.kruise.io/v1alpha1
kind: PodProbeMarker
metadata:
name: game-idle-probe
spec:
targetRef:
apiVersion: apps.kruise.io/v1alpha1
# cloneset, deployment, statefulset etc.
kind: CloneSet
name: game-server
selector:
matchLabels:
app: game-server
containers:
- name: gameserver
probes
- Name: Idle
Exec: /home/game/idle.sh
# HttpGet: xxxx
# TcpSocket: xxxx
- Name: Master
Exec: /home/game/master.sh
markItems:
# When probe execution is successful
- probeName: Master
expectation: succeeded
labels:
controller: master
- probeName: Master
expectation: failed
labels:
controller: slave

# for kruise daemon
apiVersion: apps.kruise.io/v1alpha1
kind: PodProbeMarkerRun
metadata:
name: pod-name
spec:
containers:
- gameserver
probes
- Name: Idle
Exec: xxxx
HttpGet: xxxx
# TcpSocket: xxxx
- Name: Master
Exec: /home/game/master.sh
markItems:
- probeName: Master
expectation: succeeded
labels:
controller: master
- probeName: Master
expectation: failed
labels:
controller: slave
status:
containers:
- name: gameserver
probes:
- name: Idle
result: true | false | unknown
- name: Master
result: true | false | unknown

// probe result
apiVersion: v1
kind: Pod
metadata:
name: pod-name
labels:
controller: master | slave
spec:
...
status:
conditions:
- type: Idle
status: true | false | unknown
message: xxxxxxx
- type: Master
status: true | false | unknown
```
### Implementation
- pod-probe-controller: Responsible for automatically generating and cleaning PodProbeMarkerRun resources (one per Pod) based on PodProbeMarker
and writing the results back to Pod yaml based on PodProbeMarkerRun Status
- kruise-daemon: Responsible for executing the probe (EXEC, HTTP) and returning the results to PodProbeMarkerRun Status

0 comments on commit 3b39850

Please sign in to comment.