# Kubernetes Project- Deploying a Reddit clone Project.

**Prerequisites**: To follow this project, you need the following tools and accounts:

1. Aws account
    
2. Dockerhub account
    

**We have to follow the simple steps for this project**

**Step 1: Launching Ec2 instance**

Firstly, we need to launch two ec2 instances one for the master node and the other for the worker node. For the master, we are taking the t2.medium and for the worker, we are taking the t2.mirco.

**Step 2: Running the prerequisites to make the container ready**

We need to run the following steps:

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686825852184/b6782efe-f98b-4fec-b65b-8a1e44b3cf55.png align="center")

**Step 3: Then we need to clone the code to the GitHub**

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686825923689/af2751aa-c761-4a4a-9abd-4e1c515a0f4c.png align="center")

We have the Dockerfile

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686827503538/3391bcbb-bb5c-4b53-b350-5aed36872375.png align="center")

**Step 4: we are building the Docker image**

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686827452259/e61eb573-249b-4bf5-94ea-3ee95262f03f.png align="center")

**Step 5: Deployment process**

Let's create the deployment process for the application for that we need to create a deployment.yml file.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686828154616/365e5afa-e375-4aa5-afff-f57ee8e76317.png align="center")

Now, to deploy the app you need to run following the command:

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686828499266/1ef39a8c-2db3-4910-9028-7a43a2fc6d45.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686828730342/7e89898c-b127-419c-8e0d-87d6e178c19e.png align="center")

**Step 6: Creating a service file**

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686828242385/c0499603-f814-4956-8607-3ae8cfc08eb0.png align="center")

For checking the Application and creating the link.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686829228188/0a839ec3-735c-446b-aa32-dd88d6b734e8.png align="center")

**Step 7: Exposing the app**

1. First We need to expose our deployment so use
    
    **kubectl expose deployment reddit-clone-deployment --type=NodePort** command.
    
2. You can test your deployment using
    
    **curl -L** [**http://192.168.49.2:31000**](http://192.168.49.2:31000)**. 192.168.49.2 is a minikube ip & Port 31000 is defined in Service.yml**
    
3. Then We have to expose our app service
    
    **kubectl port-forward svc/reddit-clone-service 3000:3000 --address 0.0.0.0 &**
    

Now we can see the Application

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1677780495226/7ba8afd2-e45e-455c-9b18-ee0a91d8c5a1.png?auto=compress,format&format=webp align="left")

Thanks for reading,

Mohammed Muqafamuddin.
