Skip to content

feat(state): configurable and shared Terraform backends for on-prem clusters (Kubernetes or external S3) #905

Open

Description

@malon64

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.name

Alternative:

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 YAML

Implementation / safety

  • Terraform state is infrastructure control-plane data, not Iceberg/object data or OLF's openlakeforge-ops archive. 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 kubernetes backend: 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 by olf 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=true when 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_HOME and must not be misrepresented as shareable.
  • Backend configuration cannot reference Terraform variables: olf renders/chooses backend blocks plus safe partial terraform init -backend-config before 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) and olf infra state status (type/location, reachable/locked, no secret data), plus guarded olf infra state migrate for existing local state. Migration must back up and verify state lineage/serial/identity, prevent duplicate local/remote ownership, and require explicit confirmation. Ordinary olf infra deploy initializes an already-configured backend without asking for a backend type.
  • Onprem olf infra destroy deletes only OLF-owned resources; preserve state namespace/backend and external bucket. Never use terraform init -reconfigure to 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

Dependencies: profile provider issue, #802, #50, #804. Cloud backend counterpart: #132 (v0.9).

Activity

  1. added this to the milestone on Nov 6, 2026
  2. added
    roadmap
    priority: P0
    track: operability
    on Nov 6, 2026
  3. modified the milestones: , v0.8-beta — Cloud Beta (AWS, Scaleway, OVH) on Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: P0roadmaptrack: operabilitytype: feature

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions