How to Deploy Application In Kubernetes (Local Environment)

 

 

Introduction:

As the demand for scalable and containerized web applications grows, Kubernetes remains a popular choice for orchestrating and deploying containerized workloads. In this guide, we'll walk you through the process of deploying an Angular application on Kubernetes using NodePort, providing a straightforward method to expose your application to the external world.

Prerequisites:

Ensure you have the following prerequisites in place before starting the deployment process:

  1. A functioning Kubernetes cluster- Tutorial to Install Kubernetes Locally
  2. Installed kubectl command-line tool
  3. Docker installed to containerize your Angular application.

Step 1: Clone The Repo

git clone https://github.com/shawon100/Angular-CRUD

 

                              Download 10+ DevOps Books That You Must Read 

 

Step 2: Apply the manifests file

Then Go to manifests folder 

At first deploy the deployment.yml file 

 

apiVersion: apps/v1
kind: Deployment
metadata:
name: webclient-angular-crud
spec:
selector:
matchLabels:
app: webclient-angular-crud
replicas: 1
template:
metadata:
labels:
app: webclient-angular-crud
spec:
containers:
- name: webclient-angular-crud
image: shawon10/webclient-angular-crud:85
imagePullPolicy: Always
ports:
- containerPort: 80

 

kubectl apply -f deployment.yml

 

Then deploy the service.yml

apiVersion: v1
kind: Service
metadata:
name: webclient-angular-crud-service
spec:
selector:
app: webclient-angular-crud
ports:
- protocol: "TCP"
port: 80
type: NodePort


kubectl apply -f service.yml


Step 3: Check the Pods, Services, and Ip address

Check the pod
kubectl get po
Check the Service
kubectl get svc
Note down the NodePort
Check the Ip of Node
kubectl get nodes -o wide

 

Step 4: Access Your Angular Application:

Once the service is created, access your Angular application using the NodePort on any of your cluster's nodes. Find the node's external IP and access the application at 

http://<node-ip>:NodePort

 

Watch The Full Video





 



 

 

 

Download Coding Interview Book and Get More Tutorials for Coding and Interview Solution: Click Here

Download System Design Interview Book and Get More Tutorials and Interview Solution: Click Here

Do you need more Guidance or Help? Then Book 1:1 Quick Call with Me: Click Here

Share on Google Plus

About Ashadullah Shawon

I am Ashadullah Shawon. I am a Software Engineer. I studied Computer Science and Engineering (CSE) at RUET. I Like To Share Knowledge. Learn More: Click Here
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment