Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Latest commit

 

History

History

server-app-h2

Server application

TODOs

  • Implementation
  • Metrics
  • Tracing
  • Swagger
  • Docker multistage
  • Kubernetes
    • manifests
    • implementation
      • service-discovery
      • configmap
      • secrets

Prerequisites

  • Docker
  • Minikube / Cloud Kubernetes cluster
  • httpie
  • jq

Build & run

  • Locally

     mvnw clean spring-boot:run
    
  • On Docker

     docker build . -t server-app-h2:latest
     docker run -d --name server-app-h2 \
     	-e SPRING_PROFILES_ACTIVE=docker \
     	-e HEAP_SIZE=256M \
     	-e META_SIZE=300M \
     	-p 8080:8080 -p 8090:8090 \
     	server-app-h2
     docker logs server-app-h2 -f
    
  • On Kubernetes

     kubectl apply -f kube/configmap.yaml
     kubectl apply -f kube/secret.yaml
     kubectl apply -f kube/service.yaml
     kubectl apply -f kube/deployment.yaml
     kubectl apply -f kube/hor-pod-scale.yaml
    

API calls

Local / Docker

Minikube

  • Prepare env-vars
     SERVER_APP_HOST=$(minikube ip)
     SERVER_APP_PORT=$(k get svc | grep -i server-app | awk '{print $5}' | cut -d ',' -f 1 | sed 's,8080:,,' | sed 's,/TCP,,')
    
  • Insert
     http POST $SERVER_APP_HOST:$SERVER_APP_PORT/users email="[email protected]" name="Matteo Baiguini" age=33
     http POST $SERVER_APP_HOST:$SERVER_APP_PORT/users email="[email protected]" name="John Doe" age=42
     http POST $SERVER_APP_HOST:$SERVER_APP_PORT/users email="[email protected]" name="Jane Doe" age=24
     http POST $SERVER_APP_HOST:$SERVER_APP_PORT/users email="[email protected]" name="Clint Eastwood" age=75
    
  • Get
     http $SERVER_APP_HOST:$SERVER_APP_PORT/users
     http $SERVER_APP_HOST:$SERVER_APP_PORT/users/[email protected]
    
  • Update
     USER_ID=$(http $SERVER_APP_HOST:$SERVER_APP_PORT/users/[email protected] | jq ".id")
     http PUT $SERVER_APP_HOST:$SERVER_APP_PORT/users id=$USER_ID email="[email protected]" name="Clint Eastwood" age=89
    
  • Delete
     http DELETE $SERVER_APP_HOST:$SERVER_APP_PORT/users/[email protected]
     http DELETE $SERVER_APP_HOST:$SERVER_APP_PORT/users