Deploying a Kubernetes cluster on EC2 Ubuntu 20.04 LTS.
- An AWS account
- AWS CLI
- jq
make iac.install.macos.deps
make iac.configure profile=personal
- 2 instances (1 master, 1 node)
- Type:
t3.small
- 2 vCPUs
- 2GB RAM
- Security groups:
22 <my IP>
80 0.0.0.0/0
443 0.0.0.0/0
6443 0.0.0.0/0 <-- allow nodes in the same VPC
10250 0.0.0.0/0 <-- allow port-fowarding using kubectl
30000-32767 0.0.0.0/0 <-- k8s service type=NodePort exposes these range
- Build the master node
make iac.build.instance \
profile=personal \
instance-name=k8s-master \
sg-name=k8s-node-sg \
keypair-name=aws-k8s-key
- Build the worker node
make iac.build.instance \
profile=personal \
instance-name=k8s-worker \
sg-name=k8s-node-sg \
keypair-name=aws-k8s-key
- Setup SSH configs
# master
make iac.setup.ssh.config \
profile=personal \
instance=k8s-master \
keypair=aws-k8s-key
# worker
make iac.setup.ssh.config \
profile=personal \
instance=k8s-worker \
keypair=aws-k8s-key
- Setup Nodes (install Docker, Kubernetes components and dependencies)
make iac.setup.node instance=k8s-master
make iac.setup.node instance=k8s-worker
- Initialize the Kubernetes cluster on master node
make iac.fetch.public.ip profile=personal instance=k8s-master
make iac.setup.master instance=k8s-master publicip=<public-ip>
- Join worker node on the cluster
make iac.join.node instance=k8s-worker master=k8s-master
- Import kubectl config
make import.kubectl.config master=k8s-master
- Test it
make get.pods
Create the NGINX deployment
make run.nginx
Expose the NGINX deployment thru a Service
make expose.nginx
Port-forward the NGINX service to the localhost:4242
make pf.nginx
Open localhost:4242
and cheers!