Create a Single Cluster-Node Lab Environment on AWS
An easy way to build a Kubernetes learning environment on AWS is by installing Rancher k3s on Cloud9. This provides a consistent environment for getting hands-on experience with workloads and building projects.
A single EC2 instance will act as both master and worker.
The process is easy and straight forward. Let’s get started.
Go to AWS’ Cloud9 Console Page, and select “Create Environment”.
Fill out the Name and Description fields, and choose a t2.micro EC2 instance type.
Select Ubuntu as the operating system.
Select Secure Shell (SSH) as the connection type, and then select “Create”.
To open your new environment, select “Open in Cloud9”.
The new environment will look like this.
Next, update the operating system.
sudo apt-get update && sudo apt-get upgrade -y
Docker is already installed.
Install k3s, which is a lightweight version of Kubernetes.
curl https://get.k3s.io | sh -
Additional info on k3s can be found at https://docs.k3s.io/.
Kubernetes workloads can now be deployed.
As a test, create a new deployment, and verify it functions properly.
kubectl create deployment newdeploy --image nginx --replicas=3
kubectl describe deployment
Your learning environment is now complete.
Optionally, additional worker nodes can be added to the cluster by creating a token.
sudo cat /var/lib/rancher/k3s/server/node-token
Then adding the worker node using the new token and the worker node’s ip address.
sudo k3s agent --server https://<IP_ADDRESS_OF_WORKER_NODE>:6443 --token=<NEW_TOKEN> &