-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
added: support for adding labels from the config file itself #1926
added: support for adding labels from the config file itself #1926
Conversation
Hi @yashvardhan-kukreja. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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/test-infra repository. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: yashvardhan-kukreja The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
d5a0a38
to
b7cf15a
Compare
b7cf15a
to
54fa55b
Compare
Why wouldn't we have kubelet apply these? |
Labels can be added to control plane nodes as well right in the config file. Also, here, in the code, the labels are being created as a post-cluster-creation step where all the control-plane and worker nodes are being labelled together with the same function/logic. Hence, kubectl seemed the cleaner and more straightforward approach to implement the label creation. That's my perspective @BenTheElder , what do you think |
Huh? All of the nodes run kubelet and are registered. The labels are attached to the node at registration time by kubelet. The control-plane kubelet registers as well ...
kind is not a general command runner and we already have a (bad) abstraction for various stages of doing things. |
Ohh alright. My bad. Will hop into implementing with kubelet. |
@BenTheElder , just a small thought. The cluster creation is happening through kubeadm in the code. And that's why , the code is not executing any kubelet commands directly while creating the cluster. (kubeadm cli is doing that, behind the scenes). Wouldn't that be messy or at least rough to implement? Just a thought. Please correct me if I am wrong. |
Also, I don't know if there's anyway to do labelling of nodes via kubeadm but still, say, if there's a way to do so. Then, we would have to code the labelling of nodes at two places. One in the But in my approach in the current PR, it's all happening in one place in the |
I hope that makes sense. |
No, it would be done via the kubeadm config, by adjusting kubelet options. |
pkg/cluster/internal/create/actions/postcreationconfiguration/postcreationconfiguration.go
Outdated
Show resolved
Hide resolved
6743f41
to
c8e2546
Compare
c8e2546
to
4b5c1bb
Compare
@BenTheElder I removed all that 'postcreationconfiguration' stuff and coded the addition of labels at the time of node registration via kubeadm's kubeletExtraArgs. |
And I tested it with the following configuration and it's working perfectly fine: kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
labels:
name: sample-controller
age: 2
- role: control-plane
labels:
name: sample-controller-2
index: 3
- role: worker
labels:
name: sample-worker
worker-age: 3
- role: worker
- role: worker Output
|
@BenTheElder @neolit123 @krzyzacy Please review this PR |
sorry all time is currently consumed on bug-fixes (or non kind related work, none of the maintainers work full time on kind), with some small bits of time granted to documentation (which helps save everyone's time). features and releases are on hold, in particular #1969 needs to be resolved. I will get to this ASAP, but I need to prioritize these still. EDIT: previously I was personally unavailable for a bit for any work for personal reasons, since I've been back I've been resolving those. |
Regarding this, this has already received an lgtm from Lubomir :)
Sure @BenTheElder . No worries. Please take your time. |
sorry for the incredibly long delay. I am closing out our backlog prior to #2120 and since the last release we've expanded the maintainer group to help avoid this. I'd still like to move this to v1alpha5, but as that doesn't exist yet, merging as v1alpha4. if we get v1alpha5 ready in time for 1.21, we'll migrate this over. if not we'll just leave it as a v1alpha4 addition. thank you for working on this. |
@yashvardhan-kukreja: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. 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/test-infra repository. I understand the commands that are listed here. |
This feature was introduced with kubernetes-sigs#1926
Some node labels in the config file (such as node-role.kubernetes.io/worker) cause |
closes #1574
My approach:
So, the labelling of the nodes is going to be one of the actions (
actionsToRun
) when cluster creation happens in the code.Now, I have not coded a dedicated action for "just the labelling of nodes".
I have rather created a file
postcreationconfiguration.go
which will consist of all the functions which are supposed to occur after the cluster gets created. (like labelling in our case)And in the file
postcreationconfiguration.go
, I have written alabelNodes
function which will label the nodes from the config file.Why did I do it?
Because, say, in the future, there is another requirement like adding taints or tolerations (or some other configuration, which usually in real life are done after cluster is created) through the config file itself.
Then, we can write functions for those things in the
postcreationconfigurations.go
itself instead of creating dedicated actions for them. That's because these things like adding taints or tolerations are usually done after the cluster is already created.What's happening behind the scenes?
So, basically, at every iteration, if the labels are being applied to a control-plane node, then, that control-plane-node itself will self-apply those labels to itself.
But if the labels are being applied to a worker node, then, one of the control plane nodes will apply those labels to that worker node.
Usage from user's side:
Output: (Look over the end of every labels row)