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

Per configMap defined labels in configMapGenerator #5724

Open
1 of 2 tasks
aschaber1 opened this issue Jun 23, 2024 · 2 comments
Open
1 of 2 tasks

Per configMap defined labels in configMapGenerator #5724

aschaber1 opened this issue Jun 23, 2024 · 2 comments
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

@aschaber1
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?

I'd like to set labels on a configMap level and not only on a generatorOptions level, which causes all configMaps to have these labels.

Why is this needed?

I'd like to use this to add configMaps containing Grafana Dashboards. These need a label: grafana_dashboard: 1.
But I don't want this on all configMaps I'm generating with this kustomization. For instance I regularly create a configMap for Flux' Helm values.yaml. This configMap should not have that label.

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

Yes, by manually generating configMaps like this and adding the result to the resources:

kubectl create configmap --dry-run=client -o yaml --from-file 13768_rev4.json grafana-dashboard > grafana-dashboard.yaml

What other solutions have you considered?

Above manual configmap solution.

Anything else we should know?

Here's an example of how it could look:

configMapGenerator:
  - name: grafana-dashboard-13768
    labels:
      grafana_dashboard: "1"
    files:
      - grafana_dashboard.json=13768_rev4.json

Feature ownership

  • I am interested in contributing this feature myself! 🎉
@aschaber1 aschaber1 added the kind/feature Categorizes issue or PR as related to a new feature. label Jun 23, 2024
@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 Jun 23, 2024
@ephesused
Copy link
Contributor

This feature is available via options, which basically is a per-generator generatorOptions:

kustomization.yaml

configMapGenerator:
- name: grafana-dashboard-has-label
  options:
    labels:
      grafana_dashboard: "1"
  literals:
  - key=value
- name: other-configmap-lacks-label
  literals:
  - other-key=other-value
$ kustomize build .
apiVersion: v1
data:
  key: value
kind: ConfigMap
metadata:
  labels:
    grafana_dashboard: "1"
  name: grafana-dashboard-has-label-t757gk2bmf
---
apiVersion: v1
data:
  other-key: other-value
kind: ConfigMap
metadata:
  name: other-configmap-lacks-label-t8297hht97

$

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

3 participants