This project serves as a playground for experimenting with Spring Boot API development. It provides a basic API structure that can be used as a foundation for testing and learning Spring Boot concepts.
The project includes:
- Basic REST endpoints (
/,/actuator/health,/posts) - Entity management with JPA
- Error handling
- Integration tests
This API was created as a base playground for experimenting with Spring Boot features and concepts. It's designed to be simple enough to understand quickly, yet structured in a way that allows for easy expansion and experimentation.
- Java JDK
- Maven
mvn spring-boot:runmvn testGET /- Index endpoint, returns "ok"GET /posts/{id}- Get a specific posts by IDGET /postss- List all postsPOST /posts- Create a new posts
docker build -t post-api:latest .docker run -p 8080:8080 post-api:latestApply the Kubernetes manifests in your cluster:
kubectl apply -f k8s-deployment.yamlThis will create a Deployment and Services for the API. You can port-forward to access the services:
kubectl port-forward svc/post-api-cluster 8090:80
kubectl port-forward svc/post-api-lb 8080:80You can then access them on localhost:8090 and 8080 respectively
If using Minikube and you built the image locally, load it into your Minikube cluster before applying the manifest:
minikube start
minikube image load post-api:latestAfter applying the manifest you can either port-forward as above or use minikube service post-api-lb to find the url to access the service.
You can also manage the cluster using minikube dashboard if preferred to command line.
If you want to access your API via a LoadBalancer service (external to cluster and port 80), apply the manifest and run:
minikube tunnelThis will expose the post-api-lb service on a local IP. You can get the external IP with:
kubectl get svc post-api-lbThen access your API at http://<external-ip>/.