Add health probes to your AKS pods

By default, the Application Gateway Ingress Controller (AGIC) provisions an HTTP GET probe for exposed Azure Kubernetes Service (AKS) pods. You can customize the probe properties by adding a readiness or liveness probe to your deployment or pod specification.

Tip

Consider Application Gateway for Containers for your Kubernetes ingress solution. For more information, see Custom health probe for Application Gateway for Containers.

Code for adding a readiness or liveness probe

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

For more information, see the Kubernetes API reference.

Note

  • readinessProbe and livenessProbe are supported when you configure them with httpGet.
  • Probing on a port other than the one exposed on the pod is currently not supported.
  • HttpHeaders, InitialDelaySeconds, and SuccessThreshold aren't supported.

If the code doesn't include a readiness or liveness probe, the ingress controller makes an assumption that the service is reachable on either:

  • The Path value that's specified for backend-path-prefix annotation
  • The path value that's specified in the ingress definition for the service

Default values for the health probe

Any property that the readiness or liveness probe can't infer uses the following default values.

Application Gateway probe property Default value
Path /
Host localhost
Protocol HTTP
Timeout 30
Interval 30
UnhealthyThreshold 3