<#7123 feat(sandbox): Replace PostgreSQL pod with ...
# flyte-github
a
#7123 feat(sandbox): Replace PostgreSQL pod with embedded-postgres Pull request opened by pingsutw Tracking issue Why are the changes needed? The Flyte sandbox currently deploys PostgreSQL as a Bitnami StatefulSet inside K3s, which adds startup time, resource overhead, and complexity. By embedding PostgreSQL directly into the sandbox container using the `fergusstrange/embedded-postgres` Go library, we eliminate the PostgreSQL pod entirely while maintaining full compatibility. What changes were proposed in this pull request? • New
embedded-postgres
binary
(
cmd/embedded-postgres/main.go
): A Go program that uses the
fergusstrange/embedded-postgres
library to start PostgreSQL 16 as an embedded process. It: • Pre-caches PostgreSQL binaries from Maven (zonkyio) during Docker build • Drops privileges from root to
postgres
(uid 999) before starting • Configures
pg_hba.conf
to allow remote connections from K8s pods • Creates
flyte
and
runs
databases on startup • Signals readiness via
/tmp/embedded-postgres-ready
• Dockerfile multi-stage build (
pg-cache
stage): Downloads PostgreSQL binaries from Maven Central during build, collects glibc dependencies (since the K3s base image has no libc), and bundles them into the final image. • K8s Service + Endpoints: Replaces the Bitnami PostgreSQL StatefulSet with a headless Service + Endpoints pointing to the host's node IP, allowing K8s pods to connect to the embedded PostgreSQL running on the host. • Bootstrap changes: Added
%{NODE_IP}%
template variable resolution for the Endpoints resource IP address. • Helm chart: Wrapped PostgreSQL PV/PVC templates in
{{- if .Values.postgresql.enabled }}
conditional. • Removed: Bitnami PostgreSQL image from
manifest.txt
, ~270 lines of PostgreSQL StatefulSet/Secret/Service manifests from
complete.yaml
and
dev.yaml
. How was this patch tested? • Unit tests added for
embedded-postgres
(constants, pg_hba.conf append, data path persistence) and
bootstrap
(node IP resolution) • Full integration test: built Docker image, started sandbox container, verified: • All pods running with 0 restarts (no PostgreSQL pod) • Flyte binary connects and runs SQL queries against embedded PostgreSQL • External access via
psql -h 127.0.0.1 -p 30001
works •
flyte
and
runs
databases created successfully Labels • changed: Replaces PostgreSQL deployment strategy in sandbox Check all the applicable boxes • I updated the documentation accordingly. • All new and existing tests passed. • All commits are signed-off. •
main
• #6583 • feat(sandbox): Replace PostgreSQL pod with embedded-postgres 👈 flyteorg/flyte