Skip to content

Instantly share code, notes, and snippets.

@prageethw
Forked from vfarcic/eks-scale.sh
Last active November 29, 2018 10:11
Show Gist options
  • Save prageethw/02053e401046f38f926c5128c75fb5ce to your computer and use it in GitHub Desktop.
Save prageethw/02053e401046f38f926c5128c75fb5ce to your computer and use it in GitHub Desktop.
######################
# Create The Cluster #
######################
# Make sure that you're using eksctl v0.1.5+.
# Follow the instructions from https://github.com/weaveworks/eksctl to intall eksctl.
export AWS_ACCESS_KEY_ID=[...] # Replace [...] with AWS access key ID
export AWS_SECRET_ACCESS_KEY=[...] # Replace [...] with AWS secret access key
export AWS_DEFAULT_REGION=us-west-2
export NAME=devops25
mkdir -p cluster
eksctl create cluster \
-n $NAME \
-r $AWS_DEFAULT_REGION \
--kubeconfig cluster/kubecfg-eks \
--node-type t2.small \
--nodes 3 \
--nodes-max 9 \
--nodes-min 3
export KUBECONFIG=$PWD/cluster/kubecfg-eks
###################
# Install Ingress #
###################
kubectl apply \
-f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/mandatory.yaml
kubectl apply \
-f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/provider/aws/service-l4.yaml
kubectl apply \
-f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/provider/aws/patch-configmap-l4.yaml
##################
# Install Tiller #
##################
kubectl create \
-f https://raw.githubusercontent.com/vfarcic/k8s-specs/master/helm/tiller-rbac.yml \
--record --save-config
helm init --service-account tiller
kubectl -n kube-system \
rollout status deploy tiller-deploy
##################
# Get Cluster IP #
##################
LB_HOST=$(kubectl -n ingress-nginx \
get svc ingress-nginx \
-o jsonpath="{.status.loadBalancer.ingress[0].hostname}")
export LB_IP="$(dig +short $LB_HOST \
| tail -n 1)"
echo $LB_IP
# Repeat the `export` command if the output is empty
#######################
# Destroy the cluster #
#######################
export AWS_DEFAULT_REGION=us-west-2
LB_NAME=$(aws elb \
describe-load-balancers \
| jq -r \
".LoadBalancerDescriptions[0] \
| select(.SourceSecurityGroup.GroupName \
| contains (\"k8s-elb\")) \
.LoadBalancerName")
echo $LB_NAME
aws elb delete-load-balancer \
--load-balancer-name $LB_NAME
eksctl delete cluster -n devops25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment