= Asciidoctor + Spring Boot + K8s :asciidoctor-docs-url: https://docs.asciidoctor.org/ :toc: preamble :validation: You should be able to access the https://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-features.html#production-ready[Actuator] endpoint http://localhost:8080/actuator.
This project shows how work with a containerized https://spring.io/projects/spring-boot[Spring Boot] service to convert documents with {asciidoctor-docs-url}asciidoctorj/latest[Asciidoctorj].
== Requirements
== Features
=== Metrics // https://github.com/kubernetes-sigs/metrics-server/releases/download/metrics-server-helm-chart-3.8.2/components.yaml // kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml
Skaffold deployment adds https://github.com/kubernetes-sigs/metrics-server[metrics server] adapted for Kind. Once <<_skaffold,deployed>>, you can check the resources used by the pod with
$ kubectl top pods
== Build & Deploy
Note deploying in just Docker or local K8s requires the minimal setup, but also require more manual steps. And doesn't allow for life-reload and code debugging from IntelliJ.
=== Docker only
To run in plain Docker, build the image and run it.
$ ./gradlew bootBuildImage $ docker run -it -p8080:8080 asciiboot:0.0.1-SNAPSHOT
To demo it run
curl -X POST -H 'Content-Type: application/json' "http://localhost:8080/asciidoc" -d '{"data":"PSBUaXRsZQo="}' | jq -r '.content' | base64 -d > file.html
An open file.html
=== Kubernetes only
. Start a local Kind cluster
$ kind create cluster --config kind-config.yaml
. Build Spring Boot docker image
$ ./gradlew bootBuildImage
. Load image into Kind
$ kind load docker-image asciiboot:0.0.1-SNAPSHOT
. Deploy in Kind's K8s cluster
$ kubectl apply -f manifests/
To validate it:
$ kubectl port-forward service/asciiboot-svc 8080:8080
{validation}
--kubelet-insecure-tls
.
Otherwise, metrics-server pod won't start with error====
=== Skaffold
https://skaffold.dev[Skaffold] automates the complete process of building, deploying, port-forwarding and debugging. It also offers life-reload, so that changes in the code ar automatically deployed in the local k8s cluster.
To just run without debugging
$ skaffold dev
{validation}
For debugging install https://plugins.jetbrains.com/plugin/8079-cloud-code[Cloud Code plugin] in IntelliJ.
Create a Cloud Code: Kubernetes
with the Run > Edit Configurations
option, and run it as Debug
.
You should see the app logs in the IDE console and be able to add breakpoints and debug as any other Java app.