0% found this document useful (0 votes)
52 views

Setup Kubernetes (K8s) Cluster On AWS: #Sudo Apt-Get Install Unzip - If You Dont Have Unzip in Your System

The document provides steps to setup a Kubernetes cluster on AWS including: 1. Installing necessary tools like AWSCLI, kubectl, and kops on an Ubuntu EC2 instance 2. Creating an IAM role and S3 bucket for the cluster 3. Generating SSH keys and using kops to create the cluster configuration in the S3 bucket 4. Updating the cluster to launch it on AWS It then demonstrates deploying an Nginx container to the cluster and exposing it via an ELB.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views

Setup Kubernetes (K8s) Cluster On AWS: #Sudo Apt-Get Install Unzip - If You Dont Have Unzip in Your System

The document provides steps to setup a Kubernetes cluster on AWS including: 1. Installing necessary tools like AWSCLI, kubectl, and kops on an Ubuntu EC2 instance 2. Creating an IAM role and S3 bucket for the cluster 3. Generating SSH keys and using kops to create the cluster configuration in the S3 bucket 4. Updating the cluster to launch it on AWS It then demonstrates deploying an Nginx container to the cluster and exposing it via an ELB.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Setup Kubernetes (K8s) Cluster on AWS

1. Create Ubuntu EC2 instance

2. install AWSCLI

3. curl https://s3.amazonaws.com/aws-cli/awscli-bundle.zip -o awscli-


bundle.zip
4. apt install unzip python
5. unzip awscli-bundle.zip
6. #sudo apt-get install unzip - if you dont have unzip in your system
./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws

7. Install kubectl

8. curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl


-s https://storage.googleapis.com/kubernetes-
release/release/stable.txt)/bin/linux/amd64/kubectl
9. chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl

10. Create an IAM user/role with Route53, EC2, IAM and S3 full access

11. Attach IAM role to ubuntu server

Note: If you create IAM user with programmatic access then provide Access keys.

aws configure

12. Install kops on ubuntu instance:

13. 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
14. chmod +x kops-linux-amd64
sudo mv kops-linux-amd64 /usr/local/bin/kops

15. Create a Route53 private hosted zone (you can create Public hosted zone if you have a
domain)

16. create an S3 bucket

aws s3 mb s3://dev.k8s.valaxy.in

17. Expose environment variable:

export KOPS_STATE_STORE=s3://dev.k8s.valaxy.in

18. Create sshkeys before creating cluster

ssh-keygen

19. Create kubernetes cluster definitions on S3 bucket


kops create cluster --cloud=aws --zones=ap-southeast-1b
--name=dev.k8s.valaxy.in --dns-zone=valaxy.in --dns private

20. Create kubernetes cluser

kops update cluster dev.k8s.valaxy.in --yes

21. Validate your cluster

kops validate cluster

22. To list nodes

kubectl get nodes

Deploying Nginx container on Kubernetes

1. Deploying Nginx Container

2. kubectl run sample-nginx --image=nginx --replicas=2 --port=80


3. kubectl get pods
kubectl get deployments

4. Expose the deployment as service. This will create an ELB in front of those 2 containers
and allow us to publicly access them:

5. kubectl expose deployment sample-nginx --port=80 --type=LoadBalancer


kubectl get services -o wide

6. To delete cluster

kops delete cluster dev.k8s.valaxy.in --yes

You might also like