Skip to content

Node Name for Karpenter Managed Nodes.

0

I have an although generic but time sensitive development question,

  • The node name of a karpenter provisioned node gets a default name like this 'ip-100-64-48-241.eu-central-1.compute.internal'
  • I want to change that to give a node name like this <project-name><application-name>-<env name>-<cluster-version >
  • Amazon Q suggests I reference it as label - "eks.amazonaws.com/nodegroup-name: "vfde-utiq-bbx-prod-eks", directly under the spec section of the nodepool.

But there is no concept of nodegroups within karpenter so how will it interpret it

asked 2 years ago1.6K views

3 Answers
0

You're correct that Karpenter doesn't use the concept of node groups like traditional EKS managed node groups. The suggestion to use "eks.amazonaws.com/nodegroup-name" as a label wouldn't work as expected with Karpenter.

To customize the node names for Karpenter-provisioned nodes, you'll need to use Karpenter's own naming conventions and configuration options. Karpenter allows you to specify a custom naming pattern for the EC2 instances it creates, which in turn affects the node names in Kubernetes.

You can achieve this by modifying the Karpenter Provisioner (or NodePool in newer versions) configuration. In the Provisioner/NodePool spec, you can use the "aws" section to define a custom naming pattern. Here's an example of how you might structure it:

spec:
  aws:
    tags:
      Name: "{{.Project}}-{{.Application}}-{{.Environment}}-{{.ClusterVersion}}-{{.InstanceID}}"

In this pattern, you would replace the placeholders (like {{.Project}}, {{.Application}}, etc.) with actual values or references to labels/annotations that Karpenter can interpret.

Keep in mind that the exact node name in Kubernetes might still include some AWS-specific information (like the IP address and region), but the EC2 instance name will follow your specified pattern. This approach allows you to have more meaningful and project-specific names for your Karpenter-managed nodes while still working within Karpenter's architecture.

Remember to test this configuration in a non-production environment first to ensure it works as expected with your specific setup and requirements.
Sources
EKS Node Scaling with Karpenter | AWS re:Post
Karpenter - Amazon EKS

answered 2 years ago

0

I use tag to name the instances

apiVersion: karpenter.k8s.aws/v1
kind: EC2NodeClass
...
  tags:
    Name: my-karpenter-node

answered 2 years ago

0

I think you can use something like this

apiVersion: karpenter.sh/v1alpha5
kind: Provisioner
metadata:
  name: default
spec:
  # ...existing code...
  requirements:
    - key: "karpenter.sh/capacity-type"
      operator: In
      values: ["spot", "on-demand"]
  provider:
    # ...existing code...
    kubeletConfiguration:
      kubeletExtraArgs:
        hostname-override: "<project-name><application-name>-<env-name>-<cluster-version>"
  # ...existing code...

Ensure that the values you use for hostnam-override are unique and valid DNS names

EXPERT

answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.