'getting error "Invalid value" when trying to use secret value in flux Kustomization patchesStrategicMerge

I am getting the error

dry-run failed, reason: Invalid, error: Deployment.apps "server" is invalid: spec.template.spec.containers[0].env[0].valueFrom: Invalid value:
"": may not be specified when `value` is not empty

when trying to override a value in flux Kustomization using patchesStrategicMerge like:

  env:
  - name: DATABASE_URL
    valueFrom:
      secretKeyRef:
        name: server-db-url
        key: dburl

The secret server-db-url exists and contains the key dburl

I am not sure if this has something to do with https://github.com/kubernetes/kubernetes/issues/46861



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source