Skip to the content.

Spring Boot Kubernetes and MySQL

Sample project to test and deploy spring boot application with mysql database in kubernetes.

Prerequisite

Start application

kubectl apply -f deployment/secrets.yaml
kubectl apply -f deployment/mysql-deployment.yaml

gradle clean dockerTag
kubectl apply -f deployment/app-k8s.yaml

curl -X GET \
  http://localhost:31371/api/v1/pets \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json'
  

Response should be :

[
  {
    "name": "Puffball",
    "owner": "Diane",
    "species": "hamster",
    "sex": "f",
    "birth": "1999-03-30",
    "death": null
  }
]

Delete deployment, service, secret and pvc

kubectl delete -f deployment/app-k8s.yaml
kubectl delete -f deployment/mysql-deployment.yaml
kubectl delete -f deployment/secrets.yaml

Reference