当前位置:网站首页>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 .
边栏推荐
- Vulnhub geminiinc
- PHP基础
- R语言使用gridExtra包的grid.arrange函数将ggplot2包的多个可视化图像横向组合起来,ncol参数自定义组合图列数、nrow参数自定义组合图行数
- STL tutorial 8-map
- Software testing weekly (issue 78): the more confident you are about the future, the more patient you are about the present.
- (database authorization - redis) summary of unauthorized access vulnerabilities in redis
- Ripper of vulnhub
- Excel quick cross table copy and paste
- vulnhub之GeminiInc
- This article explains the complex relationship between MCU, arm, MCU, DSP, FPGA and embedded system
猜你喜欢

vulnhub之Nagini

ftp登录时,报错“530 Login incorrect.Login failed”

rxjs Observable filter Operator 的实现原理介绍

vulnhub之Ripper

Xiaopeng P7 hit the guardrail and the airbag did not pop up. The official responded that the impact strength did not meet the ejection requirements

STL tutorial 10 container commonalities and usage scenarios

外插散点数据

Kubernetes 三打探针及探针方式

Qt OpenGL 旋转、平移、缩放

GCC compilation process and dynamic link library and static link library
随机推荐
量化计算调研
牛牛的组队竞赛
银泰百货点燃城市“夜经济”
并发编程-单例
在CoreOS下部署WordPress实例教程
DNS multi-point deployment IP anycast+bgp actual combat analysis
PHP基础
Duplicate numbers in the array of sword finger offer 03
Extrapolated scatter data
Ripper of vulnhub
Test classification in openstack
Vulnhub's presidential
Mysql根据时间搜索常用方法整理
STL教程9-容器元素深拷贝和浅拷贝问题
Dynamic programming (interval DP)
Kibana~Kibana的安装和配置
The tutor put forward 20 pieces of advice to help graduate students successfully complete their studies: first, don't plan to take a vacation
PHP Basics
Xiaopeng P7 hit the guardrail and the airbag did not pop up. The official responded that the impact strength did not meet the ejection requirements
Excel快速跨表复制粘贴