Template for a REST micro service written in Kotlin.
- Kotlin
- Quarkus
- PostgreSQL
- OpenAPI v3 documentation generation
- Kubernetes deployment
- Docker compose for local development with live reload
- Production ready native Dockerfile
- Flyway migration of database
OpenAPI v3 documentation is generated on localhost:8080/docs.yaml
and Swagger GUI is available on localhost:8080/docs-ui
. The UI is only available on dev.
docker-compose up
The docker-compose.yaml
file will connect the micro service to a PostgreSQL database for persistent storage.
Quarkus dev is set up for live reload and will notice file changes in src
on new requests. However, if dependencies change in the pom.xml
file, docker-compose
needs to be re-run.
docker build -t <tag> .
Provided docker image has two steps.
- Compile the project sources to a native binary.
- Run the binary on
registry.access.redhat.com/ubi8/ubi-minimal
.
kubectl apply -f k8s/se-rest
In the k8s/se-rest
directory, resources are provided to deploy the micro service to a Kubernetes cluster.
Required changes
- Update secrets in
k8s/se-rest/00-secrets.yaml
. - Make sure to not check in unencrypted secrets in the repository.
- Update image in
k8s/se-rest/20-deployment.yaml
.
Example set-up with k3s/k3d
- Create a cluster:
k3d create -n se-rest
. - Add cluster info:
export KUBECONFIG="$(k3d get-kubeconfig --name='se-rest')"
. - Apply secrets:
kubectl apply -f k8s/se-rest/00-secrets.yaml
- Set up PostgreSQL:
kubectl apply -f k8s/dev/00-postgres.yaml
- Apply all se-rest configs:
kubectl apply -f k8s/se-rest
. - Port forward:
kubectl port-forward svc/se-rest 8080:80
. - Curl:
curl http://localhost:8080/posts
.