Skip to content

Instantly share code, notes, and snippets.

@ericbisme
Last active December 14, 2023 18:53
Show Gist options
  • Save ericbisme/82013337ef86be6d6491730cac93906a to your computer and use it in GitHub Desktop.
Save ericbisme/82013337ef86be6d6491730cac93906a to your computer and use it in GitHub Desktop.
# Cordon nodes of a particular version
k cordon $(k get nodes --no-headers | awk 'BEGIN { ORS=" " }; $5 == "v1.15.11-eks-14f01f" {print $1}' )
# Cordon nodes older than 10 days
kubectl cordon $(kubectl get no --no-headers -o go-template --template '{{range .items}}{{.metadata.name}} {{.metadata.creationTimestamp}}{{"\n"}}{{end}}' | awk 'BEGIN { ORS=" " }; $2 <= "'$(date -u -v -10d +%Y-%m-%dT%H:%M:%SZ)'" { print $1 }')
# View of autoscaling groups in a table
aws autoscaling describe-auto-scaling-groups --output table --query "AutoScalingGroups[? Tags[? (Key=='k8s.io/cluster/XXXX') && Value=='owned']]".'[AutoScalingGroupName,DesiredCapacity]'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment