Last active
March 30, 2022 14:05
-
-
Save vfarcic/70a14c8f15c7ffa533ea7feb75341545 to your computer and use it in GitHub Desktop.
This file contains 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/vfarcic/70a14c8f15c7ffa533ea7feb75341545 | |
###################### | |
# 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/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 | |
################## | |
# 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 | |
################## | |
# Metrics Server # | |
################## | |
helm install stable/metrics-server \ | |
--name 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 | |
############################ | |
# Install Prometheus Chart # | |
############################ | |
PROM_ADDR=mon.$LB_IP.nip.io | |
AM_ADDR=alertmanager.$LB_IP.nip.io | |
helm upgrade -i prometheus \ | |
stable/prometheus \ | |
--namespace metrics \ | |
--version 7.1.3 \ | |
--set server.ingress.hosts={$PROM_ADDR} \ | |
--set alertmanager.ingress.hosts={$AM_ADDR} \ | |
-f mon/prom-values.yml | |
kubectl -n metrics \ | |
rollout status \ | |
deploy prometheus-server | |
####################### | |
# 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