Steps to Run Kubernetes on the AWS Cloud Using Minikube Cluster

minicube cluster

 

Before setting up the Kubernetes environment, you must install the Docker: docker-ce:18.06 or above, Kubectl, and Minikube in the cloud instance. Let us see the steps to run the Kubernetes on the AWS cloud with the Minikube cluster.

Step 1: Start an AWS EC2 instance

  • First, go to AWS Management Console > Services > EC2.
  • Then Launch Instance.

For the Instance, use the following settings:

  1. Choose an Amazon Machine Image (AMI) and select Ubuntu Server 18.04 LTS (HVM), SSD Volume Type.
  2. Choose the Instance type as t2.medium

Change the instance type from t2.micro (1 vCPU) to t2.medium (2 vCPU). A minimum of 2 vCPUs are required for Minikube. An error will occur while running with t2.micro:

Requested cpu count 1 is less than the minimum allowed of 2

Ensure to stop or terminate the instance once you’ve finished testing to avoid a huge AWS fee because t2.medium is no longer in the Free Tier.

  1. Add Storage – Size: 10GiB
  2. Add Tags – Key and Value: Name and minikube-instance
  3. In Configure Security Group, Create a new security group.

Name: minikube-sg

Type: All traffic & Source: Custom 0.0.0.0/0

  1. Finally, Review and Launch > Choose either an existing key pair or create a new pair > Launch Instances.

Step 2: Create EC2 Instance using your keypair

SSH into your newly created EC2 instance from your local Terminal using your keypair.

$ ssh -i [keypair] ubuntu@[Instance Public IP]

Step 3: Install kubectl

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

Step 4: Install Docker

Minikube requires a Container Engine. So, Docker is used in this case.

sudo apt-get update && \

sudo apt-get install docker.io -y

 Step 5: Install Minikube

curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/

Step 6: Check Minikube Version

$ minikube version

Conntrack must be installed in the root’s path for Kubernetes v1.20.0. So, let us install Conntrack.

$ sudo apt install conntrack

After the installation process, test the minikube.

Step 7: Run Minikube on EC2 Ubuntu

Run the command as a Root user.

sudo -i

In case you are unable to run the command as root then always add sudo before the command minikube and kubectl.

Start the Minikube

$ minikube start --vm-driver=none

$ minikube status

Run the first container

$ kubectl run hello-minikube 

--image=gcr.io/google_containers/echoserver:1.4 --port=8080

Now expose the container port so that we can access it and locate port 8080 in the container exposed in the EC2 Instance port.

$ kubectl expose pod hello-minikube --type=NodePort

$ kubectl get svc

Note: Port 32233 is the EC2 Instance Port that exposes the container’s port 8080.

Whenever you expose the port, the EC2 instance port changes and your value may differ. The command kubectl get svc – the list of services and their exposed ports. Let us check by using a web browser on your computer.

Using a web browser, navigate the container’s EC2 Instance Port.

The address is: [Public IP]:32233

Step 8: Dashboard Minikube

To access the Minikube Dashboard, create an SSH tunnel.

$ minikube dashboard –url

Now open another local terminal and create an SSH Tunnel.

$ ssh -i [private key.pem] -L [local port]:localhost:[remote port of minikube dashboard] ubuntu@[public ip]

$ ssh -i .\aws-arth-key.pem -L 8081:localhost:46233 ubuntu@15.207.16.144

Open this URL in the browser

http://127.0.0.1:8081/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/#/error?namespace=_all

We have successfully run Kubernetes on the AWS Cloud using the Minikube Cluster.

Also, check: How to fix Linux Error 111: Connection Refused

To get more updates you can follow us on Facebook, Twitter, LinkedIn

Subscribe to get free blog content to your Inbox
Loading

Written by actsupp-r0cks