<p>I am trying to apply below deployment, but I get below error</p>

<p>The Deployment "example" is invalid: spec.template.spec.containers[0].env[0].valueFrom.fieldRef.fieldPath: Invalid value: "spec.template.metadata.annotations.configHash": error converting fieldPath: field label not supported: spec.template.metadata.annotations.configHash</p>

<p>I have tried different ways of accessing the fieldPath like:</p>

<pre><code>spec.template.metadata.annotations['configHash']
spec.template.metadata.['annotations'].['configHash']
spec.template.metadata.['annotations'['configHash']]
</code></pre>

<p>Nothing seems to work . Any help will be appreciated.</p>

<p>Kubernetes - 1.16.8-gke.15</p>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: ecc-web
  labels:
    app: ecc
spec:
  replicas: 1
  selector:
    matchLabels:
      app: ecc
  template:
    metadata:
      labels:
        app: ecc
      annotations:
        configHash: b6651e50d35182bd8fc2f75a5af4aca79387079860fb953896399a1ad16e317d
    spec:
      volumes:
      - name: opt-ecc-logs
        emptyDir: {}
      securityContext:
        fsGroup: 1000
      containers:
      - name: ecc-web
        image: gcr.io/gke-nonprod/ecc:release-11
        envFrom:
        - configMapRef:
            name: env-config
        env:
          - name: CONFIG_HASH
            valueFrom:
              fieldRef:
               fieldPath: spec.template.metadata.annotations.configHash
          - name: DB_PASSWORD
            valueFrom:
              secretKeyRef:
                name: ecc-secret
                key: mysql_svcacct_ecc_dev_password
        ports:
        - containerPort: 80
        imagePullPolicy: Always
        securityContext:
          privileged: true
        volumeMounts:
        - name: opt-ecc-logs
          mountPath: /opt/ecc/logs
      - name: application-log
        image: busybox
        command: ["/bin/sh","-c"]
        args: ["touch /opt/ecc/logs/application.log;chown -R wsapp:wsapp /opt/ecc/logs/;tail -n+1 -f /opt/ecc/logs/application.log"]
        securityContext:
          runAsUser: 1000
          runAsGroup: 1000
        volumeMounts:
        - name: opt-ecc-logs
          mountPath: /opt/ecc/logs
</code></pre>

<p>Just use:</p>

<pre><code>env:
  - name: CONFIG_HASH
    valueFrom:
      fieldRef:
        fieldPath: metadata.annotations['configHash']
</code></pre>

<p>Instead of spec.template.metadata.annotations.configHash</p>
