【问题标题】:Understanding healthchecks for backend services on GKE when using ingress使用 ingress 时了解 GKE 上后端服务的运行状况检查
【发布时间】:2018-08-16 04:49:09
【问题描述】:

我在statefulset.yml中使用以下代码

apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: geth
  namespace: prod
spec:
  serviceName: geth-service
  replicas: 2
  selector:
    matchLabels:
      app: geth-node
  template:
    metadata:
      labels:
        app: geth-node
    spec:
containers:
      - name: geth-node
        image: <My image>
        imagePullPolicy: Always
        livenessProbe:
          httpGet:
              path: /
              port: 8545
          initialDelaySeconds: 20 #wait this period after staring fist time
          periodSeconds: 15  # polling interval
          timeoutSeconds: 5    # wish to receive response within this time period
        readinessProbe: 
          httpGet:
              path: /
              port: 8545
          initialDelaySeconds: 20 #wait this period after staring fist time
          periodSeconds: 15    # polling interval
          timeoutSeconds: 5 

我的ingress.yml中有以下内容

kind: Ingress
apiVersion: extensions/v1beta1
metadata:
  name: prod-ingress
  namespace: prod
  annotations:
    kubernetes.io/ingress.class: "gce"
    kubernetes.io/ingress.global-static-ip-name: "mystaticip"
spec:
  tls:
    - secretName: my-tls
      hosts: 
        - myhost.com
  rules:
    - host: myhost
      http:
        paths:
        - path: /rpc
          backend:
            serviceName: gethrpc-service
            servicePort: 80   

我的容器暴露了端口8545,所以我为statefulset配置了上面的探针。

当我创建这个 statefulset 和 ingress 时,会自动创建一个负载均衡器。

我有两个后端服务(我认为两个节点的两个端口 - 我在两个节点上运行它)

但是,我对为这些后端服务创建的以下两个运行状况检查感到困惑。

1. Path: /healthz Port number: 30695
2. Path: / Port number: 30190   
  1. 我不明白为什么这些健康检查对于不同的节点是不同的。
  2. 我将路径配置为/,所以 IMO 都应该有路径 /

PS:我正在运行一个两节点集群和 2 个 Pod,每个节点上一个。

【问题讨论】:

    标签: google-kubernetes-engine kubernetes-health-check


    【解决方案1】:

    路径 [/healthz] 用于 GLBC 的默认后端,请查看 here。 如您所知,默认后端是处理所有 URL 路径和托管 GLBC 控制器不理解的服务。

    路径 [/] 很可能是为您服务的。

    【讨论】:

    • 感谢您的回答,但我不明白为什么通过端口30695 而不是通过30190/healthz 进行健康检查
    • 默认情况下,默认后端的路径是 /healthz 并且对于每个不同的路径都有不同的端口,当您使用云提供商的负载均衡器在外部公开服务时还将创建一个 NodePort。Kubernetes master 将从 --service-node-port-range 标志指定的范围内分配一个端口(默认值:30000-32767)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-12-12
    • 1970-01-01
    • 1970-01-01
    • 2019-10-10
    • 2022-09-28
    • 1970-01-01
    • 2020-11-25
    相关资源
    最近更新 更多