Build Your Kubernetes Playground on AWS: MicroK8s

VijayaLakshmi Yvl
4 min readNov 19, 2023

--

A Hands-On Guide for Kubernetes and Helm Chart Practice

Introduction: Embarking on the journey of Kubernetes and Helm chart development can be both thrilling and challenging. This comprehensive guide is designed to help you set up your own Kubernetes cluster using AWS, providing a controlled environment for hands-on exploration. The only prerequisite is an AWS free tier account.

Prerequisites:

  1. AWS free tier account
  2. Basic understanding of AWS services

Step 1: Launch an EC2 Instance Initiate the process by launching an EC2 instance, which will serve as the foundation for your Kubernetes cluster. Follow these straightforward steps:

  • Log in to your AWS Management Console.
  • Navigate to the EC2 Dashboard.
  • Click on “Launch Instance” and select the “Ubuntu” Amazon Machine Image (AMI).
  • Choose the “t2.medium” instance type for optimal performance.
  • Configure instance details and storage according to your requirements
  • Review your settings and proceed to launch the instance.

Reminder: To prevent incurring charges, kindly ensure to either stop or terminate the AWS EC2 instance upon completion of your hands-on activities. This practice helps maintain cost efficiency by avoiding unnecessary billing for idle resources.

Step 2: Connect to Your EC2 Instance Once your EC2 instance is running, establish an SSH connection:

Step 3: Install Microk8s: Microk8s is a lightweight and easily installable Kubernetes distribution. Execute the following commands to install Microk8s on your EC2 instance:

1. sudo snap install microk8s --classic
2. sudo usermod -a -G microk8s Ubuntu
3. newgrp microk8s

Step4: Now install Kubectl

Kubectl is a command line interphase to interact with the k8s cluster.

use below commands to install Kubectl

1. curl -LO https://dl.k8s.io/release/v1.28.4/bin/linux/amd64/kubectl
2. sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
3. kubectl version --client

Step5: To make kubectl interact with Microk8s cluster, configure .kube directory

1. cd $HOME
2. mkdir .kube
3. cd .kube
4. microk8s config > config
5. Ls –lart
6. cat config

In this configuration file:
<cluster-name> is the name of your cluster.
<cluster-server-url> is the URL of your Kubernetes API server.
<base64-encoded-ca-cert> is the base64-encoded cluster certificate authority.
<user-name> is the name of the user context.
<base64-encoded-client-cert> is the base64-encoded client certificate.
<base64-encoded-client-key> is the base64-encoded client private key.
<context-name> is the name of the context, combining the cluster and user.
<default-namespace> is the default namespace for the context.

Understanding and modifying this configuration file allows you to manage multiple Kubernetes clusters and switch between them seamlessly using kubectl config use-context <context-name>. It’s a crucial aspect of working with Kubernetes, especially in environments with multiple clusters or users.

MicroK8s Kubernetes cluster setup has been successfully completed.

Step6: Now, let’s verify whether kubectl commands are functioning properly by using the following command.

kubectl get all --all-namespaces

Hurray! The successful execution of this command indicates that we are now able to interact seamlessly with the Kubernetes cluster using kubectl commands. This milestone opens the door to a multitude of possibilities for managing and deploying applications within the Kubernetes environment. The next steps in your Kubernetes journey are ready to unfold. Happy exploring!

🚀Thank you for being a part of this enriching exploration! If you discovered value in this article, be sure to hit the follow button for a continuous stream of insightful content. Subscribe to our updates and show your appreciation with a round of applause (claps)👏 if you enjoyed the read. Your support is invaluable. Stay tuned for more insights! Follow and subscribe vijayalakshmiyvl

--

--

VijayaLakshmi Yvl

DevOps Engineer having Experience with Aws, Ansible, Docker, Kubernetes, Jenkins, Linux, Git, GitHub, Tomcat, Maven, Shell Script, Sonarqube, and Terraform