AWS Kubernetes Cluster Checkouts | Bash Script

Overview

Perform checkouts against your AWS Kubernetes cluster before and after implementing changes such as upgrades by using my latest Bash shell script! I took my AKS checkouts script from a couple of weeks ago and converted it into an EKS checkouts script 😎

This script performs the following tasks:

✅ Sets the kubeconfig context based on the provided cluster name (names must match)

✅ Display addresses of the master and services

✅ Checks the k8's version running on both the control plane and the nodes

✅ Checks supported EKS versions

✅ Lists all nodes and their status, age and version

✅ Display custom columns for pods with node, pod, namespace, status, and age

✅ Output count for total # pods running

✅ Gets all pods in the cluster, loops through each and runs a verbose describe outputting values from Node to Status

Link to the script: https://github.com/jksprattler/kubernetes/blob/main/eks/scripts/eks-checkouts.sh

Usage & Sample Output

The script output can be useful during instances where you need to submit a vendor ticket for troubleshooting. I'll also be including the output in my internal ticket tracking upgrades to validate it was completed.

Here's some sanitized sample output with redactions for brevity from running the script:

❯ ./eks-checkouts.sh --help
Usage: ./eks-checkouts.sh <cluster-name> <region> <aws-profile>

❯ ./eks-checkouts.sh my-cluster my-region my-profile
Switched to context "my-cluster".
########################################################
Kubernetes control plane is running at https://my-cluster.gr7.my-region.eks.amazonaws.com
CoreDNS is running at https://my-cluster.gr7.my-region.eks.amazonaws.com/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
########################################################
Control Plane Version: 
Client Version: v1.23.6
Server Version: v1.23.17-eks-0a21954
########################################################
Cluster Version: v1.23.16-eks-48e63af
Cluster Status: ACTIVE
########################################################
Available EKS versions:
1.22
1.23
1.24
1.25
1.26
1.27
########################################################
NAME                                         STATUS   ROLES    AGE   VERSION
ip-my-node.my-region.compute.internal   Ready    <none>   73d   v1.23.16-eks-48e63af
ip-my-node.my-region.compute.internal   Ready    <none>   73d   v1.23.16-eks-48e63af
#### Redacted for brevity ####
########################################################
NODE                                         POD                                             NAMESPACE      STATUS    AGE
ip-my-node.my-region.compute.internal   aws-node-zs123                                  kube-system    Running   2023-03-24T18:35:15Z
#### Redacted for brevity ####
########################################################
Total number of pods running:      163
########################################################
Checking pod: cert-manager/cert-manager-12345678-45svg
Node:         ip-my-node.my-region.compute.internal/ip-my-node
Start Time:   Thu, 16 Mar 2023 06:25:19 -0500
Labels:       app=cert-manager
              app.kubernetes.io/component=controller
              app.kubernetes.io/instance=cert-manager
              app.kubernetes.io/name=cert-manager
              app.kubernetes.io/version=v1.8.2
              pod-template-hash=12345678
Annotations:  kubernetes.io/psp: eks.privileged
              prometheus.io/path: /metrics
              prometheus.io/port: 9090
              prometheus.io/scrape: true
Status:       Running
########################################################
#### Redacted for brevity ####

Since I'm performing upgrades to my EKS clusters this week, I decided to put this script together and share it! Enjoy!