1

I am trying to use wget in my liveness probe in Kubernetes. Here is the code:

apiVersion: v1
kind: Pod
metadata:
  namespace: test
  labels:
    test: liveness
  name: liveness-exec
spec:
  containers:
  - name: busybox
    image: busybox
    command:
      - sleep
      - "99999999"
    livenessProbe:
      exec:
        command:
        - wget
        - -O- 
        - --header=
        - "DD-APPLICATION-KEY: abcde"
        - --header= 
        - "DD-API-KEY: a123456"
        - https://api.datadoghq.com/api/v1/monitor/1234567 | grep \"overall_state\":\"OK\"
      initialDelaySeconds: 10
      periodSeconds: 10

But I am facing the following error when I use describe command in the pod:

Liveness probe failed: wget: bad port ' abcde'

My goal is to check an alert in Datadog. If the alert is red the pod will restart.

The wget command works in the terminal. It looks like the YAML file is facing some problems using the headers.

2 Answers2

1

Remove the equal sign from the --header= and use --header instead

        command:
        - wget
        - -O-
        - --header
        - "DD-APPLICATION-KEY: abcde"
        - --header
        - "DD-API-KEY: a123456"
        - https://api.datadoghq.com/api/v1/monitor/1234567
        - -q
      initialDelaySeconds: 10
      periodSeconds: 10

Note that using wget in a liveness probe can cause unnecessary load on the system. Instead, it's recommended to use a more lightweight command like curl or nc to check the health of your application. See this link

0

I suppose this is the simple way to rewrite this:

        command:
        - /bin/sh
        - -c
        - 'wget -O- ...'