你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

向服务添加运行状况探测

默认情况下,入口控制器将为公开的 Pod 预配 HTTP GET 探测。 可以通过将就绪情况或运行情况探测添加到 deployment/pod 规范来自定义探测属性。

使用 readinessProbelivenessProbe

apiVersion: networking.k8s.io/v1
kind: Deployment
metadata:
  name: aspnetapp
spec:
  replicas: 3
  template:
    metadata:
      labels:
        service: site
    spec:
      containers:
      - name: aspnetapp
        image: mcr.microsoft.com/dotnet/samples:aspnetapp
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 80
        readinessProbe:
          httpGet:
            path: /
            port: 80
          periodSeconds: 3
          timeoutSeconds: 1

Kubernetes API 参考:

注意

  • 配置了 httpGet 时,支持 readinessProbelivenessProbe
  • 当前不支持对 Pod 上公开的端口以外的端口进行探测。
  • 不支持 HttpHeadersInitialDelaySecondsSuccessThreshold

不使用 readinessProbelivenessProbe

如果未提供上述探测,则入口控制器假设在为 backend-path-prefix 注释指定的 Path 上或在服务的 ingress 定义中指定的 path 上可以访问该服务。

运行状况探测的默认值

对于就绪情况/运行情况探测无法推断的任何属性,将设置默认值。

应用程序网关探测属性 默认值
Path /
Host localhost
Protocol HTTP
Timeout 30
Interval 30
UnhealthyThreshold 3