当前位置:网站首页>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 .
边栏推荐
- Dynamic programming (interval DP)
- vulnhub之narak
- Unity3D学习笔记5——创建子Mesh
- Yintai department store ignites the city's "night economy"
- STL tutorial 10 container commonalities and usage scenarios
- Solutions to the failure of installing electron
- PHP基础
- Nestjs配置服务,配置Cookie和Session
- Qt+VTK+OCCT读取IGES/STEP模型
- R language uses data The table package performs data aggregation statistics, calculates window statistics, calculates the median of sliding groups, and merges the generated statistical data into the o
猜你喜欢

Excel表格转到Word中,表格不超边缘纸张范围

Momentum of vulnhub

vulnhub之momentum

Niuniu's team competition

vulnhub之Ripper

Raven2 of vulnhub

Vulnhub geminiinc

The uniapp scroll view solves the problems of high adaptability and bullet frame rolling penetration.

同事写了一个责任链模式,bug无数...

The tutor put forward 20 pieces of advice to help graduate students successfully complete their studies: first, don't plan to take a vacation
随机推荐
R language ggplot2 visualization: gganimate package creates dynamic line graph animation (GIF) and uses transition_ The reveal function displays data step by step along a given dimension in the animat
Raven2 of vulnhub
STL tutorial 8-map
Kubernetes 三打探针及探针方式
vulnhub之presidential
2022 northeast four provinces match VP record / supplementary questions
简单工厂和工厂方法模式
Dynamic programming (interval DP)
解决msvcp120d.dll和msvcr120d.dll缺失
PHP基础
How should intermediate software designers prepare for the soft test
XML (DTD, XML parsing, XML modeling)
Extrapolated scatter data
Some common terms
外插散点数据
uniapp scroll view 解决高度自适应、弹框滚动穿透等问题。
Ripper of vulnhub
R language uses grid of gridextra package The array function combines multiple visual images of the ggplot2 package horizontally, and the ncol parameter defines the number of columns of the combined g
Vulnhub narak
R语言使用gridExtra包的grid.arrange函数将lattice包的多个可视化图像横向组合起来,ncol参数自定义组合图列数、nrow参数自定义组合图行数