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

k8s系列(14)--探针检测

apiVersion: v1
kind: Pod
metadata:
name: readiness-httpget-pod
namespace: default
spec:
containers:

  • name: readiness-httpget-container
    image: 192.168.68.253:8253/library/nginx:latest
    imagePullPolicy: IfNotPresent
    readinessProbe:
    httpGet:
    port: 80
    path: /index1.html
    initialDelaySeconds: 1
    periodSeconds: 3
    进入容器
    kubectl exec readiness-httpget-pod -it -- /bin/sh
    exit退出
    文件已经存在,但是检测还是失败了

存活检测
apiVersion: v1
kind: Pod
metadata:
name: liveness-exec-pod
namespace: default
spec:
containers:

  • name: livness-exec-container
    image: 192.168.68.253:8253/library/busybox:latest
    imagePullPolicy: IfNotPresent
    command: ["/bin/sh","-с", "touch /tmp/live ; sleep 60; rm -rf /tmp/live; sleep 3600"]
    livenessProbe:
    exec:
    command: ["test","-е","/tmp/live"]
    initialDelaySeconds: 1
    periodSeconds: 3
    不知道为什么,文件夹没删掉,又失败了,拼写错误,rm -rf没有空格,上面也是拼写失败,index1.html后面多了个I

apiVersion: v1
kind: Pod
metadata:
name: liveness-httpget-pod
namespace: default
spec:
containers:

  • name: liveness-httpget-container
    image: 192.168.68.253:8253/library/nginx:latest
    imagePullPolicy: IfNotPresent
    ports:
    • name: http
      containerPort: 80
      livenessProbe:
      httpGet:
      port: http
      path: /index.html
      initialDelaySeconds: 1
      periodSeconds: 3
      timeoutSeconds: 10

kubectl exec podname -it -- rm -rf /usr/share/nginx/html/index/html

apiVersion: v1
kind: Pod
metadata:
name: probe-tcp
spec:
containers:

  • name: nginx
    image: 192.168.68.253:8253/library/nginx:latest
    imagePullPolicy: IfNotPresent
    livenessProbe:
    initialDelaySeconds: 5
    timeoutSeconds: 1
    tcpSocket:
    port: 80

start/end

apiVersion: v1
kind: Pod
metadata:
name: lifecycle-demo
spec:
containers:

  • name: lifecycle-demo-container
    image: 192.168.68.253:8253/library/nginx:latest
    lifecycle:
    postStart:
    exec:
    command: ["/bin/sh", "-с", "echo Hello from the poststart handler > /usr/share/message"]
    prestop:
    exec:
    command: ["/bin/sh","-с", "echo Hello from the poststop handler > /usr/share/message"]

status的值
挂起(Pending):Pod己被Kubernetes系统接受,但有一个或者多个容器镜像尚未创建。等待时间包括调度Pod的时间和通过网络下载镜像的时间,这可能需要花点时间
运行中(Running):该Pod已经绑定到了一个节点上,Pod 中所有的容器都已被创建。至少有一个容器正在运行,或者正处于启动或重启状态
成功(Succeeded):Pod 中的所有容器都被成功终止,并且不会再重启
失败(Failed):Pod 中的所有容器都已终止了,并且至少有一个容器是因为失败终止。也就是说,容器以非0状态退出或者被系统终止
未知(Unknown):因为某些原因无法取得Pod的状态,通常是因为与Pod所在主机通信失败

命令式编程:重复调用重复执行,一步一步走
声明式编程:只要最终结果一致就不会重新执行,告诉结果,自动执行,数据库就是声明式编程

http://www.jsqmd.com/news/1795/

相关文章:

  • k8s系列--控制器yml(15)
  • 从 Web 到 LLM,多入口、多链路的自动化威胁如何防护? - 详解
  • 学生管理系统案例初步分析报告
  • 【mysql】mysql5.6 版本修改用户的登录
  • AT_abc200_e [ABC200E] Patisserie ABC 2 题解
  • 日总结 5
  • Linux驱动开发(1)概念、环境与代码框架 - 实践
  • 9月22号
  • 0.5*8 边形 != 式
  • 题解:AT_agc052_c [AGC052C] Nondivisible Prefix Sums
  • 寻路算法
  • 2025年9月22日 - 20243867孙堃2405
  • day 1
  • [Paper Reading] METAGPT: META PROGRAMMING FOR A MULTI-AGENT COLLABORATIVE FRAMEWORK
  • 二进制 - 20243867孙堃2405
  • 学习问题日记-1
  • 记一次生产环境内存溢出记录
  • 四舍六入五成双
  • 借助 Apache Phoenix,使用标准 SQL 和 JDBC 接口来操作 HBase
  • LeetCode:15.转轮数组 - 详解
  • Android 中获取稳定时间的方法 - 指南
  • 【精品资料鉴赏】RPA财务机器人应用(基于UiPath)教材配套课件 - 详解
  • 如何让AI生成多页面APP原型图?AI原型设计实用指南
  • 代码随想录算法训练营第五天 | leetcode 242 349 202 1
  • CF2146 Codeforces Round 1052 (Div. 2) 游记
  • 原码补码反码与位操作
  • 如何安装 SQLPro Studio for Mac?v2024.21.dmg 文件安装步骤详解(附安装包)
  • 特殊句式
  • 9月22日
  • 20250922