Kubernetes Hello World Example with Spring Boot Application
Hey There ,
Today we will learn , how can we deploy our first spring boot demo application via Kubernetes. As a pre-requisite , I have already created a spring boot application and uploaded on public docker hub.
Docker Image Name : shashivish123/exploration
Pre-requisite : MiniKube Cluster
Step 1: Start Your Kubernetes cluster if not running . In below example ,we will be using Minikube cluster for development purpose.
If you do not know , how to install minikube cluster , please follow official kubernetes documentation.
Step 2: Now since our cluster is running fine , we will start by create a namespace where we will deploy our Kubernetes Pods and Services.
#Create Namespace
kubectl create namespace casdemo
Step 3: Next step is to create manifest file which will be used for creating pods and services.
#Create Manifest Files kubectl create deployment casdemo --image=shashivish123/casexploration:latest --dry-run -o=yaml > deployment.yaml kubectl create service clusterip casdemo --tcp=8080:8080 --dry-run -o=yaml > service.yaml
Step 4 : Deployment file points to spring boot application image and it pull that image once Pod is being created.
#Create Pods and services kubectl create -f deployment.yaml -n casdemo kubectl create -f service.yaml -n casdemo
Step 5: Let's make sure that everything is up and running state.
#Check Pods are properly created
kubectl get all -n casdemo
Step 6 : Now we will enable port forwarding for accessing Spring boot application.
#Port Forwarding kubectl port-forward service/casdemo 8080:8080 -n casdemo
Step 7 : Let's check if we are able to access application using curl command or alternatively you can also check in browser.
curl http://localhost:8080/actuator/health
Hope you find blog helpfull.
Keep Learning & Keep Sharing. :)
best devops training institute in hyderabad
ReplyDelete