Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Define a livenessProbe with secret httpHeaders

I want to define a livenessProbe with an httpHeader whose value is secret.

This syntax is invalid:

livenessProbe:
  httpGet:
    path: /healthz
    port: 8080
    httpHeaders:
      - name: X-Custom-Header
        valueFrom:
          secretKeyRef:
            name: my-secret-key
            value: secret

If I specify my-secret-key with value secret as an environment variable named MY_SECRET_KEY, the following could work:

livenessProbe:
  exec:
    command:
      - curl
      - --fail
      - -H
      - "X-Custom-Header: $MY_SECRET_KEY"
      - 'http://localhost:8080/healthz'

Unfortunately it doesn't due to the way the quotations are being evaluated. If I type the command curl --fail -H "X-Custom-Header: $MY_SECRET_KEY" http://localhost:8080/healthz directly on the container, it works.

I've also tried many combinations of single quotes and escaping the double quotes.

Does anyone know of a workaround?

like image 430
Jenna Quindica Avatar asked Jan 21 '17 00:01

Jenna Quindica


1 Answers

Here some examples with curl and wget:

exec:
command:
  - /bin/sh
  - -c
  - "curl -H 'Authorization: Bearer $(AUTH_TOKEN)' 'http://example.com'"

exec:
  command:
  - /bin/sh
  - -c
  - "wget --spider --header \"Authorization: Bearer $AUTH_TOKEN\" http://some.api.com/spaces/${SPACE_ID}/entries"
like image 97
debiasej Avatar answered Oct 04 '22 01:10

debiasej