当前位置: 首页 > news >正文

飞天使-k8s知识点17-kubernetes实操2-pod探针的使用

文章目录

        • 探针的使用
          • 容器探针启动实验1-启动探针的使用-startupprobe
          • Liveness Probes 和 Readiness Probes
            • 演示
            • 若存在started.html 则进行

探针的使用
kubectl edit deploy -n kube-system corednslivenessprobe 的使用 livenessProbe:failureThreshold: 5httpGet:path: /healthport: 8080scheme: HTTPinitialDelaySeconds: 60periodSeconds: 10successThreshold: 1timeoutSeconds: 5readinessProbereadinessProbe:failureThreshold: 3httpGet:path: /readyport: 8181scheme: HTTPperiodSeconds: 10successThreshold: 1timeoutSeconds: 1kubectl edit po nginx kubectl describe po nginx-daemon
最下面有容器启动时候相关日志
容器探针启动实验1-启动探针的使用-startupprobe
Events:Type     Reason     Age               From               Message----     ------     ----              ----               -------Normal   Scheduled  20s               default-scheduler  Successfully assigned default/my-pod1 to ha2.example.localNormal   Pulled     20s               kubelet            Container image "nginx:1.7.9" already present on machineNormal   Created    20s               kubelet            Created container nginxNormal   Started    20s               kubelet            Started container nginxWarning  Unhealthy  4s (x2 over 14s)  kubelet            Startup probe failed: HTTP probe failed with statuscode: 404
[root@kubeadm-master1 test]# kubectl get pod
NAME                                 READY   STATUS    RESTARTS   AGE
client                               1/1     Running   0          48d
my-pod                               1/1     Running   0          7d23h
my-pod1                              0/1     Running   0          37s
net-test1                            1/1     Running   133        55d
net-test2                            1/1     Running   13         55d
nginx-deployment-67dfd6c8f9-5s6nz    1/1     Running   1          55d
tomcat-deployment-6c44f58b47-4pz6d   1/1     Running   1          55d
[root@kubeadm-master1 test]# kubectl get pod
NAME                                 READY   STATUS    RESTARTS   AGE
client                               1/1     Running   0          48d
my-pod                               1/1     Running   0          7d23h
my-pod1                              0/1     Running   0          42s
net-test1                            1/1     Running   133        55d
net-test2                            1/1     Running   13         55d
nginx-deployment-67dfd6c8f9-5s6nz    1/1     Running   1          55d
tomcat-deployment-6c44f58b47-4pz6d   1/1     Running   1          55d
[root@kubeadm-master1 test]# cat nginx-po.yaml
apiVersion: v1
kind: Pod
metadata:name: my-pod1labels:type: apptest: "1.0.0"namespace: default
spec:containers:- name: nginximage: nginx:1.7.9imagePullPolicy: IfNotPresentcommand:- nginx- -g- 'daemon off;'workingDir: /usr/share/nginx/htmlports:- name: httpcontainerPort: 80protocol: TCPenv:- name: JVM_OPTSvalue: '-Xms128m -Xmx128m'resources:requests:cpu: 100mmemory: 128Milimits:cpu: 200mmemory: 256MistartupProbe:httpGet:path: /api/pathport: 80failureThreshold: 3periodSeconds: 10successThreshold: 1timeoutSeconds: 5restartPolicy: OnFailure
Liveness Probes 和 Readiness Probes
用于检查容器是否还在运行。如果 liveness 探针失败,Kubernetes 将杀死容器,并根据其重启策略来处理。
用于检查容器是否已经准备好接收流量。如果 readiness 探针失败,Kubernetes 将不会将流量路由到该容器。定义了一个 startupProbe,它在容器启动后通过 HTTP GET 请求检查 /api/path 端点。现在我们将添加 livenessProbe 和 readinessProbe。一个 livenessProbe 可以如下定义:livenessProbe:httpGet:path: /api/healthport: 80initialDelaySeconds: 30periodSeconds: 10
这个 livenessProbe 会在容器启动后的30秒开始工作,每10秒检查一次 /api/health 端点。一个 readinessProbe 可以如下定义:readinessProbe:httpGet:path: /api/readyport: 80initialDelaySeconds: 5periodSeconds: 5
这个 readinessProbe 会在容器启动后的5秒开始工作,每5秒检查一次 /api/ready 端点。
演示
[root@kubeadm-master1 test]# cat liveness.yml
apiVersion: v1
kind: Pod
metadata:name: my-pod1labels:type: apptest: "1.0.0"namespace: default
spec:containers:- name: nginximage: nginx:1.7.9imagePullPolicy: IfNotPresentcommand:- nginx- -g- 'daemon off;'workingDir: /usr/share/nginx/htmlports:- name: httpcontainerPort: 80protocol: TCPenv:- name: JVM_OPTSvalue: '-Xms128m -Xmx128m'resources:requests:cpu: 100mmemory: 128Milimits:cpu: 200mmemory: 256MistartupProbe:httpGet:path: /api/pathport: 80failureThreshold: 3periodSeconds: 10successThreshold: 1timeoutSeconds: 5livenessProbe:httpGet:path: /api/healthport: 80initialDelaySeconds: 30periodSeconds: 10readinessProbe:httpGet:path: /api/readyport: 80initialDelaySeconds: 5periodSeconds: 5restartPolicy: OnFailureState:          RunningStarted:      Thu, 15 Feb 2024 15:15:19 +0800Ready:          FalseRestart Count:  0Limits:cpu:     200mmemory:  256MiRequests:cpu:      100mmemory:   128MiLiveness:   http-get http://:80/api/health delay=30s timeout=1s period=10s #success=1 #failure=3Readiness:  http-get http://:80/api/ready delay=5s timeout=1s period=5s #success=1 #failure=3Startup:    http-get http://:80/api/path delay=0s timeout=5s period=10s #success=1 #failure=3Environment:JVM_OPTS:  -Xms128m -Xmx128mMounts:/var/run/secrets/kubernetes.io/serviceaccount from default-token-75cq9 (ro)
Conditions:Type              StatusInitialized       TrueReady             FalseContainersReady   FalsePodScheduled      True
Volumes:default-token-75cq9:Type:        Secret (a volume populated by a Secret)SecretName:  default-token-75cq9Optional:    false
QoS Class:       Burstable
Node-Selectors:  <none>
Tolerations:     node.kubernetes.io/not-ready:NoExecute op=Exists for 300snode.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:Type     Reason     Age               From               Message----     ------     ----              ----               -------Normal   Scheduled  19s               default-scheduler  Successfully assigned default/my-pod1 to ha2.example.localNormal   Pulled     19s               kubelet            Container image "nginx:1.7.9" already present on machineNormal   Created    19s               kubelet            Created container nginxNormal   Started    19s               kubelet            Started container nginxWarning  Unhealthy  2s (x2 over 12s)  kubelet            Startup probe failed: HTTP probe failed with statuscode: 404
若存在started.html 则进行

