Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How can I make sure my health checks work in kubernetes?

I’m currently trying to add health checks into my API through my helm chart. However, when I run this service under kubernetes it seems that my pod is ready but I have 0/1 Running and when I try to hit the URL for the service is not returning anything.

This is how my deployment looks:


apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ include "test.fullname" . }}
  labels:
    app.kubernetes.io/name: {{ include "test.name" . }}
    helm.sh/chart: {{ include "test.chart" . }}
    app.kubernetes.io/instance: {{ .Release.Name }}
    app.kubernetes.io/managed-by: {{ .Release.Service }}
spec:
  replicas: {{ .Values.replicaCount }}
  selector:
    matchLabels:
      app.kubernetes.io/name: {{ include "test.name" . }}
      app.kubernetes.io/instance: {{ .Release.Name }}
  template:
    metadata:
      labels:
        app.kubernetes.io/name: {{ include "test.name" . }}
        app.kubernetes.io/instance: {{ .Release.Name }}
    spec:
      containers:
        - name: {{ .Chart.Name }}
          image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
          imagePullPolicy: {{ .Values.image.pullPolicy }}

          readinessProbe:
                httpGet:
                  path: /health
                  port: 80001
                initialDelaySeconds: 60
                periodSeconds: 60

          livenessProbe:
              httpGet:
                path: /health
                port: 80001
              initialDelaySeconds: 60
              periodSeconds: 60
  
          startupProbe:
            httpGet:
              path: /health
              port: 80001
            failureThreshold: 60
            periodSeconds: 60

          env:
              {{- range .Values.variables }}
              - name: {{ .name }}
                value: {{ .value }}
              {{- end }} 
          ports:
            - name: http
              containerPort: 80001
              protocol: TCP

If I delete the health checks, I will have 1/1 Running. Does anyone knows if I have to add something else to the health checks?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Your healthcheck specification looks syntactically fine.
But your port number seems wrong: The maximum possible TCP port is 65535, you specify 80001. Probably a zero too many?

Verify which port your application is listening to in the container and use that port.

You can verify it by running the app as local docker container and call the health check with curl.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading