How i use EKS in dev

I would like to share the notes how i build EKS cluster for development needs.

 

  1. I created shell script to deploy cluster via eksctl tool.
REGION=eu-west-1
VERSION=1.19
NODES=0
TYPE=t2.large

eksctl create cluster --version=$VERSION --name=inqud-dev-cluster --nodes=$NODES --region=$REGION --node-type $TYPE --node-labels="lifecycle=OnDemand" --asg-access

in above scenario i created 0 nodes, because i’m going to use spot nodes with the cheapest price.

2. Create nodegroup with the spot nodes

eksctl create nodegroup -f dev-spot-nodegroup.yml

#manifest
apiVersion: eksctl.io/v1alpha5
kind: ClusterConfig
metadata:
  name: dev-cluster
  region: eu-west-1
nodeGroups:
  - name: spot-dev-node-group
    minSize: 3
    maxSize: 5
    desiredCapacity: 3
    instancesDistribution:
      instanceTypes: ["t2.medium"]
      onDemandBaseCapacity: 0
      onDemandPercentageAboveBaseCapacity: 0
      spotAllocationStrategy: "capacity-optimized"
    labels:
      lifecycle: Ec2Spot
    iam:
      withAddonPolicies:
        autoScaler: true

#check:
kubectl get nodes --show-labels --selector=lifecycle=Ec2Spot

3. Install AWS Node Termination handler. It give us ability to gracefully

Details by link: https://github.com/aws/aws-node-termination-handler/

kubectl apply -f https://github.com/aws/aws-node-termination-handler/releases/download/v1.12.0/all-resources.yaml

#check. you should daemons on each node
kubectl get daemonsets --all-namespaces

4. Then we need to install autoscaler to be able to automatically add new nodes into the cluster:

Details by link: https://github.com/kubernetes/autoscaler

#download script
curl -LO https://raw.githubusercontent.com/kubernetes/autoscaler/master/cluster-autoscaler/cloudprovider/aws/examples/cluster-autoscaler-multi-asg.yaml

#find nodegroup name
eksctl get nodegroup spot-dev-node-group --cluster dev-cluster -o json | jq '.[0].AutoScalingGroupName' | xargs

#edit nodegroup and run
kubectl apply -f cluster-autoscaler-multi-asg.yaml

5. Install and run network load balancer:

kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v0.44.0/deploy/static/provider/aws/deploy.yaml

6. install let’s encrypt service to be able to use dynamic https endpoints:

https://amsone.tech.blog/2021/02/09/https-in-kubernetes/

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Design a site like this with WordPress.com
Get started