Skip to content

loucasa/posts-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spring Boot API Playground

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.

Overview

The project includes:

  • Basic REST endpoints (/, /actuator/health, /posts)
  • Entity management with JPA
  • Error handling
  • Integration tests

Purpose

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.

Getting Started

Prerequisites

  • Java JDK
  • Maven

Running the Application

mvn spring-boot:run

Running Tests

mvn test

API Endpoints

  • GET / - Index endpoint, returns "ok"
  • GET /posts/{id} - Get a specific posts by ID
  • GET /postss - List all posts
  • POST /posts - Create a new posts

Containerization

Build Docker Image

docker build -t post-api:latest .

Run with Docker

docker run -p 8080:8080 post-api:latest

Kubernetes Deployment

Apply the Kubernetes manifests in your cluster:

kubectl apply -f k8s-deployment.yaml

This 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:80

You 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:latest

After 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.

Exposing with LoadBalancer (Minikube)

If you want to access your API via a LoadBalancer service (external to cluster and port 80), apply the manifest and run:

minikube tunnel

This will expose the post-api-lb service on a local IP. You can get the external IP with:

kubectl get svc post-api-lb

Then access your API at http://<external-ip>/.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Generated from github/codespaces-blank