在这里插入图片描述

相关文章:

飞天使-k8s知识点17-kubernetes实操2-pod探针的使用

文章目录 探针的使用容器探针启动实验1-启动探针的使用-startupprobeLiveness Probes 和 Readiness Probes演示若存在started.html 则进行 探针的使用 kubectl edit deploy -n kube-system corednslivenessprobe 的使用 livenessProbe:failureThreshold: 5httpGet:path: /heal…...

tee漏洞学习-翻译-3:TrustZone exploit for MSM8974

原文&#xff1a;http://bits-please.blogspot.com/2015/08/full-trustzone-exploit-for-msm8974.html 在这篇博文中&#xff0c;我们将介绍利用上一篇文章中描述的 TrustZone 漏洞的完整过程。 在开发此漏洞时&#xff0c;我只使用了我值得信赖的&#xff08;个人&#xff0…...

rust递归遍历磁盘目录及文件

Std库实现 //遍历dir目录&#xff0c;找出修改日期距离当前超过age天的文件名称&#xff0c;存入file_list中 fn visit_dir(dir: &Path, file_list: &mut Vec<String>, age: u64) -> io::Result<()> {if dir.is_dir() {for entry in fs::read_dir(dir)…...

C语言每日一题(56)平衡二叉树

力扣网 110 平衡二叉树 题目描述 给定一个二叉树&#xff0c;判断它是否是高度平衡的二叉树。 本题中&#xff0c;一棵高度平衡二叉树定义为&#xff1a; 一个二叉树每个节点 的左右两个子树的高度差的绝对值不超过 1 。 示例 1&#xff1a; 输入&#xff1a;root [3,9,20,…...

Flutter Android开发 梳理Google Material Design颜色体系

前言 做安卓开发&#xff08;Kotlin语言&#xff09;&#xff0c;Flutter开发的人员应该都听说过谷歌一直推崇的Material Design&#xff0c;而Material Design Color是其推崇的颜色体系&#xff0c;具体来说&#xff0c;Material Design Color是一套旨在帮助设计师和开发者创…...

每日五道java面试题之java基础篇(六)

目录&#xff1a; 第一题&#xff1a;Java 创建对象有哪⼏种⽅式&#xff1f;第二题 .Integer a 127&#xff0c;Integer b 127&#xff1b;Integer c 128&#xff0c;Integer d 128&#xff1b;相等吗?第三题.Object 类的常⻅⽅法?第四题 List和Set的区别第五题 ArrayList和…...

c++ STL系列——(五)map

