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

Allow the charm to set extra-labels it wishes to manage not set by user #13

Merged
merged 1 commit into from
Jan 8, 2025

Conversation

addyess
Copy link
Member

@addyess addyess commented Dec 19, 2024

Overview

User config via juju can add node labels but failed to be able to intentionally remove labels
These changes allow the charm to specify labels ending with "-" to remove those labels

Details

  • creates an option to raise an exceptions when invalid labels are detected
  • allows for labels whose values endswith "-" to be removed (the label key will be removed entirely)

EG)
a node has labels not applied by the charm like this:

Name:               juju-ecc100-1
Roles:              <none>
Labels:             beta.kubernetes.io/arch=amd64
                    beta.kubernetes.io/os=linux
                    hostname=juju-ecc100-1
                    unwanted-label-is-here=any-value
                    juju-application=k8s
                    juju-charm=k8s
                    juju.io/cloud=vsphere
                    kubernetes.io/arch=amd64
                    kubernetes.io/hostname=juju-ecc100-1
                    kubernetes.io/os=linux

by applying this config, the charm should be able to intentionally remove this label

juju config label-maker-charm label-config="unwanted-label-is-here=-"

Copy link

@louiseschmidtgen louiseschmidtgen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Adam!
Have we thought about any alternative implementations, maybe a charm action to remove the label?
I feel like the UX could be a little bit better.
Excuse my ideas if this was already discussed :)

@addyess
Copy link
Member Author

addyess commented Jan 8, 2025

I'm all ears @louiseschmidtgen. I do like that it's one config item to rule them all and it works very similarly to the way you apply labels with kubectl.

if you want to remove a node label using kubectl one simply:

kubectl label node <nodename> <label>-

and to add it back

kubectl label node <nodename> <label>=<value>

@louiseschmidtgen
Copy link

I see your point.
A charm action would also not translate so well into the terraform world. With the config you can change the terraform plan.

Copy link

@louiseschmidtgen louiseschmidtgen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@addyess addyess merged commit e35bbe0 into main Jan 8, 2025
7 checks passed
@addyess addyess deleted the KU-2391/charm-ownership-of-node-role-labels branch January 8, 2025 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants