Skip to content

Instantly share code, notes, and snippets.

@vfarcic
Last active January 18, 2022 00:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save vfarcic/a6b2a5132aad6ca05b8ff5033c61a88f to your computer and use it in GitHub Desktop.
Save vfarcic/a6b2a5132aad6ca05b8ff5033c61a88f to your computer and use it in GitHub Desktop.
cd k8s-specs
git pull
# Only if EKS
export NAME=devops25
# Only if EKS
ASG_NAME=$(aws autoscaling \
describe-auto-scaling-groups \
| jq -r ".AutoScalingGroups[] \
| select(.AutoScalingGroupName \
| startswith(\"eksctl-$NAME-nodegroup\")) \
.AutoScalingGroupName")
# Only if EKS
echo $ASG_NAME
# Only if EKS
aws autoscaling \
create-or-update-tags \
--tags \
ResourceId=$ASG_NAME,ResourceType=auto-scaling-group,Key=k8s.io/cluster-autoscaler/enabled,Value=true,PropagateAtLaunch=true \
ResourceId=$ASG_NAME,ResourceType=auto-scaling-group,Key=kubernetes.io/cluster/$NAME,Value=true,PropagateAtLaunch=true
# Only if EKS
IAM_ROLE=$(aws iam list-roles \
| jq -r ".Roles[] \
| select(.RoleName \
| startswith(\"eksctl-$NAME-nodegroup-0-NodeInstanceRole\")) \
.RoleName")
# Only if EKS
echo $IAM_ROLE
# Only if EKS
cat scaling/eks-autoscaling-policy.json
# Only if EKS
aws iam put-role-policy \
--role-name $IAM_ROLE \
--policy-name $NAME-AutoScaling \
--policy-document file://scaling/eks-autoscaling-policy.json
# Only if EKS
helm install stable/cluster-autoscaler \
--name aws-cluster-autoscaler \
--namespace kube-system \
--set autoDiscovery.clusterName=$NAME \
--set awsRegion=$AWS_DEFAULT_REGION \
--set sslCertPath=/etc/kubernetes/pki/ca.crt \
--set rbac.create=true
# Only if EKS
kubectl -n kube-system \
rollout status \
deployment aws-cluster-autoscaler
kubectl get nodes
cat scaling/go-demo-5-many.yml
kubectl apply \
-f scaling/go-demo-5-many.yml \
--record
kubectl -n go-demo-5 get hpa
kubectl -n go-demo-5 get pods
kubectl -n kube-system get cm \
cluster-autoscaler-status \
-o yaml
kubectl -n go-demo-5 \
describe pods \
-l app=api \
| grep cluster-autoscaler
kubectl get nodes
kubectl -n go-demo-5 get pods
kubectl apply \
-f scaling/go-demo-5.yml \
--record
kubectl -n go-demo-5 get hpa
kubectl -n go-demo-5 rollout status \
deployment api
kubectl -n go-demo-5 get pods
kubectl get nodes
kubectl -n kube-system \
get configmap \
cluster-autoscaler-status \
-o yaml
kubectl -n kube-system \
get configmap \
cluster-autoscaler-status \
-o yaml
kubectl get nodes
kubectl delete ns go-demo-5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment