Spring Boot + Kubernetes Tutorial - Service Hello World Example

In this tutorial we will be developing a Nodeport service using which the external client will be able to access the deployed application.

Video
This tutorial is explained in the below Youtube Video.Spring Boot + Kubernetes Tutorial
What is Kubernetes? Need for it? Install Ubuntu on Windows using WSL Installing Kubectl, Minikube and Docker on Ubuntu Create Docker Image Deploy to Minikube Pods Difference between ClusterIP, NodePort and LoadBalancer Service Service Hello World Example
Implementation
In previous tutorial we had created the nodeport service configuration file as follows-
apiVersion: v1
kind: Service
metadata:
name: employee-producer-service
spec:
selector:
app: boot-jar
ports:
- protocol: TCP
port: 80
targetPort: 8080
nodePort: 30080
type: NodePort

Start Minikube
minikube start --force

If we list the docker images, we can see the images we created previously
docker image ls

To use docker with minikube we will need to switch the docker context to using minikube.
eval $(minikube docker-env)
kubectl apply -f service.yml

In previous tutorial we had created a pod.yml for deploying spring boot application to kupernetes pods. For this we will be modifying the pod.yml to have the same label as the service.

apiVersion: v1
kind: Pod
metadata:
name: boot-jar
labels:
app: boot-jar
spec:
containers:
- name: boot-jar-container
image: javainuse/employee-producer-kubernetes:latest
kubectl delete pod boot-jar

Next we will again create the pod as follows -
kubectl apply -f pod.yml

We can check the pod logs as follows
kubectl logs boot-jar

As the pod is showing that the application has started successfully, we will test the application running in pod. For this we first need to get the minikube ip address as follows -
minikube ip

curl 192.168.49.2:30080/employee

Popular Posts
1Z0-830 Java SE 21 Developer Certification
1Z0-819 Java SE 11 Developer Certification
1Z0-829 Java SE 17 Developer Certification
AWS AI Practitioner Certification
AZ-204 Azure Developer Associate Certification
AZ-305 Azure Solutions Architect Expert Certification
AZ-400 Azure DevOps Engineer Expert Certification
DP-100 Azure Data Scientist Associate Certification
AZ-900 Azure Fundamentals Certification
PL-300 Power BI Data Analyst Certification
Spring Professional Certification
Azure AI Foundry Hello World
Azure AI Agent Hello World
Foundry vs Hub Projects
Build Agents with SDK
Bing Web Search Agent
Function Calling Agent
Spring Boot + Azure Key Vault Hello World Example
Spring Boot + Elasticsearch + Azure Key Vault Example
Spring Boot Azure AD (Entra ID) OAuth 2.0 Authentication
Deploy Spring Boot App to Azure App Service
Secure Azure App Service using Azure API Management
Deploy Spring Boot JAR to Azure App Service
Deploy Spring Boot + MySQL to Azure App Service
Spring Boot + Azure Managed Identity Example
Secure Spring Boot Azure Web App with Managed Identity + App Registration
Elasticsearch 8 Security - Integrate Azure AD OIDC