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
gefragt vor 2 Jahren212 Aufrufe
1 Antwort
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
beantwortet vor 2 Jahren
  • 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.

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen