zoukankan      html  css  js  c++  java
  • k8s之Probe

    概述

    readinessProbe主要探测服务是否就绪,如果你的应用的readinessProbe运行失败,那么就会从组成service的端点中删除,这样就不会有流量通过Kubernetes服务发现机制来发送给它

    livenessProbe探测服务是否可,不可用时重启pod

    参数

    • initialDelaySeconds:容器启动后,第一次执行探测需要等待多少秒
    • periodSeconds:执行探测的频率,默认是10秒,最小1秒
    • timeoutSeconds:探测超时时间,告诉Kubernetes应该为健康检查等待多长时间,默认1秒,最小1秒

    官方文档: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/

    支持的类型

    http 请求

    spec:
      containers:
      - name: liveness
        args:
        - /server
        image: gcr.io/google_containers/liveness
        readinessProbe:
          httpGet:
            path: /healthz
            port: 8080
            httpHeaders:
              - name: X-Custom-Header
                value: Awesome
          initialDelaySeconds: 20
          periodSeconds: 10
          timeouteSeconds: 1
        livenessProbe:
          httpGet:
            path: /healthz
            port: 8080
            httpHeaders:
              - name: X-Custom-Header
                value: Awesome
          initialDelaySeconds: 20
          periodSeconds: 10
          timeouteSeconds: 1

    tcp 端口

    spec:
      containers:
      - name: goproxy
        image: gcr.io/google_containers/goproxy:0.1
        ports:
        - containerPort: 8080
        readinessProbe:
          tcpSocket:
            port: 8080
          initialDelaySeconds: 20
          periodSeconds: 10
          timeoutSeconds: 1
        livenessProbe:
          tcpSocket:
            port: 8080
          initialDelaySeconds: 20
          periodSeconds: 10
          timeoutSeconds: 1

    sh命令或shell脚本

    spec:
      containers:
      - name: liveness
        args:
        - /bin/sh
        - -c
        - touch /tmp/healthy; sleep 30; rm -rf /tmp/healthy; sleep 600
        image: gcr.io/google_containers/busybox
        livenessProbe:
          exec:
            command:
            - cat
            - /tmp/healthy
          initialDelaySeconds: 5
          periodSeconds: 5
  • 相关阅读:
    新浪微博评论抓取
    ubuntu下ssh登录特别慢的问题
    在ubuntu13.04上安装Mac主题
    ubuntu修复grub
    linux卸载自己编译安装的内核
    ubuntu下搭建sublime text2的java开发环境
    CentOS防火墙对特定端口允许
    python笔记:python的表达式
    python笔记一:python变量
    python笔记一:python初步
  • 原文地址:https://www.cnblogs.com/mabiao008/p/12247113.html
Copyright © 2011-2022 走看看