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

add node-name-strategy option #419

Merged
merged 2 commits into from
Jan 20, 2024
Merged

Conversation

Issacwww
Copy link
Contributor

@Issacwww Issacwww commented Jan 19, 2024

Issue #, if available:

Description of changes:
Add support for AL2023 self managed node group to have EC2Instance Based Name

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

Testing

Tested with AL2 AMI

kubetest2-eksapi --kubernetes-version=1.28 --up --unmanaged-nodes --ami ami-0c63d30c477bc4cc2 --node-name-strategy=EC2PrivateDNSName --nodes=1

k get nodes
NAME                                           STATUS   ROLES    AGE     VERSION
ip-192-168-36-81.us-west-2.compute.internal    Ready    <none>   8m54s   v1.28.5-eks-5e0fdde

Tested with self build AL2023 1.28 AMI, along with this change

kubetest2-eksapi --kubernetes-version=1.28 --up --user-data-format=nodeadm --unmanaged-nodes --ami ami-0b41e47dab79e8cea --node-name-strategy=SessionName --nodes=1

k get nodes
NAME                  STATUS   ROLES    AGE     VERSION
i-00e37501896aa8468   Ready    <none>   4m39s   v1.28.5-eks-5e0fdde

@@ -69,6 +71,7 @@ type deployerOptions struct {
KubernetesVersion string `flag:"kubernetes-version" desc:"cluster Kubernetes version"`
NodeReadyTimeout time.Duration `flag:"node-ready-timeout" desc:"Time to wait for all nodes to become ready"`
Nodes int `flag:"nodes" desc:"number of nodes to launch in cluster"`
OsDistro string `flag:"os-distro" desc:"Specifies the OS distribution for the AMI. Allowed values: ['al2', 'al2023'] (case-insensitive)"`
Copy link
Member

Choose a reason for hiding this comment

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

Can we make this option a little more targeted to this specific behavior, something like --node-name-strategy?

We'll eventually have to add --ami-type to test with MNG, but that concept doesn't mean anything for an unmanaged nodegroup.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean we need to decouple the behaviors from the os-distro? Option like naming strategy would allow use cases like AL2 + SessionName and AL2023 + PrivateDNSName. Although we can control it via pipeline, is there any other user will use it in that way?

Copy link
Member

Choose a reason for hiding this comment

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

Option like naming strategy would allow use cases like AL2 + SessionName and AL2023 + PrivateDNSName.

Yeah exactly. When we add support for AL2023 managed node groups, this tool will need an option for --ami-type, and we will set --node-name-strategy based on that value; but for unmanaged nodes, the AMI may use bootstrap.sh, nodeadm, or something else entirely. I want to avoid making too many assumptions about feature sets here, and just expose the individual options. Our higher level test framework that uses this tool can centralize all the details of which AMI's support which feature, how to test a given AMI, etc.

Comment on lines 104 to 111
return fmt.Sprintf(`
- username: system:node:{{%s}}
groups:
- system:bootstrappers
- system:nodes
rolearn: `
rolearn: `, nodeNameFlavor)

}
Copy link
Member

Choose a reason for hiding this comment

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

I think we should use a proper go template for this, since we're filling in 2 values now. Examples in the deployers/eksapi/templates package

"strings"
)

func IsStringInSlice(a string, list []string) bool {
Copy link
Member

Choose a reason for hiding this comment

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

I think the stdlib has something like this now: https://pkg.go.dev/slices

@Issacwww Issacwww changed the title dynamically generate AuthMapRole aginst os distro add node-name-strategy option Jan 20, 2024
@cartermckinnon cartermckinnon merged commit c281778 into aws:main Jan 20, 2024
2 checks passed
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.

2 participants