当前位置:网站首页>Kubernetes three dozen probes and probe mode
Kubernetes three dozen probes and probe mode
2022-07-03 11:54:00 【Xinyi7777】
One 、 Introduction to probe background
1、 Orchestration tool runtime , although pod Hang up will restart under the scheduling of the controller , appear pod When restarting , however pod Status is running, Can't really react at that time pod A healthy state , We can go through Kubernetes Probe monitoring of pod In real time .
Two 、Kubernetes Three probe types
Start the probe (Startup Probe): Judge whether the application in the container is started and completed ( Before starting the probe to judge success , Ready probes and survival probes will not execute )
Ready probe (Readiness Probe): Determine whether the container is ready , If not ready , The container will be in the not ready state , Containers that are not ready , No traffic scheduling .
Survival probe (Liveness Probe): Determine whether the application in the container is normal , If it's not normal ,K8s Will restart the container .
3、 ... and 、 Three ways of probe
exec: By executing the specified command in the container , To determine the status code returned when the command exits , If 0 Is normal .
httpGet: Through the of the container IP Address 、 Port and URL Path to send GET request ; If the status code of the response is 200 ~ 399 between , Is normal .
tcpSocket: Through the of the container IP Address and specified port , Conduct TCP Check , If the port is open , Is normal .
Four 、 Configuration item
initialDelaySeconds: Wait for the time we define After that, start the probe inspection ;
periodSeconds: The probe's Time interval between ;
timeoutSeconds: The probe's Timeout time , When we exceed the time we define , It will be regarded as a failure ;
successThreshold: The probe's Minimum number of consecutive successes ;
failureThreshold: The probe's Minimum number of consecutive failures ;
Now we use different probe methods for these three probes , Mainly for the convenience of giving you a simple introduction , It's not fixed writing ; meanwhile , These three probes can be used together ; The more common is Ready probe and survival probe are used together ( Start the probe at K8s 1.6 Added after version
5、 ... and 、 Introduction to the use of probe
1) Start the probe
apiVersion: v1
kind: Pod
metadata:
name: nginx-start-up
namespace: probe
spec:
containers:
- name: nginx-start-up
image: nginx:latest
ports:
- containerPort: 80
startupProbe:
failureThreshold: 3 # Failed three times, the probe failed
exec:
command: ['/bin/sh','-c','echo Hello World']
initialDelaySeconds: 20 # Delay 20s After that, conduct the first probe
periodSeconds: 3 # interval 3s Conduct a probe
successThreshold: 1 # Calculate the probe successfully once ok
timeoutSeconds: 2 # Overtime 2s It's a failure
2) Ready probe
apiVersion: v1
kind: Pod
metadata:
name: nginx-ready
namespace: probe
labels:
app: nginx-ready # Verify the key parameters of the ready probe
spec:
containers:
- name: nginx-ready
image: nginx:latest
ports:
- containerPort: 80
readinessProbe:
failureThreshold: 3
tcpSocket:
port: 80
initialDelaySeconds: 20
periodSeconds: 3
successThreshold: 1
timeoutSeconds: 2
Port detection is normal :
Write a nodeport Type for flow verification
apiVersion: v1
kind: Service
metadata:
name: ready-nodeport
labels:
name: ready-nodeport
namespace: probe
spec:
type: NodePort
ports:
- port: 88
protocol: TCP
targetPort: 80
nodePort: 30880
selector:
app: nginx-ready
The result of the simulated flow is ok Of
Now modify the ready probe tcpSocket The port of the detection mode is 81 Failed to simulate the probe , Will the flow reach this pod
Show 81 Port failure ,ready Status as 0, but pod yes running Of , The result of the request is as follows , Traffic injection failed . Ready probe failed , I won't give it pod Input flow .
3) Survival probe
apiVersion: v1
kind: Pod
metadata:
name: nginx-live
namespace: probe
labels:
app: nginx-live
spec:
containers:
- name: nginx-live
image: nginx:latest
ports:
- containerPort: 80
livenessProbe:
failureThreshold: 3
httpGet:
path: /
port: 80
scheme: HTTP
initialDelaySeconds: 20
periodSeconds: 3
successThreshold: 1
timeoutSeconds: 2
Generate a nodeport type service
apiVersion: v1
kind: Service
metadata:
name: live-nodeport
labels:
name: live-nodeport
namespace: probe
spec:
type: NodePort
ports:
- port: 89
protocol: TCP
targetPort: 80
nodePort: 30810
selector:
app: nginx-live
curl Conduct ip Port verification
modify httpget in port Parameter values for 81, Simulated survival probe failed , Probe failed , Will make pod To restart .
6、 ... and 、 Probe recovery
Correct probe detection port , Reload yaml file , Normal flow .
边栏推荐
猜你喜欢
OPenGL 基本知识(根据自己理解整理)
2022年湖南工学院ACM集训第二次周测题解
Vulnhub geminiinc
Groovy test class and JUnit test
vulnhub之presidential
How to get started embedded future development direction of embedded
vulnhub之Ripper
Based on MCU, how to realize OTA differential upgrade with zero code and no development?
Ripper of vulnhub
MCDF实验1
随机推荐
抓包整理外篇fiddler———— 会话栏与过滤器[二]
vulnhub之GeminiInc v2
基于turtlebot3实现SLAM建图及自主导航仿真
The excel table is transferred to word, and the table does not exceed the edge paper range
MySQL uses the method of updating linked tables with update
Capturing and sorting out external Fiddler -- Conversation bar and filter [2]
R language uses grid of gridextra package The array function combines multiple visual images of the lattice package horizontally, and the ncol parameter defines the number of columns of the combined g
Ripper of vulnhub
. \vmware-vdiskmanager. exe -k “c:\\xxxxx.vmdk”
Experience container in libvirt
《剑指offer 03》数组中重复的数字
Machine learning 3.2 decision tree model learning notes (to be supplemented)
Kibana - installation and configuration of kibana
STL tutorial 10 container commonalities and usage scenarios
Nestjs configuration service, configuring cookies and sessions
简单工厂和工厂方法模式
DNS multi-point deployment IP anycast+bgp actual combat analysis
Some common terms
This article explains the complex relationship between MCU, arm, MCU, DSP, FPGA and embedded system
Sheet1$. Output [excel source output] Error in column [xxx]. The returned column status is: "the text is truncated, or one or more characters have no matches in the target code page.".