Setup Kubernetes Cluster on AWS using KOPS
Setup Route53
- Register free domain from Freenom, please refer this link
- Create a Public Hosted in Route 53, please refer this link
- Update NameServers in Freenom DNS Management control panel, please refer this link
Create Ubuntu EC2 instance
For installing kops we are creating this Ubuntu EC2 instance
- Use the below the button to create EC2 instance along with necessary roles needed for this installation
- Once your instance is created login into it using private key
- Username: Ubuntu
Install AWS CLI
You will need to install on AWS CLI on Ubuntu this we created, login to that instance and follow below steps
- Download AWS CLI package using:
curl https://s3.amazonaws.com/aws-cli/awscli-bundle.zip -o awscli-bundle.zip
- Install unzip & python packages using:
apt install unzip python
- Unzip AWS CLI bundle using:
unzip awscli-bundle.zip
- Copy AWS CLI package using:
./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws
Install kubectl
- Download kubectl using:
curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
- Give permission to kubectl package using:
chmod +x ./kubectl
- Copy kubectl using:
sudo mv ./kubectl /usr/local/bin/kubectl
Install kops
- Download kubectl using:
curl -LO https://github.com/kubernetes/kops/releases/download/$(curl -s https://api.github.com/repos/kubernetes/kops/releases/latest | grep tag_name | cut -d '"' -f 4)/kops-linux-amd64
- Give permission to kubectl package using:
chmod +x kops-linux-amd64
- Copy kubectl using:
sudo mv kops-linux-amd64 /usr/local/bin/kops
- Create an S3 bucket using:
aws s3 mb s3://<enter-unique-name>
- Expose environment variable:
export KOPS_STATE_STORE=s3://<enter-unique-name>
- Create SSH keys before creating cluster using:
ssh-keygen
- Create kubernetes cluster definitions on S3 bucket:
kops create cluster --cloud=aws --zones=us-east-1a --name=<your-cluster-name> --dns-zone=<your-freenom-domain> --dns public --node-size=t2.micro --master-size=t2.micro
- Create kubernetes cluser:
kops update cluster <your-cluster-name> --yes
- Validate your cluster
kops validate cluster
- To list nodes
kubectl get nodes