久久精品人人爽,华人av在线,亚洲性视频网站,欧美专区一二三

Kubernetes pod中systemctl狀態探針失敗問題怎么解決

159次閱讀
沒有評論

共計 2941 個字符,預計需要花費 8 分鐘才能閱讀完成。

本篇內容介紹了“Kubernetes pod 中 systemctl 狀態探針失敗問題怎么解決”的有關知識,在實際案例的操作過程中,不少人都會遇到這樣的困境,接下來就讓丸趣 TV 小編帶領大家學習一下如何處理這些情況吧!希望大家仔細閱讀,能夠學有所成!

在 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/v1
kind: DaemonSet
metadata:
 name: glusterfs-daemon
 namespace: gluster
 labels:
 k8s-app: glusterfs-node
spec:
 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 狀態探針失敗問題怎么解決”的內容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業相關的知識可以關注丸趣 TV 網站,丸趣 TV 小編將為大家輸出更多高質量的實用文章!

正文完
 
丸趣
版權聲明:本站原創文章,由 丸趣 2023-08-16發表,共計2941字。
轉載說明:除特殊說明外本站除技術相關以外文章皆由網絡搜集發布,轉載請注明出處。
評論(沒有評論)
主站蜘蛛池模板: 灵璧县| 杨浦区| 泉州市| 娱乐| 个旧市| 开封县| 焦作市| 东丰县| 文登市| 海南省| 贡山| 台中县| 朝阳区| 奉节县| 靖宇县| 南康市| 盐城市| 禄丰县| 桓台县| 伊宁市| 蓝山县| 梁河县| 五大连池市| 元江| 天气| 泰州市| 武汉市| 南宁市| 辽阳市| 东莞市| 博湖县| 怀安县| 金山区| 板桥市| 车险| 禹州市| 桐乡市| 崇文区| 镇平县| 博客| 康保县|