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
Established in 2012, CloudThat is a leading Cloud Training and Cloud Consulting services provider in India, USA, Asia, Europe, and Africa. Being a pioneer in the cloud domain, CloudThat has special expertise in catering to mid-market and enterprise clients from all the major cloud service providers like AWS, Microsoft, GCP, Databricks, HP, and more. Uniquely positioned to be a single source for both training and consulting for cloud technologies like Cloud Migration, Data Platforms, DevOps, IoT, and the latest technologies like AI/ML, it is a top-tier partner with AWS and Microsoft, winning more than 8 awards combined in 11 years. Recently, it was recognized as the ‘Think Big’ partner from AWS and won the Microsoft Superstars FY 2023 award in Asia & India. Leveraging its position as a leader in the market, CloudThat has trained 650k+ professionals in 500+ cloud certifications and delivered 300+ consulting projects for 100+ corporates in 28+ countries.
WRITTEN BY Mehar Nafis
Click to Comment