helm icon indicating copy to clipboard operation
helm copied to clipboard

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

Open hvaandres opened this issue 2 years ago • 1 comments

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: 8001
                initialDelaySeconds: 60
                periodSeconds: 60

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

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

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

hvaandres avatar Sep 21 '22 21:09 hvaandres

Check the kubelet log for the node that the pod is on. That's where the health/readiness checks are logged.

joejulian avatar Sep 22 '22 00:09 joejulian

@joejulian please create a issue in k8s project. Thanks very much.

yxxhero avatar Sep 22 '22 12:09 yxxhero

I assume you meant to tag @hvaandres . 🙂

joejulian avatar Sep 22 '22 13:09 joejulian

@joejulian & @yxxhero It seems that everything started to work now. I did an update on kubernetes and it seems that it fixed the issue. Also, the developers were able to find something wrong with the new end-points that they created for the application itself. So, I believe this now is working as expected

hvaandres avatar Sep 24 '22 19:09 hvaandres