Last active
October 7, 2023 03:22
-
-
Save vfarcic/0ce1ccdd862f401bbacf56d3ca18b808 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Source: https://gist.github.com/0ce1ccdd862f401bbacf56d3ca18b808 | |
###################### | |
# 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-max 9 \ | |
--nodes-min 3 \ | |
--asg-access \ | |
--managed | |
export KUBECONFIG=$PWD/cluster/kubecfg-eks | |
################### | |
# Install Ingress # | |
################### | |
kubectl apply \ | |
-f https://raw.githubusercontent.com/kubernetes/ingress-nginx/1cd17cd12c98563407ad03812aebac46ca4442f2/deploy/mandatory.yaml | |
kubectl apply \ | |
-f https://raw.githubusercontent.com/kubernetes/ingress-nginx/1cd17cd12c98563407ad03812aebac46ca4442f2/deploy/provider/aws/service-l4.yaml | |
kubectl apply \ | |
-f https://raw.githubusercontent.com/kubernetes/ingress-nginx/1cd17cd12c98563407ad03812aebac46ca4442f2/deploy/provider/aws/patch-configmap-l4.yaml | |
################## | |
# Metrics Server # | |
################## | |
kubectl create namespace metrics | |
helm install metrics-server \ | |
stable/metrics-server \ | |
--version 2.0.2 \ | |
--namespace metrics | |
kubectl -n metrics \ | |
rollout status \ | |
deployment metrics-server | |
################## | |
# 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 | |
eksctl delete cluster -n devops25 | |
SG_NAME=$(aws ec2 describe-security-groups \ | |
--filters Name=group-name,Values=k8s-elb-$LB_NAME \ | |
| jq -r ".SecurityGroups[0].GroupId") | |
echo $SG_NAME | |
aws ec2 delete-security-group \ | |
--group-id $SG_NAME |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment