Create Kubernetes cluster on EKS

I know a lot of people out there have become fan of k8s and so Iam. Recently I deployed my personal project on EKS. I prefer to choose gitlab for ci-cd because as it is widely said — ‘Gitlab is the future of devops’. So lets begin with the first part.
First we need to create an EKS cluster. Earlier I preferred using kops to create that but here we are going to use eksctl — amazon’s own k8s command line tool since there are some extra steps of manual work that needs to be done using kops like explicitly creating a S3 bucket.
Prerequisites — You need to own a AWS account
- Navigate to IAM services in AWS console after logging in and create a user. Give it a programmatic access only. Store safe your ACCESS_KEY_ID and SECRET_ACCESS_KEY.
- In your local machine install aws-cli. In awscliv1 you needed to install python to download it. But latest awscliv2 doesnt have any requisites and u can install it with these 3 simple commands.
a) curl “https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o “awscliv2.zip”
b) unzip awscliv2.zip
c) sudo ./aws/install
d) aws — version
3. Now configure aws account in your local machine. Just type aws configure
and it will ask for ACCESS_KEY_ID and SECRET_ACCESS_KEY. Input the values you stored in step 1 and leave rest configuration options to default.
4. test the user by typing aws sts get-caller-identity
OR aws iam list-users
You should see your latest configurations in output
5. Next you will have to install eksctl — Elastic kubernetes service’s command line tool that manages eks cluster
For Linux users
a) curl — silent — location “https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_$(uname -s)_amd64.tar.gz” | tar xz -C /tmp
b) sudo mv /tmp/eksctl /usr/local/bin
c) eksctl version
For MacOs
a) brew install weaveworks/tap/eksctl
6. Next type a simple eksctl command to create a cluster on AWS.
a) eksctl create cluster — name=my-eks-cluster
to create cluster, eksctl command uses your aws user that you configured in step 3. Ideally I would suggest to export a variable on your machine named CLUSTER
and we will using that variable to create a cluster, since going forward we will need cluster name repeatedly.
a) export CLUSTER=my-cluster
b) eksctl create cluster — name=${CLUSTER} This will create a cluster with default configurations or either you can create a yaml file as below and run the command `eksctl create cluster -f cluster.yaml`
#cluster.yamlapiVersion: eksctl.io/v1alpha5
kind: ClusterConfigmetadata:
name: taskmanager-cluster
region: ap-southeast-1nodeGroups:
- name: ng-1
instanceType: t2.small
desiredCapacity: 1
ssh:
allow: true
Voila! Within 10–15 minutes your eks cluster will up and ready.
In next part we will create a simple k8s project locally and configure this cluster in gitlab to automate the ci-cd process.