Skip to content

abelsromero/asciiboot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Oct 29, 2024
b7815bc · Oct 29, 2024

History

68 Commits
Sep 10, 2023
May 22, 2023
Nov 25, 2023
Sep 10, 2023
Nov 25, 2023
Sep 10, 2023
Feb 19, 2021
Nov 25, 2023
Oct 29, 2024
May 22, 2023
Mar 30, 2023
Nov 25, 2023
Mar 2, 2021
Nov 25, 2023

Repository files navigation

Asciidoctor + Spring Boot + K8s

This project shows how work with a containerized Spring Boot service to convert documents with Asciidoctorj.

Requirements

  • Docker

  • Kind: to create a simplified local K8s cluster.

  • Skaffold: to automate, build, deploy and debugging, with life-reload. Debugging requires IntelliJ + Cloud Code plugin.

Features

Metrics

Skaffold deployment adds metrics server adapted for Kind. Once 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

  1. Start a local Kind cluster

    $ kind create cluster --config kind-config.yaml
  2. Build Spring Boot docker image

    $ ./gradlew bootBuildImage
  3. Load image into Kind

    $ kind load docker-image asciiboot:0.0.1-SNAPSHOT
  4. Deploy in Kind’s K8s cluster

    $ kubectl apply -f manifests/

To validate it:

$ kubectl port-forward service/asciiboot-svc 8080:8080
Note

Project contains a modified version of https://github.com/kubernetes-sigs/metrics-server/releases/download/metrics-server-helm-chart-3.8.2/components.yaml adding --kubelet-insecure-tls. Otherwise, metrics-server pod won’t start with error

scraper.go:140] "Failed to scrape node" err="Get \"https://172.18.0.2:10250/metrics/resource\": x509: cannot validate certificate for 172.18.0.2 because it doesn't contain any IP SANs" node="kind-21-worker"

Skaffold

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

For debugging install 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.

About

Asciidoctorj + SpringBoot example

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published