Implementing Readiness and Liveness probe in Azure AKS

1/17/2020

I am trying to follow this documentation to enable readiness and liveness probe on my pods for health checkes in my cluster, however it gives me an error where connection refused to the container IP and port. Portion where i have added the readiness and liveness is below.

I am using helm for deployment and the port i am trying to monitor is 80. The service file for ingress is also given below.

https://docs.microsoft.com/en-us/azure/application-gateway/ingress-controller-add-health-probes

Service.yaml

apiVersion: v1
kind: Service
metadata:
name: expose-portal 
annotations:
service.beta.kubernetes.io/azure-load-balancer-internal: "{{ .Values.isInternal }}"
spec:
type: LoadBalancer
ports:
- port: 80
selector:
app: portal

Deployment.yaml

    spec:
  containers:
  - name: App-server-portal
    image: myacr-app-image-:{{ .Values.image_tag }}
    imagePullPolicy: Always      
    ports:
    - name: http
      containerPort: 80
      protocol: TCP
    readinessProbe:
      httpGet:
        path: /
        port: 80
      periodSeconds: 3
      timeoutSeconds: 1
    livenessProbe:
      httpGet:
        path: /
        port: 80
      periodSeconds: 3
      timeoutSeconds: 1
    volumeMounts:
    - mountPath: /etc/nginx
      readOnly: true
      name: mynewsite
  imagePullSecrets:
  - name: my-secret
  volumes:
  - name: mynewsite.conf
    configMap:
      name: mynewsite.conf
      items:
      - key: mynewsite.conf
        path: mynewsite.conf

Am i doing something wrong here. As per azure documentation as of today Probing on a port other than the one exposed on the pod is currently not supported. My understanding is that port 80 on my pod is already exposed.

-- Vaishnav
azure
azure-aks
azure-kubernetes
kubernetes-helm
kubernetes-ingress

1 Answer

1/22/2020

taken from the docs:

  1. initialDelaySeconds: Number of seconds after the container has started before liveness or readiness probes are initiated. Defaults to 0 seconds. Minimum value is 0.
  2. periodSeconds: How often (in seconds) to perform the probe. Default to 10 seconds. Minimum value is 1.
  3. timeoutSeconds: Number of seconds after which the probe times out. Defaults to 1 second. Minimum value is 1.

https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#configure-probes

The solution was to increase timeout.

PS. I think you might need to introduce initialDelaySeconds instead of increasing timeout to 3 minutes

-- 4c74356b41
Source: StackOverflow