Skip to content

Conversation

@youwalther65
Copy link
Contributor

@youwalther65 youwalther65 commented Oct 1, 2025

This PR includes settings.kubernetes.hostname-override-source in BottlerocketConfig struct to allow resource-based K8s node naming with just the EC2 instance ID.

It uses a yet undocumented Bottlerocket feature, see Bottlerocket issue Add documentation for settings.kubernetes.hostname-override-source #547.

Fixes #8548

Description

How was this change tested?
Yes, successfully tested using:
Prerequisites:

  • cluster acess entry of type EC2 for Karpenter node role
    Note: This is important to successfuly register K8s node object by kubelet
$ aws eks create-access-entry --cluster-name karpenter-demo --principal-arn  "arn:aws:iam::<redacted>:role/KarpenterNodeRole-karpenter-demo" --type EC2
{
    "accessEntry": {
        "clusterName": "karpenter-demo",
        "principalArn": "arn:aws:iam::<redacted>:role/KarpenterNodeRole-karpenter-demo",
        "kubernetesGroups": [
            "system:nodes"
        ],
        "accessEntryArn": "arn:aws:eks:eu-west-1:<redacted>:access-entry/karpenter-demo/role/<redacted>/KarpenterNodeRole-karpenter-demo/8accfbff-<redacted>",
        "createdAt": "2025-10-18T17:44:55.758000+02:00",
        "modifiedAt": "2025-10-18T17:44:55.758000+02:00",
        "tags": {},
        "username": "system:node:{{SessionName}}",
        "type": "EC2"
    }
}
  • EC2NodeClass with the following setting:
$ k get ec2nodeclass default -o yaml
apiVersion: karpenter.k8s.aws/v1
kind: EC2NodeClass
metadata:
...
  finalizers:
  - karpenter.k8s.aws/termination
...
  name: default
...
spec:
  amiFamily: Bottlerocket
  amiSelectorTerms:
  - id: <redacted>
...
  userData: |
    [settings.kubernetes]
    "hostname-override-source" = "instance-id"
...
  • test deployment to create pods and launch instances

Run patched Karpenter locally with make run, launched instance , SSM into instance and got:

$ k get nodeclaims.karpenter.sh
NAME            TYPE         CAPACITY    ZONE         NODE                  READY   AGE
default-jq2zl   c6a.xlarge   on-demand   eu-west-1a   i-07<redacted>   True    6m25s

$ k get nodes -l=karpenter.sh/initialized=true
NAME                  STATUS   ROLES    AGE    VERSION
i-07<redacted>   Ready    <none>   7m9s   v1.32.8-eks-e386d34

$ aws ssm start-session --target i-07<redacted>
...
[ssm-user@control]$ apiclient get settings.kubernetes.hostname-override-source
{
  "settings": {
    "kubernetes": {
      "hostname-override-source": "instance-id"
    }
  }
}

Does this change impact docs?

  • Yes, PR includes docs updates
  • Yes, issue opened: #
  • No

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

@youwalther65 youwalther65 requested a review from a team as a code owner October 1, 2025 18:45
@netlify
Copy link

netlify bot commented Oct 1, 2025

Deploy Preview for karpenter-docs-prod canceled.

Name Link
🔨 Latest commit be83dba
🔍 Latest deploy log https://app.netlify.com/projects/karpenter-docs-prod/deploys/690d8d654e238400082af656

@DerekFrank
Copy link
Contributor

Thanks for the PR! I'm not sure I specifically understand the usecase. Could you include an example of how and why someone would use this new setting? I'm trying to find out why someone one want to configure this, or if we should just set it by default instead

Also if theres a better documentation link than https://bottlerocket.dev/en/os/1.44.x/api/settings/kubernetes/ that'd be nice to include in the description. I can't find the setting this is referring to specifically.

@youwalther65
Copy link
Contributor Author

youwalther65 commented Oct 2, 2025

@DerekFrank Unfortunately the Bottlerocket are currently missing this parameter, already addressed it.
Setting it as a default does not work, because just using this will break node registration, other prerequisites are required as well.
The idea is, that using instance-id as a value gives you a unique K8s node name based on EC2 instance ID, rather then having the private DNS name including trailing domain name as K8s node name.
There are some advantages using instance-id I described in the corresponding issue 8548 and extended the reason behind this request in more detail!

@DerekFrank
Copy link
Contributor

Synced with the team, looks like we're willing to accept this change but you'll have to update the branch :)

@youwalther65
Copy link
Contributor Author

Synced with the team, looks like we're willing to accept this change but you'll have to update the branch :)

Done.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 29, 2025

Preview deployment ready!

Preview URL: https://pr-8549.d18coufmbnnaag.amplifyapp.com

Built from commit 9191f38489a295b7d3a9951ea42c68704cff9c05

@coveralls
Copy link

Pull Request Test Coverage Report for Build 18919770533

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.1%) to 67.586%

Totals Coverage Status
Change from base Build 18858441218: 0.1%
Covered Lines: 7794
Relevant Lines: 11532

💛 - Coveralls

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.

Add Bottlerocket "settings.kubernetes.hostname-override-source" to allows resource-based-naming (RBN) just on EC2 instance ID

3 participants