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

Make it possible to set node naming convention #1006

Merged
merged 1 commit into from
Dec 17, 2021
Merged

Conversation

olemarkus
Copy link
Contributor

As of k8s 1.23, CCM supports both instance ID (resource name) and private dns (ip name) based naming.
It is not possible for karpenter to determine when which convention is used, and this may also depend on the installer used.
Therefore this is added as a CLI argument.

1. Issue, if available:
Fixes #927

2. Description of changes:
This adds a CLI flag for the node naming convention.
This is AWS specifc, so I added an "AWS" prefix. I think this is the first "global" cloud provider setting, so I was not sure how you wanted to name this.

I think a CLI arg for this is the only way of fixing this issue. Trying to parse k8s version and whether or not the external CCM is used is a bit fragile. It is also not given that the external CCM is the "official" one.

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 16, 2021

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

🔨 Explore the source changes: c1df256

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

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.

This is only supported by the external CCM, right? I'd love to get to a point where Karpenter only runs in ip-name mode.

if injection.GetOptions(ctx).AWSNodeNameConvention == "ip-name" {
nodeName = aws.StringValue(instance.PrivateDnsName)
} else {
nodeName = *instance.InstanceId
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: aws.StringValue() helps us avoid NPEs.

for _, instanceType := range instanceTypes {
if instanceType.Name() == aws.StringValue(instance.InstanceType) {
var nodeName string
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider collapsing to

nodeName := ...
if ... {
  nodeName = ...
}

}

func (o Options) Validate() (err error) {
err = multierr.Append(err, o.validateEndpoint())
if o.ClusterName == "" {
err = multierr.Append(err, fmt.Errorf("CLUSTER_NAME is required"))
}
if o.AWSNodeNameConvention != "ip-name" && o.AWSNodeNameConvention != "resource-name" {
Copy link
Contributor

@ellistarn ellistarn Dec 16, 2021

Choose a reason for hiding this comment

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

Can we default to ip-name, for now? I'd hate for folks to have to pass this flag in all cases.

edit: nvm, you did this in the flag above. 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ip-name is the default when parsing the flags. There shouldn't be a need to set this explicitly when running through main(). At least that was my intention.

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 fix, thank you! I'd love to get us to a point where only resourcename is supported.

@olemarkus olemarkus force-pushed the rbn branch 2 times, most recently from 5b934b5 to f45a0aa Compare December 16, 2021 17:06
ellistarn
ellistarn previously approved these changes Dec 16, 2021
As of k8s 1.23, CCM supports both instance ID (resource name) and private dns (ip name) based naming.
It is not possible for karpenter to determine when which convention is used, and this may also depend on the installer used.
Therefore this is added as a CLI argument

Update pkg/utils/options/options.go

Co-authored-by: Ellis Tarn <[email protected]>
@ellistarn ellistarn merged commit fdb2cca into aws:main Dec 17, 2021
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.

Karpenter creates Node objects with the wrong name
2 participants