千家信息网

Kubernetes pod中systemctl状态探针失败问题怎么解决

发表于:2026-11-02 作者:千家信息网编辑
千家信息网最后更新 2026年11月02日,本篇内容介绍了"Kubernetes pod中systemctl状态探针失败问题怎么解决"的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧
千家信息网最后更新 2026年11月02日Kubernetes pod中systemctl状态探针失败问题怎么解决

本篇内容介绍了"Kubernetes pod中systemctl状态探针失败问题怎么解决"的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!

在Heketi的glusterd容器服务,使用systemctl探针来检测glusterfs服务是否可用,发现总是出现失败问题。

经查,在Ubuntu 18.04 上 systemctl status glusterd.service 运行时输出信息不是K8s livenessProbe希望的,导致检测器超时挂起了。

  • 使用systemctl status glusterd.service并不能检测到服务的真实状态,会挂起、超时,返回错误状态码。

使用下面的方式,可以正确检测service的真实状态:

systemctl is-active --quiet glusterd.service; echo $?;

或者(类似于):

systemctl is-active sshd >/dev/null 2>&1 && echo 0 || echo 1

输出:

  • 正常时 0;

  • 非正常时为错误码。

  • 如下所示:

        livenessProbe:          exec:            command:            - /bin/bash            - -c            - systemctl is-active --quiet glusterd.service; echo $?;          failureThreshold: 3          initialDelaySeconds: 60          periodSeconds: 10          successThreshold: 1          timeoutSeconds: 3        readinessProbe:          exec:            command:            - /bin/bash            - -c            - systemctl is-active --quiet glusterd.service; echo $?;

修改后的k8s yaml文件如下:

apiVersion: apps/v1kind: DaemonSetmetadata:  name: glusterfs-daemon  namespace: gluster  labels:    k8s-app: glusterfs-nodespec:  selector:    matchLabels:      name: glusterfs-daemon  template:    metadata:      labels:        name: glusterfs-daemon    spec:      tolerations:      - key: node-role.kubernetes.io/master        effect: NoSchedule      containers:      - image: gluster/gluster-centos:latest        imagePullPolicy: IfNotPresent        name: glusterfs        livenessProbe:          exec:            command:            - /bin/bash            - -c            - systemctl is-active --quiet glusterd.service; echo $?;          failureThreshold: 3          initialDelaySeconds: 60          periodSeconds: 10          successThreshold: 1          timeoutSeconds: 3        readinessProbe:          exec:            command:            - /bin/bash            - -c            - systemctl is-active --quiet glusterd.service; echo $?;          failureThreshold: 3          initialDelaySeconds: 60          periodSeconds: 10          successThreshold: 1          timeoutSeconds: 3        resources: {}        securityContext:          capabilities: {}          privileged: true        terminationMessagePath: /dev/termination-log        terminationMessagePolicy: File        volumeMounts:        - mountPath: /var/lib/heketi          name: glusterfs-heketi        - mountPath: /run          name: glusterfs-run        - mountPath: /run/lvm          name: glusterfs-lvm        - mountPath: /etc/glusterfs          name: glusterfs-etc        - mountPath: /var/log/glusterfs          name: glusterfs-logs        - mountPath: /var/lib/glusterd          name: glusterfs-config        - mountPath: /dev          name: glusterfs-dev        - mountPath: /sys/fs/cgroup          name: glusterfs-cgroup      dnsPolicy: ClusterFirst      hostNetwork: true      restartPolicy: Always      schedulerName: default-scheduler      securityContext: {}      terminationGracePeriodSeconds: 30      volumes:      - hostPath:          path: /var/lib/heketi          type: ""        name: glusterfs-heketi      - emptyDir: {}        name: glusterfs-run      - hostPath:          path: /run/lvm          type: ""        name: glusterfs-lvm      - hostPath:          path: /etc/glusterfs          type: ""        name: glusterfs-etc      - hostPath:          path: /var/log/glusterfs          type: ""        name: glusterfs-logs      - hostPath:          path: /var/lib/glusterd          type: ""        name: glusterfs-config      - hostPath:          path: /dev          type: ""        name: glusterfs-dev      - hostPath:          path: /sys/fs/cgroup          type: ""        name: glusterfs-cgroup

可能在不同的Linux版本上,systemd的版本不同,参数也可能不一样,输入systemctl help来获取当前版本的帮助。

"Kubernetes pod中systemctl状态探针失败问题怎么解决"的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注网站,小编将为大家输出更多高质量的实用文章!

状态 检测 探针 问题 版本 服务 输出 不同 内容 更多 知识 错误 实用 学有所成 接下来 信息 参数 困境 实际 容器 数据库的安全要保护哪些东西 数据库安全各自的含义是什么 生产安全数据库录入 数据库的安全性及管理 数据库安全策略包含哪些 海淀数据库安全审计系统 建立农村房屋安全信息数据库 易用的数据库客户端支持安全管理 连接数据库失败ssl安全错误 数据库的锁怎样保障安全 百单网互联网科技有限公司 广州百单互联网科技有限公司 科技与互联网 互联网科技财经 互联网下的科技发展 重庆互联网络科技 四川狮子座互联网科技 人人互联网科技是培训 互联网公司会议桌创意科技软装饰 互联网科技实习生岗位职责 宁夏众和广鑫互联网科技有限公司 昭通互联网科技选哪家 赶超互联网科技 微信多开 速维有品互联网信息科技(苏州)有限公司 山东子淼互联网科技有限公司 中天科技中国工业互联网 互联网高科技行业有哪些企业 西安左小互联网科技有限公司 科技信息时代互联网发展 10位科技互联网大佬 广州百单互联网科技有限公司 互联网电商科技 圆梦互联网科技 科技互联网公司装修 科技互联网技术 平安科技 互联网 互联网公司会议桌创意科技软装饰 南山科技园互联网公司有哪些 互联网公司科技股 互联网科技新闻
0