Pod 自监控

最近更新时间: 2025-03-11 17:03:00

当前 TIC 的两个镜像组件 tcloud-tic-cgi-server 和 tcloud-tic-terraform-operator 已经容器化部署到 Kubernetes 中,使用 liveness probe(存活探针)来确认何时重启容器,使用 readiness probe(就绪探针)来确定容器是否已经就绪接收外部流量提供服务。在 TCS 集群中存活探针和就绪探针的定义如下:

livenessProbe:
      exec:
        command:
        - bash
        - /tce/healthchk.sh
      failureThreshold: 3
      initialDelaySeconds: 30
      periodSeconds: 5
      successThreshold: 1
      timeoutSeconds: 5
    name: tcloud-tic-cgi-server
    ports:
    - containerPort: 80
      protocol: TCP
    readinessProbe:
      exec:
        command:
        - bash
        - /tce/healthchk.sh
      failureThreshold: 5
      initialDelaySeconds: 30
      periodSeconds: 5
      successThreshold: 1
      timeoutSeconds: 3

两个探针使用的都是脚本/tce/healthchk.sh进行检查,在不同镜像此脚本会根据镜像中的组件进行定义,如果组件运行正常则以0退出,否则以非0退出。借助存活探针和就绪探针 Kubernetes 集群保证业务请求的正常处理。