This repository contains YAML configuration files for deploying an NGINX server on a Kubernetes cluster set up using kubeadm on EC2 instances.
Before proceeding, make sure you have kubeadm installed on both the master and worker (slave) nodes. You can follow the installation guide here: Kubeadm Installation Using Containerd.
Start by creating a dedicated namespace for the NGINX deployment.
- Run the following command to create a namespace named
nginx:
kubectl create namespace nginx- Verify that the namespace has been created:
kubectl get namespacesWith the namespace created, deploy an NGINX Pod.
1. Create a file named pod.yaml
2. Apply the Pod configuration in the nginx namespace:
kubectl apply -f pod.yml -n nginx3. Verify that the Pod is running in the nginx namespace:
kubectl get pods -n nginx1. Create a file named 'deployment.yaml'
2. Apply the Deployment configuration in the nginx namespace:
kubectl apply -f deployment.yml --namespace nginx3. Verify that the Deployment and replicas are running:
kubectl get deployments -n nginx
kubectl get pods -n nginx1. Create a file named 'service.yaml'
2. Apply the service configuration in the nginx namespace:
kubectl apply -f service.yml --namespace nginx3. Verify that the service is running and note the assigned NodePort:
kubectl get services -n nginxAfter setting up the NodePort service, you can access NGINX using the public IP address of any node in the cluster along with the NodePort assigned to the service.
For example, if the NodePort assigned to the service is 30007 and your worker node’s IP address is X.X.X.X, you can access NGINX by visiting:

