Empty ConfigMap used in container environment variables

You can use ConfigMaps as values for container environment variables. This validator detects when a ConfigMap used as a source for environment variables is empty. Because of that, no environment variables will be sources from the ConfigMap.

Affected Resources: Deployment, DaemonSet, StatefulSet, CronJob, Job, ReplicaSet, Pod

Examples

kind: Deployment spec: template: spec: containers: - name: my-container envFrom: - configMapRef: name: my-config-map # This ConfigMap is empty
kind: ConfigMap metadata: name: my-config-map data: {} # Empty data or no data at all

Resolution

  • Populate data in the ConfigMap so it is mapped as environment variables.
  • Delete the empty ConfigMap if indeed no environment variables are supposed to be sourced from that ConfigMap.
  • Resolution Examples

    kind: ConfigMap metadata: name: my-config-map data: ENV_FOO: bar
    $ kubectl delete configmap my-config-map -n

    Need other validation rules?

    Please let us know if there are other built-in validation rules you would like to see in Kubevious to detect misconfigurations and violations to best practices. Optionally, you can provide your details so we can reach out to you with follow-up questions.

    Share this article on:
    message