<p>I am trying to pass livenessProbe in my kubernetes deployment yaml file to perform the health of my application. so, I created a secret with token value and passing as below</p>

<pre><code>      livenessProbe:
        httpGet:
          path: test/actuator/health
          port: 9001
          httpHeaders:
          - name: Authorization
            valueFrom:
              secretKeyRef:
                name: actuator-token
                value: token
</code></pre>

<p>but I am getting the below error</p>

<p><code>error: error validating "deployment.yaml": error validating data: [ValidationError(Deployment.spec.template.spec.containers[0].livenessProbe.httpGet.httpHeaders[0]): unknown field "valueFrom" in io.k8s.api.core.v1.HTTPHeader, ValidationError(Deployment.spec.template.spec.containers[0].livenessProbe.httpGet.httpHeaders[0]): missing required field "value" in io.k8s.api.core.v1.HTTPHeader, ValidationError(Deployment.spec.template.spec.containers[0].readinessProbe.httpGet.httpHeaders): invalid type for io.k8s.api.core.v1.HTTPGetAction.httpHeaders: got "map", expected "array"]; if you choose to ignore these errors, turn validation off with --validate=false</code></p>

<p>Kindly suggest and appreciate for the help.</p>

<p>Also let us know is their any better way of handling tokens as I don't want to provide token value directly on my deployment yaml file.</p>

magic
<p>Not sure that @DT answer gonna work, there no documentation for that feature.</p>

<p>Also I made some tests and the example below not working for me:</p>

<pre><code>spec:
  containers:
  - name: mycontainer
    image: myimage
    env:
      - name: TOKEN
        value: '12345'
    livenessProbe:
      httpGet:
        path: /v1/health
        port: 80
        httpHeaders:
        - name: Authorization
          value: Apikey $TOKEN
</code></pre>

<p>I'm getting 401 for my application because it can't substitute env variable for header value. I even tried many other options with single/double quotes, with brackets, none of them working.</p>

<p>Otherwise, you can use <code>exec</code> instead of <code>httpGet</code>, but it requires to have curl installed in your docker image.</p>

<pre><code>spec:
  containers:
  - name: mycontainer
    image: myimage
    env:
      - name: TOKEN
        value: '12345'
    livenessProbe:
      exec:
        command:
        - bash
        - -c
        - 'curl --fail http://localhost/v1/health --header "Authorization: Apikey $TOKEN"'
    initialDelaySeconds: 30
    periodSeconds: 15
</code></pre>

<p>If you want to use <code>valueFrom</code> from your secret you don't need to decode variable inside a container. I will be already decoded.</p>

<p>In case you can't add curl package to your image, better to consider writing custom script based on language your application developed. Here is example for js:
<a href="https://blog.sixeyed.com/docker-healthchecks-why-not-to-use-curl-or-iwr/" rel="noreferrer">https://blog.sixeyed.com/docker-healthchecks-why-not-to-use-curl-or-iwr/</a></p>

<p>Also, check this question, there a similar answer <a href="https://stackoverflow.com/questions/33484942/how-to-use-basic-authentication-in-a-http-liveness-probe-in-kubernetes">How to use basic authentication in a HTTP liveness probe in Kubernetes?</a></p>
