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 kOps to set labels required for cluster operations #999

Merged
merged 2 commits into from
Dec 16, 2021

Conversation

olemarkus
Copy link
Contributor

1. Issue, if available:

*2. Description of changes:
kOps require two labels set on Nodes: kops.k8s.io/instancegroup and kops.k8s.io/gpu.
The latter is especially important as any pod using the nvidia runtimeclass will get that label as nodeSelector.

To make this more future proof, I allowed the entire kops.k8s.io domain as there will not be a case where these labels are restricted from Karpenters point of view.

3. Does this change impact docs?

  • Yes, PR includes docs updates
  • Yes, issue opened: link to issue
  • No

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@netlify
Copy link

netlify bot commented Dec 15, 2021

✔️ Deploy Preview for karpenter-docs-prod canceled.

🔨 Explore the source changes: 5039ef5

🔍 Inspect the deploy log: https://app.netlify.com/sites/karpenter-docs-prod/deploys/61bb96526b500f000882c0a6

Copy link
Contributor

@ellistarn ellistarn left a comment

Choose a reason for hiding this comment

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

Does the kubelet allow these labels to be set?

@@ -90,6 +90,9 @@ func (c *Constraints) validateLabels() (errs *apis.FieldError) {

func IsRestrictedLabelDomain(key string) bool {
labelDomain := getLabelDomain(key)
if labelDomain == "kops.k8s.io" {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you implement something similar to RestrictedLabelDomains (e.g. AllowedLabelDomains) and generalize this bit of code?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That I can.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Take a look if this is better now.

@olemarkus
Copy link
Contributor Author

No. As far as I know, the entire k8s.io domain is banned, including subdomains. But these labels make no sense to set on kubelet, and kOps does not support setting labels as kubelet arguments. So for these we should be fine.

@olemarkus olemarkus force-pushed the relax-labels branch 2 times, most recently from 2a718bd to cfcf6e5 Compare December 15, 2021 19:15
@ellistarn
Copy link
Contributor

No. As far as I know, the entire k8s.io domain is banned, including subdomains. But these labels make no sense to set on kubelet, and kOps does not support setting labels as kubelet arguments. So for these we should be fine.

Currently we pass all labels to the kubelet. This is to avoid an issue where if karpenter crashes right after launching the instance, but doesn't get a chance to create the node, the labels will still be applied.

I can potentially see moving away from applying all labels in the kubelet args and instead moving towards a model where

  1. The karpenter.sh/provisioner-name is set in kubelet args (for safety)
  2. All labels are created/patched onto the node by Karpenter

Currently, karpenter only does this with a create call, but during periods of high congestion (e.g. fast node boot and kubeclient throttling), we could support this with a mechanism like CreateOrPatch.

Copy link
Contributor

@ellistarn ellistarn left a comment

Choose a reason for hiding this comment

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

Change LGTM other than the LT generation bit I pointed out.

@olemarkus
Copy link
Contributor Author

As mentioned on Slack, restricted labels should never be set by components other than those who own the respective keys. That is why they are restricted.

For now, I suggest filtering out allowed labels in the launch template. It is a very curious edge case where EKS users would set flags that are owned by kOps, so I think the risk here is very low.

}
nodeLabelArgs.WriteString(strings.Join(labelStrings, ","))
Copy link
Contributor

Choose a reason for hiding this comment

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

Thoughts on simplifying to:

fmt.Sprintf("--node-labels=%s", strings.Join(labelStrings, ","))

ellistarn
ellistarn previously approved these changes Dec 16, 2021
Copy link
Contributor

@ellistarn ellistarn left a comment

Choose a reason for hiding this comment

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

Nice work!

@ellistarn ellistarn merged commit 0113a91 into aws:main Dec 16, 2021
@Tyler887
Copy link
Contributor

No. As far as I know, the entire k8s.io domain is banned, including subdomains. But these labels make no sense to set on kubelet, and kOps does not support setting labels as kubelet arguments. So for these we should be fine.

Wrong. It moved to another domain, as I checked the thing and it took me somewhere else. Try going into it and you should be redirected to another domain.

@olemarkus
Copy link
Contributor Author

@Tyler887 I suspect you are not talking about label domains/prefixes here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants