Skip to content

uuhnaut69/spring-boot-k8s

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

spring-boot-k8s

Spring boot deploy k8s example

Prerequisites

  • Java 17
  • Docker / Docker-compose
  • Minikube

Get Started

  • Init sample application
  • Deploy sample application k8s
  • CRUD app sample
  • Deploy Postgres k8s

1. Install minikube

Install minikube

brew install minikube

Show minikube dashboard

minikube dashboard

2. Build app docker image

Build docker image

./mvnw spring-boot:build-image

Tag docker image

docker tag demo:0.0.1-SNAPSHOT uuhnaut69/spring-demo

Push image

docker push uuhnaut69/spring-demo

3. Generate k8s yaml files

Make directory to store all yaml files

mkdir deployment

Generate deployment yaml

kubectl create deployment spring-boot-app --image uuhnaut69/spring-demo -o yaml --dry-run=client > deployment/app-deployment.yaml

Generate service yaml

kubectl create service clusterip spring-boot-app --tcp 80:8080 -o yaml --dry-run=client > deployment/app-service.yaml

4. Deploy

Apply deployment

kubectl apply -f ./deployment

Config port forward

kubectl port-forward svc/spring-boot-k8s 9090:80

Test

curl http://localhost:9090/greeter; echo

About

Spring boot deploy k8s example

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages