Skip to content

Kubernetes deployment of NGINX using kubeadm on EC2 instances, including configuration files for setting up a master and worker node

Notifications You must be signed in to change notification settings

GMATHUR90/nginx-k8s-with-kubeadm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NGINX Kubernetes Deployment with Kubeadm

This repository contains YAML configuration files for deploying an NGINX server on a Kubernetes cluster set up using kubeadm on EC2 instances.

Prerequisites

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.

Setup Instructions

Step 1: Create a Namespace for NGINX

Start by creating a dedicated namespace for the NGINX deployment.

  1. Run the following command to create a namespace named nginx:
   kubectl create namespace nginx
  1. Verify that the namespace has been created:
   kubectl get namespaces

Step 2: Create an NGINX Pod in the Namespace

With 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 nginx

3. Verify that the Pod is running in the nginx namespace:

kubectl get pods -n nginx

Step 3: Create an NGINX Deployment in the Namespace

1. Create a file named 'deployment.yaml'

2. Apply the Deployment configuration in the nginx namespace:

kubectl apply -f deployment.yml --namespace nginx

3. Verify that the Deployment and replicas are running:

kubectl get deployments -n nginx
kubectl get pods -n nginx

Step 4: Expose the NGINX Service in the Namespace

1. Create a file named 'service.yaml'

2. Apply the service configuration in the nginx namespace:

kubectl apply -f service.yml --namespace nginx

3. Verify that the service is running and note the assigned NodePort:

kubectl get services -n nginx

Step 5: Access the NGINX Application

After 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:

nginx_1.png

nginx_2.png

About

Kubernetes deployment of NGINX using kubeadm on EC2 instances, including configuration files for setting up a master and worker node

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published