Query EKS node information with Python Boto3 or AWS CLI
I've been trying to pull the container runtime programmatically with the AWS CLI or Boto3, but haven't been able to find a specific class or method that provides the information I'm looking for. The information I'm looking for is documented here on line item number 4.: https://docs.aws.amazon.com/eks/latest/userguide/view-nodes.html
I've searched through the EKS client class in boto3 documentation and haven't found anything that would get more granular than using describe_cluster() and into the node details: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/eks.html
As far as infrastructure goes, I followed the exact example from the AWS documentation for setting up EKS with fargate nodes: https://docs.aws.amazon.com/eks/latest/userguide/getting-started-console.html
I can see on the nodes page that it includes all the information I'm looking for, but I'm not sure what class would provide me that information programmatically.
The intent is to pull container runtimes across all EKS clusters from multiple AWS accounts.
Thanks!
With an EKS cluster, you can gather information in the EKS level or in the Kubernetes level. In the EKS level, you can use eksctl
tool or the Boto EKS Client, but at this level, you can only look into cluster/nodegroup information. What you want is node information. So you have to query at Kubernetes level. You could use kubectl tool to create your query. For example:
# list all nodes in the cluster with their labels
kubectl get nodes --show-labels
# list all nodes in a specific nodegroup
kubectl get node --selector='eks.amazonaws.com/nodegroup=x86-br-spot-xl'
If you want to do this in Python, you could use Kubernetes Python Client.
from kubernetes import client, config
# Configs can be set in Configuration class directly or using helper utility
config.load_kube_config()
k8s_api = client.CoreV1Api()
logger.info("Getting k8s nodes...")
response = k8s_api.list_node()
You should look into Kubernetes documentation on how to get all the info you want with kubectl and then translate it later to Python.
Relevant questions
Amazon Athena query history report
Accepted Answerasked 2 years agoAmazon SageMaker Local Mode raised boto3.exceptions.RetriesExceededError: Max Retries Exceeded
asked 5 months agoFiltered List in AWS console
asked 2 months agoQuery EKS node information with Python Boto3 or AWS CLI
Accepted Answerasked a month agoHow to get the enable / disable of the trigger set in lambda with boto3.
asked 2 years agoboto3 1.9.212 not able to create channel ChannelClass not setting up
asked 3 years agoHow to set Log Retention Expire to Log Group by boto3 or AWS CLI?
asked 2 years agologging options in boto3 set_stream_logger
Accepted Answerasked 4 months agoProvisioning a Wireless gateway with LoRaWAN control plane API in shell script
asked 4 months agoRoute53 reporting with command line
Accepted Answerasked 4 months ago
This makes sense. I was hoping I would be able to query it from the AWS console as it is in there to view.
I'll deep dive into using kubectl and see what I can do.
Thanks!