From c03c1f4fbd3240a6af0d4688b09b44822e8f6faf Mon Sep 17 00:00:00 2001 From: v-rocheleau Date: Tue, 6 May 2025 14:05:20 -0400 Subject: [PATCH] docs: k8s convertion using kompose outline --- .gitignore | 4 ++++ k8s/k8s-gen.md | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 k8s/k8s-gen.md diff --git a/.gitignore b/.gitignore index 5e624d19..a17d05fa 100644 --- a/.gitignore +++ b/.gitignore @@ -59,3 +59,7 @@ etc/tests/*/*/*/__pycache__ etc/tests/*/geckodriver etc/tests/*/geckodriver.log geckodriver.log + +# resolved k8s kompose resources +k8s/kompose +k8s/resolved-compose.yaml diff --git a/k8s/k8s-gen.md b/k8s/k8s-gen.md new file mode 100644 index 00000000..00f5c150 --- /dev/null +++ b/k8s/k8s-gen.md @@ -0,0 +1,45 @@ +# Bento Kubernetes resources + +Currently, Bento uses Docker Compose for development and deployment. + +Kubernetes (k8s) is a container orchestration system, which enables better deployment automation and scaling. + +As we are porting Bento for k8s, our goal is **NOT** to completely replace Docker Compose with k8s resources. + +Compose is already tightly integrated with `bentoctl`, and it offers us a simple and reliable development environment. + +The goal of this work is to keep using Docker Compose as the source of truth for defining a Bento stack, and to have a mechanism +that allows us to translate Docker Compose stacks into k8s resources for production deployments. + +To achieve this, we will be using the [Kompose](https://kompose.io/) CLI tool, which is officialy supported and developed +by the Kubernetes project for this use-case. + +## Converting Bento Compose files to Kubernets + +WIP: simple proof of concept usage of Kompose for Bento + +```bash +# Generate a resolved Docker Compose config file with bentoctl +./bentoctl.bash compose-config >> k8s/resolved-compose.yaml + +# Convert the compose config to k8s resources using Kompose +mkdir k8s/kompose +kompose -f k8s/resolved-compose.yaml convert -o k8s/kompose + +# Deploy the resources to a k8s cluster +kubectl apply -f k8s/kompose +``` + +## Kompose labels + +Per Kompose's docs on [labels](https://kompose.io/user-guide/#labels): +> `kompose` supports Kompose-specific labels within the `compose.yaml` file to get you the rest of the way there. +> +> Labels are an important kompose concept as they allow you to add Kubernetes modifications without having to edit the YAML afterwards. +> +> For example, adding an init container, or a custom readiness check. + +To bridge the gap between k8s and Docker Kompose, we will need to include various Kompose labels in our compose files. + +These labels will only take effect when converting using Kompose. +