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

yhnoh
demandé il y a 2 ans212 vues
1 réponse
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 pictureAWS
répondu il y a 2 ans
  • 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.

Vous n'êtes pas connecté. Se connecter pour publier une réponse.

Une bonne réponse répond clairement à la question, contient des commentaires constructifs et encourage le développement professionnel de la personne qui pose la question.

Instructions pour répondre aux questions