当前位置:网站首页>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 .
边栏推荐
- php 获取文件夹下面的文件列表和文件夹列表
- vulnhub之Ripper
- How to mix embedded MCU, arm and DSP?
- Cacti监控Redis实现过程
- vulnhub之Nagini
- Experience container in libvirt
- 【学习笔记】dp 状态与转移
- Test classification in openstack
- Software testing weekly (issue 78): the more confident you are about the future, the more patient you are about the present.
- uniapp实现点击加载更多
猜你喜欢
How should intermediate software designers prepare for the soft test
MCDF实验1
After watching the video, AI model learned to play my world: cutting trees, making boxes, making stone picks, everything is good
Solution to the second weekly test of ACM intensive training of Hunan Institute of technology in 2022
金额计算用 BigDecimal 就万无一失了?看看这五个坑吧~~
ftp登录时,报错“530 Login incorrect.Login failed”
XML (DTD, XML parsing, XML modeling)
Extrapolated scatter data
Qt OpenGL 纹理贴图
836. 合并集合(DAY 63)并查集
随机推荐
Qt OpenGL 纹理贴图
Machine learning 3.2 decision tree model learning notes (to be supplemented)
libvirt 中体验容器
Some common terms
C language utf8toutf16 (UTF-8 characters are converted to hexadecimal encoding)
Cacti monitors redis implementation process
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
Groovy测试类 和 Junit测试
Vulnhub's Tomato (tomato)
vulnhub之tomato(西红柿)
The tutor put forward 20 pieces of advice to help graduate students successfully complete their studies: first, don't plan to take a vacation
GCC compilation process and dynamic link library and static link library
Excel表格转到Word中,表格不超边缘纸张范围
Unity3D学习笔记5——创建子Mesh
MCDF Experiment 1
Vulnhub's presidential
小鹏 P7 撞护栏安全气囊未弹出,官方回应称撞击力度未达到弹出要求
Visual studio 2022 downloading and configuring opencv4.5.5
Ripper of vulnhub
Concurrent programming - singleton