Note: This is currently in development and not feature complete.
This is a demo project to showcase a small microservice architecture by exposing
- a simple
webfrontend service which enables the user to upload Markdown files (single or multiple) and let it convert by sending it to - the
apiservice which will add a job into therabbitmqqueue, such that - the
converterservice eventually (when idle) pulls a job from therabbitmqqueue and stores the result in the database.
components: All components making up this project.manifests: All kubernetes (k8s) manifeststools: Tools and scripts are located here..nvim: Nvim setup when entering this project. Needs pluginklen/nvim-config-local..githooks: Githooks setup, which also runs inside the CI..gitlab: CI setup with Gitlab.
The architecture is described in more details here.
On NixOS use the flake.nix by doing nix develop --command zsh inside the
root of the repo. This will setup an isolated development shell with all tools
installed.
On other systems you need the following essentials:
just: A bettermakealternative.dockerorpodman: Manage containers for virtualization and using thekindcluster.
and either
-
using the
.devcontainersetup with VS Code or over the CLI withjust start-devcontaineror -
you develop locally and have the following tools installed and on your
PATH:cargo: Rust toolchain withrustup toolchain install nightly.libpq: The PostgreSQL C library. Normally comes with packages such aspostgreson *nix systems.tilt: Auto-deploy changes directly to a running Kubernetes cluster when working in the repository and get instance feedback.kind: A Kubernetes cluster which runs in containers managed bydockerorpodman.kustomize: Rendering Kubernetes YAML manifests to specify resources/provisioning/deployments in the Kubernetes cluster.httpie: A http client which is easier/more intuitive to use thancurl[optional].k9s: A command-line tool to visualize what is running in your Kubernetes cluster [optional].
The following walks you through starting up a local Kubernetes cluster with
kind, inspecting the cluster and also shutting it down again.
Note: All commands given in the following are safe to use (virtualized or locally scoped to the repository) to use and will only minimally fiddle with your system.
The easiest way to run the api and corresponding other deployments (database
etc.) is using tilt on a local Kubernetes cluster, such as kind. The tool
kind is only doing the following two simple isolated parts on source file
changes:
- Building docker images and pushing them to a registry.
- Auto applying Kubernetes manifests in
./manifests.
Start the kind-kikist cluster (context: kind-kikist, with a local image
registry 🥳) with
just create-clusterNote: kind will write to your kubectl config file located in
~/.kube/config or otherwise set by KUBECONFIG env. variable.
You can now start k9s to inspect the state of the cluster. No api pods
should be running yet.
With tilt installed and the kind Kubernetes cluster running, deploy all the
api etc. with:
just deploy-upOpen the tilt web browser http://localhost:10350
to see the log & status of all running components, notably api and postgres.
Killing the cluster is as simple as:
just delete-clusterwhich will kill all resources and pods.
All components can be build with e.g.
just [--set parallel true] buildwhich will run the build task over all components.
to build a single component <component> either run just build inside the
components/<components> directory or use
just component <component> build`inside the repository root. All binaries are in the target directory inside
the repository root.
The tool tilt will run all services and build all docker containers to the
ttl.sh registry (ephemeral images).
It will watch for changes to any files (including the service manifests and redeploy the services, configuration maps as far as possible.
To start the loop run (after just create-cluster) do:
just deploy-upwhich loads an optional user-defined settings file
manifests/.env.yaml. You can use the local
registry for uploading the container images or ttl.sh and also configure if
you want to build a debug release for more log output on trace and debug
levels.
To remove all resources from the development cluster use:
just deploy-downYou can inspect continuously the state of the cluster with k9s and also watch
tilt what its doing by inspecting
http://localhost:10350.
- Either use VS Code with the rust extension or
- Debug in
neovimas fancy-pancy as possible by using thenvim-dap.luafile which is automatically loaded if you use the plugin{ "klen/nvim-config-local" }which will execute.nvim/nvim.luawhen you open this repo innvim. When you start the debugger (see pluginnvim-dap) it will prompt you which executable you want to debug.
Run just start-db-tool and make a connection with the DATABASE_URL in your
configured components/api/.env.
You can install Githooks by running the manual install here and then running:
cd repository
git hooks install
git hooks config enable-containerized-hooks --global --setin this repository. To show all running hooks run git hooks list. To disable
running hooks use either
GITHOOKS_DISABLE=1 <your-cmd>orgit commit --no-verify ...orgit hooks uninstallto completely remove the hook run wrappers from.git/hooks.
Either use the free Gitlab credits or start your own runner with docker by
running:
just start-gitlab-runner <token>where the <token> is the Gitlab runner token obtained from setting up a
project specific runner in Gitlab. After starting the runner, the config mount
will be inside .gitlab/local.
There is a simple just test manual command which tests some simple API calls
for manual debugging and investigations.