Open arianvp opened 3 years ago
Hi, I would like to see instance-id
as a label as well.
meanwhile, you can find instance-id
in spec.providerID
of the node resource
spec.providerId
looks like this aws:///eu-west-1a/i-01adxxxxxxxxxd
you may have to do some string magics to retrieve the instance id
I forget where I got this from, but for EKS managed node groups, we accomplished getting this label using preBootstrapCommands
:
managedNodeGroups:
...
preBootstrapCommands:
- sed -i '/^KUBELET_EXTRA_ARGS=/a KUBELET_EXTRA_ARGS+=" --node-labels=instance=\$(curl\ http://169.254.169.254/latest/meta-data/instance-id)"' /etc/eks/bootstrap.sh
2/19/24 Update: Anyone know of an equivalent way to do this in Karpenter's NodeClass:
apiVersion: karpenter.k8s.aws/v1beta1
kind: EC2NodeClass
...
spec:
userData: |
#!/bin/bash
sed -i '/^KUBELET_EXTRA_ARGS=/a KUBELET_EXTRA_ARGS+=" --node-labels=instance-id=\$(curl\ http://169.254.169.254/latest/meta-data/instance-id)"' /etc/eks/bootstrap.sh
Community Note
Tell us about your request I want nodes to have a label
eks.amazonaws.com/instance-id=<id>
addedWhich service(s) is this request for? EKS
Tell us about the problem you're trying to solve. What are you trying to do, and why is it hard? When I have scheduled event alerts in AWS, I get the instance-id of the affected node. I then want to run
kubectl get node -leks.amazonws.com/instance-id=$instanceId
to quickly find out what kubernetes node is affected and e.g. drain it.Are you currently working around this issue? I have the following script:
Which I call like this:
Additional context Anything else we should know?
Attachments If you think you might have additional information that you'd like to include via an attachment, please do - we'll take a look. (Remember to remove any personally-identifiable information.)