By using AWS re:Post, you agree to the Terms of Use

How to get node information using sdk

0

https://docs.aws.amazon.com/sdk-for-go/api/service/eks/

i 'd like to get node instance information. but I cannot find any.

eks has only nodegroup information, not node.

how to get instance id of node or instance information? not kubectl, not eksctl. I want to use golang api

asked 2 months ago32 views
1 Answer
0

kubectl get nodes <NODE_NAME> -oyaml returns information about the node that includes the EC2 instance ID:

apiVersion: v1
kind: Node
metadata:
  annotations:
    node.alpha.kubernetes.io/ttl: "0"
    volumes.kubernetes.io/controller-managed-attach-detach: "true"
  labels:
    alpha.eksctl.io/cluster-name: <CLUSTER_NAME>
    alpha.eksctl.io/nodegroup-name: <NODEGROUP_NAME>
    beta.kubernetes.io/arch: amd64
    beta.kubernetes.io/instance-type: m5.large
    beta.kubernetes.io/os: linux
    eks.amazonaws.com/capacityType: ON_DEMAND
    eks.amazonaws.com/nodegroup: <NODEGROUP_NAME>
    eks.amazonaws.com/nodegroup-image: <AMI_ID>
    eks.amazonaws.com/sourceLaunchTemplateId: <LAUNCH_TEMPLATE_ID>
    eks.amazonaws.com/sourceLaunchTemplateVersion: "1"
    failure-domain.beta.kubernetes.io/region: <REGION>
    failure-domain.beta.kubernetes.io/zone: <AVAILABILITY_ZONE>
    k8s.io/cloud-provider-aws: <ID>
    kubernetes.io/arch: amd64
    kubernetes.io/hostname: <HOST_NAME>
    kubernetes.io/os: linux
    node.kubernetes.io/instance-type: m5.large
    topology.kubernetes.io/region: <REGION>
    topology.kubernetes.io/zone: <AVAILABILITY_ZONE>
  name: <HOST_NAME>
spec:
  providerID: aws:///<AZ>/<EC2_INSTANCE_ID>

The spec.providerID gives you the AWS AZ and the EC2 instance ID. With those items, you could use the SDK to look up additional instance info.

profile picture
answered 2 months ago
  • Thank you for your reply but, I want to use golang api. not kubectl. I couldn't find any api. It seem "getNode" function does not exist.

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.

Guidelines for Answering Questions