目录 引言 特点 包含头文件 基本特性 基本操作 插入元素 访问元素 移除元素 检查是否包含某个键 获取元素数量 高级特性 迭代器 自定义比较函数 实际应用 统计字符出现次数 缓存最近访问的元素 总结 引言 在C中&#xff0c;标准模板库&#xff08;STL&#xf…...

Huggingface 文档翻译完毕

Accelerate 0.27 中文文档音频课程文档AutoTrain 中文文档AWS 中文文档竞赛中文文档Diffusers 0.26 中文文档深度强化学习课程文档数据集服务器中文文档Datasets 2.17 中文文档 Evaluate 0.4 中文文档Huggingface.js 中文文档Hub 中文文档Hub 客户端库 JS 0.20 中文文档推理 AP…...

C++中类的6个默认成员函数 【拷贝构造函数】

文章目录 拷贝构造函数的使用拷贝构造对于自定义类型【浅拷贝】深拷贝拷贝构造函数典型调用场景 拷贝构造函数的使用 在前几章学习对象的时候&#xff0c;我们有的时候需要一个与已存在对象一某一样的新对象 那在创建对象时&#xff0c;可否创建一个与已存在对象一某一样的新对…...

【前端高频面试题--Vuex下篇】

&#x1f680; 作者 &#xff1a;“码上有前” &#x1f680; 文章简介 &#xff1a;前端高频面试题 &#x1f680; 欢迎小伙伴们 点赞&#x1f44d;、收藏⭐、留言&#x1f4ac;前端高频面试题--Vuex篇 往期精彩内容Vuex 的原理Vuex中action和mutation的区别Vuex 和 localStor…...

MySQL性能调优篇(4)-查询语句的优化与重构

MySQL数据库查询语句的优化与重构 MySQL是一种常用的关系型数据库管理系统&#xff0c;广泛应用于Web开发中。在实际应用中&#xff0c;对数据库查询语句的优化和重构是提高应用性能和响应速度的重要手段。本文将介绍一些常见的优化技巧和重构方法&#xff0c;帮助开发者提高数…...

LInux、源码编译安装

步骤&#xff1a; 步骤1&#xff1a;安装开发工具gcc与make&#xff0c;释放源代码至指定目录 yum -y install gcc make 步骤2&#xff1a;tar解包&#xff0c;释放源代码至指定目录 tar -xf /root/tools.tar.gz -C /usr/local 步骤3&#xff1a;./configure 配置&#xff0c;…...

wordpress好的网站主题

有什么好的网站主题&#xff0c;都分享在这里了。 蓝色风格的wordpress模板&#xff0c;好的wordpress网站主题&#xff0c;需要既好看&#xff0c;又好用。 https://www.zhanyes.com/qiye/6305.html 血红色的好看的wordpress主题&#xff0c;布局经典&#xff0c;设计好的&am…...

【Java多线程】对进程与线程的理解

目录 1、进程/任务&#xff08;Process/Task&#xff09; 2、进程控制块抽象(PCB Process Control Block) 2.1、PCB重要属性 2.2、PCB中支持进程调度的一些属性 3、 内存分配 —— 内存管理&#xff08;Memory Manage&#xff09; 4、线程&#xff08;Thread&#xff09;…...

C# CAD交互界面-自定义面板集-查找定位(六)

运行环境 vs2022 c# cad2016 调试成功 一、代码说明 1. 类成员变量声明&#xff1a; List<ObjectId> objectIds new List<ObjectId>(); // 用于存储AutoCAD实体对象的ObjectId列表 private static Autodesk.AutoCAD.Windows.PaletteSet _ps2; // 自定义浮动面板…...

5.7 BCC工具之disksnoop.py解读

一,disksnoop.py简介 disksnoop工具用于追踪块设备的I/O操作的延迟,它会在每次I/O执行完成后打印一行摘要信息。我们根据这些摘要日志,来分析当前的I/O操作是否存在延迟,以判断I/O是否达到了瓶颈。 二,代码示例 #!/usr/bin/python # # disksnoop.py Trace block device…...

QT:实现图片选择器

一、效果图 二、用到的类 qApp&#xff1a;可以快速获取到项目目录位置。 QSettings &#xff1a;编写config文件&#xff0c;记录上次打开图片的位置&#xff0c;下次打开图片会从上次的位置查找图片。 QPixmap&#xff1a;用于图片的缩放&#xff0c;防止图片过小&#xff0…...

LLM大模型相关问题汇总---包括问题与答案

一、基础篇 1. 目前主流的开源模型体系有哪些&#xff1f; - Transformer体系&#xff1a;由Google提出的Transformer模型及其变体&#xff0c;如BERT、GPT等。 - PyTorch Lightning&#xff1a;一个基于PyTorch的轻量级深度学习框架&#xff0c;用于快速原型设计和实验…...

自动化测试定位不到元素怎么办?

