Configuring liveness and readiness probes for Kubernetes Deployment

Hello, just wondering if anyone has tried configuring liveness and readiness probes for Kubernetes Deployment?

I noticed that when I run the following command from the LMS or CMS pods:

curl -I http://localhost:8000/heartbeat

I get a 400 status code error.

Here’s my initial configuration:

          # Liveness Probe (check if the service is alive)
          livenessProbe:
            httpGet:
              path: /heartbeat
              port: 8000
            initialDelaySeconds: 30
            periodSeconds: 10
            timeoutSeconds: 5
            failureThreshold: 3
          # Readiness Probe (check if the service is ready to receive traffic)
          readinessProbe:
            httpGet:
              path: /heartbeat
              port: 8000
            initialDelaySeconds: 30
            periodSeconds: 10
            timeoutSeconds: 5
            failureThreshold: 3

Any advise will be appreciated. Thanks!

The 400 error is because the ALLOWED_HOSTS forbids requests using localhost as a hostname. You should include the header Host: lms or Host: cms

You can add the header to the probe:

          livenessProbe:
            httpGet:
              httpHeaders:
                - name: Host
                  value: lms
              path: /heartbeat
              port: 8000

Or you can edit your ALLOWED_HOSTS setting.

Thanks! That was helpful.