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

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

Per configMap defined labels in configMapGenerator #5724

aschaber1 opened this issue Jun 23, 2024 · 3 comments
Labels
kind/feature Categorizes issue or PR as related to a new feature. kind/support Categorizes issue or PR as a support question. triage/needs-information Indicates an issue needs more information in order to work on it.

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 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

$

@stormqueen1990
Copy link
Member

Hi there, @aschaber1! Could you please check if the solution offered in #5724 (comment) addresses your issue?

/kind support
/triage needs-information

@k8s-ci-robot k8s-ci-robot added kind/support Categorizes issue or PR as a support question. triage/needs-information Indicates an issue needs more information in order to work on it. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Aug 7, 2024
@aschaber1
Copy link
Author

Awesome, works for us :) Thank you for pointing us in the right direction.

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. kind/support Categorizes issue or PR as a support question. triage/needs-information Indicates an issue needs more information in order to work on it.
Projects
None yet
Development

No branches or pull requests

4 participants