1.动态id定位不到元素 分析原因&#xff1a;每次打开页面&#xff0c;ID都会变化。用ID去找元素&#xff0c;每次刷新页面ID都会发生变化。 解决方案&#xff1a;推荐使用xpath的相对路径方法或者cssSelector查找到该元素。 2.iframe原因定位不到元素 分析原因&#xff1a;…...

1 scala集合-数组

1 定长数组 定长数组&#xff0c;是指数组长度不可变。定义定长数组的方法有如下两种&#xff1a; 方法1&#xff1a; var/val variable_name new Array[元素类型](数组长度) // 通过制定长度定义例如&#xff0c;定义一个长度为20的Int 类型数组。 scala> val a new …...

汽车生产虚拟实训中的技能提升与生产优化​

在制造业蓬勃发展的大背景下&#xff0c;虚拟教学实训宛如一颗璀璨的新星&#xff0c;正发挥着不可或缺且日益凸显的关键作用&#xff0c;源源不断地为企业的稳健前行与创新发展注入磅礴强大的动力。就以汽车制造企业这一极具代表性的行业主体为例&#xff0c;汽车生产线上各类…...

反射获取方法和属性

Java反射获取方法 在Java中&#xff0c;反射&#xff08;Reflection&#xff09;是一种强大的机制&#xff0c;允许程序在运行时访问和操作类的内部属性和方法。通过反射&#xff0c;可以动态地创建对象、调用方法、改变属性值&#xff0c;这在很多Java框架中如Spring和Hiberna…...

Spring Boot+Neo4j知识图谱实战:3步搭建智能关系网络!

一、引言 在数据驱动的背景下&#xff0c;知识图谱凭借其高效的信息组织能力&#xff0c;正逐步成为各行业应用的关键技术。本文聚焦 Spring Boot与Neo4j图数据库的技术结合&#xff0c;探讨知识图谱开发的实现细节&#xff0c;帮助读者掌握该技术栈在实际项目中的落地方法。 …...

ios苹果系统,js 滑动屏幕、锚定无效

现象&#xff1a;window.addEventListener监听touch无效&#xff0c;划不动屏幕&#xff0c;但是代码逻辑都有执行到。 scrollIntoView也无效。 原因&#xff1a;这是因为 iOS 的触摸事件处理机制和 touch-action: none 的设置有关。ios有太多得交互动作&#xff0c;从而会影响…...

高效线程安全的单例模式:Python 中的懒加载与自定义初始化参数

高效线程安全的单例模式:Python 中的懒加载与自定义初始化参数 在软件开发中,单例模式(Singleton Pattern)是一种常见的设计模式,确保一个类仅有一个实例,并提供一个全局访问点。在多线程环境下,实现单例模式时需要注意线程安全问题,以防止多个线程同时创建实例,导致…...

LINUX 69 FTP 客服管理系统 man 5 /etc/vsftpd/vsftpd.conf

FTP 客服管理系统 实现kefu123登录&#xff0c;不允许匿名访问&#xff0c;kefu只能访问/data/kefu目录&#xff0c;不能查看其他目录 创建账号密码 useradd kefu echo 123|passwd -stdin kefu [rootcode caozx26420]# echo 123|passwd --stdin kefu 更改用户 kefu 的密码…...

Caliper 配置文件解析:fisco-bcos.json

config.yaml 文件 config.yaml 是 Caliper 的主配置文件,通常包含以下内容: test:name: fisco-bcos-test # 测试名称description: Performance test of FISCO-BCOS # 测试描述workers:type: local # 工作进程类型number: 5 # 工作进程数量monitor:type: - docker- pro…...

深入浅出WebGL:在浏览器中解锁3D世界的魔法钥匙

WebGL&#xff1a;在浏览器中解锁3D世界的魔法钥匙 引言&#xff1a;网页的边界正在消失 在数字化浪潮的推动下&#xff0c;网页早已不再是静态信息的展示窗口。如今&#xff0c;我们可以在浏览器中体验逼真的3D游戏、交互式数据可视化、虚拟实验室&#xff0c;甚至沉浸式的V…...

32位寻址与64位寻址

32位寻址与64位寻址 32位寻址是什么&#xff1f; 32位寻址是指计算机的CPU、内存或总线系统使用32位二进制数来标识和访问内存中的存储单元&#xff08;地址&#xff09;&#xff0c;其核心含义与能力如下&#xff1a; 1. 核心定义 地址位宽&#xff1a;CPU或内存控制器用32位…...

【记录坑点问题】IDEA运行:maven-resources-production:XX: OOM: Java heap space

问题&#xff1a;IDEA出现maven-resources-production:operation-service: java.lang.OutOfMemoryError: Java heap space 解决方案&#xff1a;将编译的堆内存增加一点 位置&#xff1a;设置setting-》构建菜单build-》编译器Complier...