Skip to content

Instantly share code, notes, and snippets.

@vfarcic
Last active January 18, 2022 00:52
  • Star 0 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save vfarcic/211f8dbe204131f8109f417605dbddd5 to your computer and use it in GitHub Desktop.
# 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
@npsoni88
Copy link

npsoni88 commented May 22, 2020

It appears that the commands are written using helm 2 and is mostly outdated as its easier to just use helm3 and avoid tiller completely.

Also, you may want to "kubectl create ns metrics" before we "helm install stable/metrics-server". Also, in case of "helm3" you would simply use the command "helm install metrics-server stable/metrics-server --version 2.0.2 --namespace metrics" and there's no need for the --name flag.

Additionally, you may want to add "xdg-open" instead of "open", or just as an alternative.

@vfarcic
Copy link
Author

vfarcic commented May 22, 2020

I rewrote the commands in https://gist.github.com/vfarcic/0ce1ccdd862f401bbacf56d3ca18b808 and I thought that I changed the references. I probably missed one (or more). Can you please let me know where you got this link from so that I update it?

@npsoni88
Copy link

I actually got that link from devops 2.5 that i was reading on oreily.

@vfarcic
Copy link
Author

vfarcic commented May 23, 2020

I updated this Gist with the contents of the new one.

The problem is that I cannot upload updated versions of my books to Safari, so they do not include fixes, changes caused by newer releases of software, new chapters, etc. I'm allowed to do that only in LeanPub and Amazon.

If you can send me a private message to viktor @ farcic . com , I'll send you the up-to-date version of the book.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment