Skip to content

wy8162/spring-webflux-restful-kotlin-coroutine

Repository files navigation

Microservice HR Service - Kubernetes and GitOps

1. Setting up Kubernetes Environment

  • Install Microk8s based on the official documents.

  • Enable the following addons

$ microk8s enable dashboard
$ microk8s enable dns
$ microk8s enable storage
$ microk8s enable registry
$ microk8s enable istio
  • Enable Istio Sidecar for namespaces. I.e.:

$ kubectl label namespace default istio-injection=enabled
  • Install ArgoCD

    • Following ArgoCD installation guidelines to install ArgoCD.

2. Sample Service with Spring Webflux and Kotlin

2.1. What Included

  1. Controller Based REST

  2. Functional Endpoint REACTIVE REST

  3. Functional Endpoint COROUTINE

  4. R2DBC

  5. PostgreSQL

2.2. Build Docker Image

$ ./gradlew bootBuildImage --imageName=hrservice:latest
$ docker push 192.168.64.3:32000/hrservice:latest
Note
Microk8s Local Registry
  • Enable Microk8s registry addon.

  • If Microk8s runs in VM, find the Microk8s cluster IP address: "kubectl cluster-info". Here, 192.168.64.3 is the IP address in my environment.

  • Use localhost:32000 if Microk8s runs in the host machine.

  • Use localhost:32000/hrservice:latest in the K8s deployment.

2.3. SWAGGER

Note
If Deployed in Kubernetes
Note
See the code for samples

Both functional endpoints and controllers.

2.3.1. Method 1

  1. Add the Springdoc dependency.

  2. Configure Springdoc Swagger 3.0 in application.yml.

  3. Optional: create bean OpenAPI as done in OpenApiConfig.

  4. Use org.springdoc.webflux.core.fn.SpringdocRouteBuilder.route to configure RouterFounction endpoints. See example RouteOpenAPISpringdoc.

2.3.2. Method 2

Adding OpenAPI anonations to the functional endpoints directly. See branch openapi_explict_annotation.

Springdoc plugin springdoc-openapi-maven-plugin can be used to generate OpenAPI JSON descriptions.

4. Sample HR Database Schema and Data

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published