← Portfolio

lakehouse-lab: one Terraform command to destroy, one to rebuild, now open source

A complete data platform for batch and streaming, SQL and PySpark, BI and ML, powered by Spark and ClickHouse. Everything is code: one Terraform roll-out builds it from an empty cloud project, one command removes it again. I tested that for real by destroying and rebuilding the lab, then published it as open source under Apache 2.0.

TerraformKubernetesSparkDelta LakeKafkaClickHouseRangerKeycloakOpen source

Terraform destroy and apply

The real test of “everything as code”: throw the whole platform away and bring it back. Between projects the lab is simply destroyed, so it costs nothing but a tiny state bucket.

Terminal: down.sh destroys 232 resources in 10 minutes, up.sh rebuilds the lab in 46 minutes in seven steps; monitoring went from an LLM agent at about $20 a day to a static health check at $0

What scripts/up.sh does (around terraform apply)

Seven steps, each with its own timing, idempotent: running it again continues where a failed run stopped.

1Cloud resourcesterraform apply on the cloud module: project, IAM keys per workload, buckets with policies, secrets with generated passwords, container registry, Kubernetes cluster.
2ImagesOfficial releases downloaded and checksum-verified, platform images built for amd64 and arm64 without RUN steps.
3KubeconfigAdmin access to the new cluster; waits for the nodes.
4PlatformOperators, Kafka, Spark, Kyuubi, Hive Metastore, Ranger, ClickHouse, Airflow, Superset, lldap, Keycloak, monitoring, plus setup jobs for users, rights and tables.
5Maintainer accountA restricted Kubernetes account for operations tooling: sees everything except Secrets.
6First pipelineRuns a weather pipeline once through landing, bronze, silver, gold and consumption.
7DashboardsSuperset datasets, charts, dashboards and roles, now that the data exists.

What the rebuild taught me

Destroy must never hangKafka topics carry finalizers; when their operator is removed in the same step, the destroy waits forever. Fixed with the operator's documented setting plus a safety net in down.sh: the next destroy went straight through in 10 minutes.
New clusters have racesA just-started admission webhook can be unreachable for a few seconds. One automatic retry instead of a fragile wait.
No patchingOfficial releases and documented settings only. Where a gap remained (lldap to Ranger sync, a notebook magic for PySpark through Kyuubi) it is small, separate and documented as a deviation.
Nothing private in publicThe open-source copy is produced by a publish script with an exclude list and a deny list kept outside the repo: no domains, IP addresses or internal tooling leak.

Maintenance: open-weight LLM, then a static script

I let an AI agent look after the running lab: OpenCode with the open-weight GLM model, hosted in a European cloud.

The GLM agentEvery hour it checked pods, streaming and alerts, made simple repairs (restart a stuck pod, verify, report) and sent a push message. A daily root-cause analysis added improvement suggestions. It worked, but measured at about $0.70 a run it came to roughly $20 a day.
Optimised to a static scriptMost hours nothing is wrong, so an LLM is overkill. A plain Python health check with fixed rules now runs every 15 minutes and reports to the same push channel at no cost. The LLM is used interactively, when I decide it adds value.

Open source

Published under the Apache 2.0 license: gitlab.com/tigornl/lakehouse-lab-oss. The README covers the idea, principles and deviations, components, architecture, SSO and authorization, and step-by-step installation. Domains and secrets are yours to arrange.