Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kustomize build . command should be able to detect when an env variable is not defined in configmap #5861

Open
2 tasks done
psshri-suki opened this issue Feb 14, 2025 · 1 comment
Labels
kind/feature Categorizes issue or PR as related to a new feature. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one.

Comments

@psshri-suki
Copy link

Eschewed features

  • This issue is not requesting templating, unstuctured edits, build-time side-effects from args or env vars, or any other eschewed feature.

What would you like to have added?

If we have following file in a directory:
deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: dummy-deployment
spec:
  replicas: 2
  selector:
    matchLabels:
      app: dummy-deployment
  template:
    metadata:
      name: dummy-deployment
      labels:
        app: dummy-deployment
    spec:
      containers:
      - name: dummy-deployment
        resources:
        image: "gcr.io/dummy-project/dummy-service-tag"
        ports:
        - containerPort: 10001
        env:
        - name: ENV_VAR_1
          valueFrom:  
            configMapKeyRef: 
              name: dummy-configmap
              key: ENV_VAR_1
        - name: ENV_VAR_2
          valueFrom:  
            configMapKeyRef: 
              name: dummy-configmap
              key: ENV_VAR_2

kustomization.yaml

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: dummy-namespace
configMapGenerator:
- name: dummy-configmap
  literals:
  - ENV_VAR_1=VALUE
resources:
  - deployment.yaml

And if we run the command kustomize build . within the directory, we will get the following output:

apiVersion: v1
data:
  ENV_VAR_1: VALUE
kind: ConfigMap
metadata:
  name: dummy-configmap-8bkghbm66f
  namespace: dummy-namespace
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: dummy-deployment
  namespace: dummy-namespace
spec:
  replicas: 2
  selector:
    matchLabels:
      app: dummy-deployment
  template:
    metadata:
      labels:
        app: dummy-deployment
      name: dummy-deployment
    spec:
      containers:
      - env:
        - name: ENV_VAR_1
          valueFrom:
            configMapKeyRef:
              key: ENV_VAR_1
              name: dummy-configmap-8bkghbm66f
        - name: ENV_VAR_2
          valueFrom:
            configMapKeyRef:
              key: ENV_VAR_2
              name: dummy-configmap-8bkghbm66f
        image: gcr.io/dummy-project/dummy-service-tag
        name: dummy-deployment
        ports:
        - containerPort: 10001
        resources: null

When in fact, the kustomization.yaml file is missing a key ENV_VAR_2 from the configmap definition. It would be great to have a feature in which kustomize build could check whether a environment variable is missing in the configmap definition.

Why is this needed?

We have GitHub workflows that runs kustomize build . command for each PR and if the build fails then the workflow will fail. In the scenarios like above, we do not get any kustomize build failure. If we have such a feature, then it will help teams to identify missing environment variables from configmap.

Can you accomplish the motivating task without this feature, and if so, how?

NA

What other solutions have you considered?

NA

Anything else we should know?

No response

Feature ownership

  • I am interested in contributing this feature myself! 🎉
@psshri-suki psshri-suki added the kind/feature Categorizes issue or PR as related to a new feature. label Feb 14, 2025
@k8s-ci-robot
Copy link
Contributor

This issue is currently awaiting triage.

SIG CLI takes a lead on issue triage for this repo, but any Kubernetes member can accept issues by applying the triage/accepted label.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Feb 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one.
Projects
None yet
Development

No branches or pull requests

2 participants