当前位置:网站首页>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 .
边栏推荐
- How should intermediate software designers prepare for the soft test
- Deploying WordPress instance tutorial under coreos
- 鸿蒙第三次培训(项目实训)
- cgroup简介
- STL教程9-容器元素深拷贝和浅拷贝问题
- (数据库提权——Redis)Redis未授权访问漏洞总结
- rxjs Observable filter Operator 的实现原理介绍
- Dynamically monitor disk i/o with ZABBIX
- previous permutation lintcode51
- Repo ~ common commands
猜你喜欢

vulnhub之Nagini

Vulnhub's Tomato (tomato)

DS90UB949

ArcGIS应用(二十一)Arcmap删除图层指定要素的方法

836. Merge sets (day 63) and search sets

"Jianzhi offer 04" two-dimensional array search

AI模型看看视频,就学会了玩《我的世界》:砍树、造箱子、制作石镐样样不差...

Based on MCU, how to realize OTA differential upgrade with zero code and no development?

Raven2 of vulnhub

Groovy测试类 和 Junit测试
随机推荐
Visual studio 2022 downloading and configuring opencv4.5.5
VS2015的下载地址和安装教程
Qt+VTK+OCCT读取IGES/STEP模型
STL教程9-容器元素深拷贝和浅拷贝问题
Vulnhub geminiinc V2
MySQL searches and sorts out common methods according to time
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
解决msvcp120d.dll和msvcr120d.dll缺失
Based on MCU, how to realize OTA differential upgrade with zero code and no development?
uniapp scroll view 解决高度自适应、弹框滚动穿透等问题。
typeScript
Dynamically monitor disk i/o with ZABBIX
Solution to the second weekly test of ACM intensive training of Hunan Institute of technology in 2022
错排问题 (抽奖,发邮件)
ftp登录时,报错“530 Login incorrect.Login failed”
Nestjs配置服务,配置Cookie和Session
The world's most popular font editor FontCreator tool
Hongmeng third training (project training)
PHP Basics
previous permutation lintcode51