-
Notifications
You must be signed in to change notification settings - Fork 979
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
Conversation
✔️ 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 |
There was a problem hiding this 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.
pkg/cloudprovider/aws/instance.go
Outdated
if injection.GetOptions(ctx).AWSNodeNameConvention == "ip-name" { | ||
nodeName = aws.StringValue(instance.PrivateDnsName) | ||
} else { | ||
nodeName = *instance.InstanceId |
There was a problem hiding this comment.
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.
pkg/cloudprovider/aws/instance.go
Outdated
for _, instanceType := range instanceTypes { | ||
if instanceType.Name() == aws.StringValue(instance.InstanceType) { | ||
var nodeName string |
There was a problem hiding this comment.
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" { |
There was a problem hiding this comment.
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. 👍
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
5b934b5
to
f45a0aa
Compare
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]>
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?
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.