The purpose of this blog post is to explain how to deploy simple spring boot application inside Kubernetes cluster and access rest services which exposed by those applications.
Please note this is not my own creation but inspired by another blog post.
Also I am using minikube as single node Kubernetes cluster and you can follow below official document to learn more about it.
https://minikube.sigs.k8s.io/docs/
Steps to follow
- Start minikube
- Open minikube tunnel in another terminal to enable access k8s services out side the cluster
- Clone SpringBoot repository
- Building demo-backend app & Docker image
- Building demo-frontend app & Docker image
- Deploy backend and frontend applications
We need to change the image pull policy to Never in deployment (line: 22). Please refer below document for more details.
Edit image pull policy as below and deploy
- Expose both frontend and backend deployments/apps
Explaining with SpringBoot application.
Backend application expose a rest API with server port 8080 and return a message with "Hello from " prefix and pod name.
Frontend application expose an rest API with server port 8081 and return a message with "Message from backend is: " prefix plus message getting from Backend service.
So when we access the front end service with node_ip and node_port as below we will get the message as below.
http://192.168.49.2:32143
Message from backend is: Hello from demo-backend-fc9f8c8b9-tcqtz
No comments:
Post a Comment