Repository navigation
Description
v0.8 P0 — safe, collaborative Terraform state without another mandatory service
Goal
Operators must not depend on the developer's OLF_HOME/state to manage an on-prem OLF deployment. Make Terraform backend selection a Deployment Profile infra setting, independent from runtime object storage and cluster-provider selection. Support Kubernetes-native backend by default for an existing cluster, with optional external S3-compatible backend for stronger recovery isolation. Keep local kind state local; cloud backends are handled by #132 (AWS) and corresponding Azure/cloud follow-ups.
Proposed profile (illustrative; reconcile exact shape with CLI/profile schema)
spec:
provider:
type: onprem
cluster: {context: customer-k3s}
state:
backend: kubernetes # local | kubernetes | s3
namespace: olf-state
# optional state ID / secret suffix derived from metadata.nameAlternative:
spec:
state:
backend: s3
s3:
endpoint: https://s3.infra.customer.example
bucket: terraform-state
key_prefix: openlakeforge/customer-olf
region: us-east-1
# credentials supplied through CLI process env / operator secret store, not YAMLImplementation / safety
- Terraform state is infrastructure control-plane data, not Iceberg/object data or OLF's
openlakeforge-opsarchive. No state backend hosted by an OLF component whose own lifecycle is controlled by that state (avoid circular dependency; OLF-deployed SeaweedFS is not a supported Terraform state backend). - Native
kubernetesbackend: use a stable, customer-owned namespace dedicated to state (e.g.olf-state); store one deployment-scoped platform state as a Secret; use Kubernetes Lease locking; pass kubeconfig/context explicitly and provision narrowly scoped read/write Secrets+Leases permissions. State namespace is bootstrapped outside the platform Terraform root and never deleted byolf infra destroy. Native Secret size limit is 1MiB: measure actual full-platform state size in test(onprem): real multi-node K3s qualification and RKE2 smoke #804 and fail/warn before reaching the limit. Require/document etcd/Secrets backup and encryption-at-rest policy; a lost cluster can lose the backend. - S3 backend: support pre-existing external S3-compatible store with endpoint, bucket, deterministic key, secure TLS/CA and
use_lockfile=truewhen verified supported by the pinned Terraform version. Reject unsupported conditional-create/locking semantics and missing credentials. Prefer versioning, restricted access, backup/replication and a storage service outside OLF app lifecycle. Do not assume any S3-compatible implementation supports safe locking without testing. - Local reference retains the local backend under
OLF_HOMEand must not be misrepresented as shareable. - Backend configuration cannot reference Terraform variables:
olfrenders/chooses backend blocks plus safe partialterraform init -backend-configbefore plan/apply, with a stable platform-only state in onprem and separate foundation+platform states in cloud. Avoid source-tree modifications or credentials in files, Terraform outputs, plans or logs; respect backend caching behavior. - Add idempotent
olf infra state init(bootstrap/check storage, namespace and least-privilege access) andolf infra state status(type/location, reachable/locked, no secret data), plus guardedolf infra state migratefor existing local state. Migration must back up and verify state lineage/serial/identity, prevent duplicate local/remote ownership, and require explicit confirmation. Ordinaryolf infra deployinitializes an already-configured backend without asking for a backend type. - Onprem
olf infra destroydeletes only OLF-owned resources; preserve state namespace/backend and external bucket. Never useterraform init -reconfigureto silently orphan/migrate a state or force-unlock an active operator. - Allow independent deployment and environment namespacing, with bounded privileges and one writer enforced through backend locking. No Terraform state committed to Git.
Acceptance
- On pre-existing K3s, two different operators/CI runners with valid cluster access read the same state, and concurrent apply is locked by the Kubernetes Lease.
- Platform deploy + repeated deploy + status works without prior workstation-local state; no foundation root created.
- A separate existing S3-compatible backend with validated lockfile can store the platform state, including failure and recovery tests.
- No state namespace/Secret/backend bucket is removed during normal OLF destroy.
- Backend unavailable or wrong kubecontext fails closed; diagnostics do not expose sensitive state values.
- Test state export/restore and documented state loss conditions (cluster-etcd loss in Kubernetes mode; independent external backend in S3 mode).
- Cross-provider and local kind behavior unchanged; cloud uses the same backend contract when Bootstrap durable remote Terraform state for the secure AWS reference #132 lands.
Explicit non-goals
Installing a new MinIO/SeaweedFS instance just to hold state; an OLF-managed cluster-wide state operator, Vault as a mandatory dependency, complete automated cluster-etcd disaster recovery, implicit state migration, or broad backend plugin framework.
References
- Terraform Kubernetes backend: https://developer.hashicorp.com/terraform/language/backend/kubernetes (Secret + Lease, state size limited by Secret capacity)
- Terraform S3 backend: https://developer.hashicorp.com/terraform/language/backend/s3 (optional use_lockfile + versioning)
- Terraform backend configuration: https://developer.hashicorp.com/terraform/language/backend (init must resolve backend before provider variables)
Dependencies: profile provider issue, #802, #50, #804. Cloud backend counterpart: #132 (v0.9).
Activity