Skip to content

Instantly share code, notes, and snippets.

@initcron
Last active May 30, 2024 03:56
Show Gist options
  • Save initcron/5a79a8aa4feaec86b185a47fbcedefd9 to your computer and use it in GitHub Desktop.
Save initcron/5a79a8aa4feaec86b185a47fbcedefd9 to your computer and use it in GitHub Desktop.
Day 3 - Recreating EKS Cluster

Start by creating the cluster from the path where cluster.yaml is

eksctl create cluster -f cluster.yaml --without-nodegroup

once created, launch the node group as

eksctl create nodegroup -f cluster.yaml --include=ng-2-workers

deploy instavote app

kubectl create namespace instavote 
kubectl config set-context --current --namespace=instavote
kubectl apply -f vote-svc.yaml -f vote-deploy.yaml -f redis-svc.yaml -f redis-deploy.yaml -f worker-deploy.yaml -f db-deploy.yaml -f db-svc.yaml -f result-svc.yaml -f result-deploy.yaml
kubectl apply -f vote-ing.yaml

set up visualizer

from the path where kube-ops-view directoy is cloned earlier,

kubectl apply -f kube-ops-view/deploy/

Also edit the cluster security group from ec2 instances, to open range 30000-32767 of ports for NodePort access.

create IAM Service Account with

eksctl create iamserviceaccount \
  --cluster=eks-cluster-01 \
  --namespace=kube-system \
  --name=aws-load-balancer-controller \
  --role-name AmazonEKSLoadBalancerControllerRole \
  --attach-policy-arn=arn:aws:iam::xxxxxxxx:policy/AWSLoadBalancerControllerIAMPolicy \
  --approve 

where replace xxxxxxxx with actual ARN of AWSLoadBalancerControllerIAMPolicy

set up Load Balancer Controller (LBC) as

helm install aws-load-balancer-controller eks/aws-load-balancer-controller \
  -n kube-system \
  --set clusterName=eks-cluster-01 \
  --set serviceAccount.create=false \
  --set replicaCount=1 \
  --set serviceAccount.name=aws-load-balancer-controller

Find out the Application Load Balancer created from EC2 console, find out its ip address

e.g.

nslookup k8s-instavot-vote-xxxxxxxxx.elb.amazonaws.com

and update /etc/hosts or equivalent file with the updated ip address.

Once done, you should be able to browse to vote.example.com and result.example.com.

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