Voiced by Amazon Polly |
Introduction
In today’s cloud-native world, Kubernetes has become the go-to platform for container orchestration. MicroK8s, a lightweight Kubernetes distribution by Canonical, simplifies Kubernetes deployment and management. This blog will guide you through deploying MicroK8s on AWS, ensuring you have a scalable and robust environment for your applications.
Customized Cloud Solutions to Drive your Business Success
- Cloud Migration
- Devops
- AIML & IoT
Prerequisites
- An AWS account with proper permissions to create and manage EC2 instances.
- Basic knowledge of AWS, EC2, and Linux commands.
Step 1: Launching an EC2 Instance on AWS
Instance Configuration
- Instance Type: We will use a medium instance, which provides a good balance of compute power and memory for running MicroK8s.
- Operating System: Ubuntu 22.04 LTS is our choice for its stability and compatibility with MicroK8s.
- Storage: Allocate 20 GB of disk space to accommodate the MicroK8s installation and workloads.
- Security Group Configuration: Configure the security group to allow necessary ports for Kubernetes communication.
Security Group Configuration
Create a security group with the following rules:
- SSH (port 22): Allow SSH access for remote management.
- HTTP (port 80) and HTTPS (port 443): Allow web traffic for accessing applications.
- Custom TCP Rules: Open specific ports required by MicroK8s components:
PORT | SERVICE | ACCESS RESTRICTIONS |
16443 | API server | SSL encrypted. Clients need to present a valid password. |
10250 | kubelet | X509 client certificate required. |
10255 | kubelet | Read-only port. |
25000 | cluster-agent | Proper token required. |
12379 | etcd | SSL encrypted. Client certificates are required. |
10257 | kube-controller | HTTPS with authentication. |
10259 | kube-scheduler | HTTPS with authentication. |
19001 | dqlite | SSL encrypted. Client certificates are required. |
4789/udp | calico | Calico networking with VXLAN enabled. |
10248 | kubelet | Localhost healthz endpoint. |
10249 | kube-proxy | Metrics server port. |
10251 | kube-scheduler | HTTP insecurely. |
10252 | kube-controller | HTTP insecurely. |
10256 | kube-proxy | Health check server. |
2380 | etcd | Peer connections. |
1338 | containerd | Metrics port. |
30000-32767 | NodePort | NodePort range. |
Step 2: Set Hostname
After launching the instance, connect via SSH and set the hostname:
sudo hostnamectl set-hostname microk8s-node1
Step 3: Install MicroK8s
MicroK8s can be installed using Snap, a package manager for Ubuntu.
sudo snap install microk8s --classic --channel=1.28/stable
Step 4: Configure User Permissions
Add your current user to the microk8s group and set up the necessary directories:
sudo usermod -a -G microk8s $USER sudo mkdir -p ~/.kube sudo chown -f -R $USER ~/.kube
Reboot the instance to apply the changes:
sudo reboot
Step 5: Verify MicroK8s Installation
After rebooting, verify the MicroK8s installation:
microk8s status --wait-ready microk8s version microk8s inspect
Check the node details:
cat /var/snap/microk8s/current/var/kubernetes/backend/localnode.yaml
Step 6: Alias kubectl Command
To avoid conflicts with existing kubectl installations, create an alias for MicroK8s kubectl:
nano ~/.bashrc
Add the following line:
alias mkubectl='microk8s kubectl'
Apply the changes:
source ~/.bashrc
You can now use mkubectl for Kubernetes commands. For example:
mkubectl get nodes
Step 7: Deploy an Application
Deploy a demo Nginx application:
<code>microk8s kubectl create deployment nginx –image=nginx –replicas=3 microk8s kubectl get pods </code>
Expose the deployment:
<code>microk8s kubectl expose deployment nginx –type=NodePort –name=nginx-service –port=80</code>
Step 8: Manage MicroK8s
Start and stop MicroK8s services as needed:
<code> microk8s stop microk8s start</code>
Conclusion
By following these steps, you’ve successfully deployed MicroK8s on an AWS EC2 instance. This setup provides a scalable, lightweight Kubernetes environment for your applications. MicroK8s simplifies Kubernetes management, making it easier to deploy, monitor, and scale your workloads. Stay tuned for more on MicroK8s, including advanced configurations, multi-node clusters, and best practices for production deployments. Happy containerizing!
Feel free to reach out for any queries or feedback in the comments below.
Get your new hires billable within 1-60 days. Experience our Capability Development Framework today.
- Cloud Training
- Customized Training
- Experiential Learning
About CloudThat
CloudThat is a leading provider of Cloud Training and Consulting services with a global presence in India, the USA, Asia, Europe, and Africa. Specializing in AWS, Microsoft Azure, GCP, VMware, Databricks, and more, the company serves mid-market and enterprise clients, offering comprehensive expertise in Cloud Migration, Data Platforms, DevOps, IoT, AI/ML, and more.
CloudThat is the first Indian Company to win the prestigious Microsoft Partner 2024 Award and is recognized as a top-tier partner with AWS and Microsoft, including the prestigious ‘Think Big’ partner award from AWS and the Microsoft Superstars FY 2023 award in Asia & India. Having trained 850k+ professionals in 600+ cloud certifications and completed 500+ consulting projects globally, CloudThat is an official AWS Advanced Consulting Partner, Microsoft Gold Partner, AWS Training Partner, AWS Migration Partner, AWS Data and Analytics Partner, AWS DevOps Competency Partner, AWS GenAI Competency Partner, Amazon QuickSight Service Delivery Partner, Amazon EKS Service Delivery Partner, AWS Microsoft Workload Partners, Amazon EC2 Service Delivery Partner, Amazon ECS Service Delivery Partner, AWS Glue Service Delivery Partner, Amazon Redshift Service Delivery Partner, AWS Control Tower Service Delivery Partner, AWS WAF Service Delivery Partner, Amazon CloudFront Service Delivery Partner, Amazon OpenSearch Service Delivery Partner, AWS DMS Service Delivery Partner, AWS Systems Manager Service Delivery Partner, Amazon RDS Service Delivery Partner, AWS CloudFormation Service Delivery Partner, AWS Config, Amazon EMR and many more.

WRITTEN BY Mehar Nafis
Comments