ok-storage is the persistent storage layer of OpenKubes.
It owns the storage contract consumed by every OpenKubes capability — ok-cluster, ok-apps, and any Crossplane Composition that requests a PVC — never a specific implementation.
OpenKubes owns the contracts, not the components. ok-storage defines what a volume guarantees. Longhorn is today's implementation. See ADR-Platform-009 for the full decision record.
| StorageClass | Access Mode | Guarantees |
|---|---|---|
ok-storage-block (default) |
RWO | Replicated (>=2), survives single node failure, snapshot/restore, online expansion |
ok-storage-shared |
RWX | Shared storage required by KubeVirt live migration and multi-pod workloads, same durability as block |
ok-storage-local |
RWO | Node-local, non-replicated — scratch, cache, reproducible data only |
No manifest in any ok-* repo may reference an implementation-specific
StorageClass (e.g. longhorn, rook-ceph-block). The three names above are
the only stable interface.
An experimental, non-contract investigation of developer-workspace capacity enforcement is documented in the C3 preflight. It does not add or change a StorageClass guarantee.
ok-storage-block-gpu-test is a deliberately unstable, demo-only class.
It is not a fourth storage contract and must never be used by production
consumers. It creates one Longhorn replica, selects only the Longhorn node tag
openkubes-gpu-demo, uses reclaimPolicy: Delete, and exists solely for
repeatable short-lived Talos/Flatcar demonstrations on ok-gpu.
The lifecycle is fail-closed and separate from make apply-classes:
# Mutating: requires separate runtime approval.
GPU_DEMO_APPLY=yes make gpu-demo-apply \
KUBECONFIG_FILE="$HOME/.kube/ok-infra.yaml"
# Read-only verification.
make gpu-demo-verify KUBECONFIG_FILE="$HOME/.kube/ok-infra.yaml"
# After every demo PVC/PV/Longhorn volume is gone; fails if still in use.
GPU_DEMO_REMOVE=yes make gpu-demo-remove \
KUBECONFIG_FILE="$HOME/.kube/ok-infra.yaml"The tool merges its tag into the existing Longhorn node tags and removes only
that tag during cleanup. It never changes ok-storage-block, its replica
count, or existing volumes.
ok-storage-local-quota is an experimental, non-contract implementation profile,
not a fourth storage contract. It provides fixed-size, node-local Hostpath volumes;
there is no replication or online expansion. ADR-Platform-009:38 remains an open
question. The manifests live in demo/, beside the GPU demo, to keep them separate
from storageclasses/ and the stable interface.
The provider-neutral runtime-capacity contract in ADR-Platform-039 section 4 and the class contract in ADR-Platform-009 define the guarantees consumers require. This OpenEBS Hostpath/XFS profile is one experimental implementation proof of runtime capacity enforcement; it does not extend or replace those contracts.
Use guest clusters only. Workers need XFS mounted with prjquota and
user.max_user_namespaces > 0. Enable the ok-cluster workloadUserNamespaces
opt-in (merged in openkubes/ok-cluster#409) in the guest's cluster-config.yaml:
workloadUserNamespaces:
enabled: true
provisionerBasePath: /var/openebs/local-quotaThat path must equal the StorageClass BasePath. After local-quota-apply, run the
ok-cluster cross-repo check before local-quota-verify:
make verify-workload-user-namespaces CLUSTER=<guest> GUEST_KUBECONFIG=<guest kubeconfig> # in ok-clusterIt must print PASS: worker provisionerBasePath matches ok-storage-local-quota BasePath.
SKIP means the opt-in is disabled for that cluster, which this profile does not
support. The check compares the declared provisionerBasePath with the StorageClass
BasePath; local-quota-verify then covers the live mount and quota on one worker.
Workspace Pods must use
hostUsers: false: a UID 1000 writer without a user namespace can reset its
project ID and bypass the quota. The local-path provisioner cannot be
idmap-mounted. The provisioner namespace is labelled PodSecurity privileged
because OpenEBS helper Pods require it; workspace writers remain unprivileged.
The pinned chart's ClusterRole grants the provisioner ServiceAccount
ok-storage-local-quota/ok-storage-local-quota-provisioner all verbs on pods,
namespaces, events and endpoints in every namespace (it creates helper Pods
on the volume's node). That ServiceAccount can therefore start a Pod in any
namespace under any ServiceAccount there, which is platform authority: treat it
like other cluster add-on controllers. The openkubes DeveloperWorkspace live proof
lists it as an expected holder of Pod creation in crossplane-system when this
profile is installed. Narrowing the chart's RBAC is not part of this profile.
The OpenEBS dynamic-localpv-provisioner chart is pinned to 4.6.0 in
demo/local-quota-pin.json. The downloaded archive is SHA256-checked before
rendering and vendored alongside demo/local-quota-provisioner.yaml;
make verify checks the archive offline. Apply consumes that rendered manifest,
so it requires neither Helm nor a network fetch. Values are recorded in
values/local-quota-values.yaml. Every image this profile deploys or its verify
creates (provisioner, OpenEBS helper, Python writer, and privileged observer) is
pinned as repo:tag@sha256:digest; test images of the other profiles
(tests/verify-*.yaml) are outside this profile. The pin record lists the supplied image index digests
resolved on 2026-10-13 with skopeo inspect, along with the commands to reproduce
the render byte-for-byte. make verify rejects images without digests in both
the rendered manifest and the generated proof probes. Index digests retain
multi-architecture selection while fixing the referenced image index. Python 3 and PyYAML are required for the tools;
live lifecycle commands also require kubectl and cluster image pulls.
LOCAL_QUOTA_APPLY=yes make local-quota-apply \
LOCAL_QUOTA_GUEST_KUBECONFIG="$HOME/.kube/guest.yaml"
LOCAL_QUOTA_VERIFY=operator-proof LOCAL_QUOTA_EXPECTED_CONTEXT="disposable-guest-context" \
make local-quota-verify \
LOCAL_QUOTA_GUEST_KUBECONFIG="$HOME/.kube/guest.yaml"
LOCAL_QUOTA_REMOVE=yes make local-quota-remove \
LOCAL_QUOTA_GUEST_KUBECONFIG="$HOME/.kube/guest.yaml"Verify is an operator-only proof for disposable or explicitly authorized
environments, NOT a tenant-callable readiness check. Tenants consume the
StorageClass only. Assert LOCAL_QUOTA_VERIFY=operator-proof and set
LOCAL_QUOTA_EXPECTED_CONTEXT to the explicitly authorized kubeconfig
current-context name (replace the example above). Missing intent variables fail
before any kubectl invocation. Context equality, a live SelfSubjectAccessReview
allowing Pod creation in ok-storage-local-quota, and server-side dry-run
admission of the privileged hostPath observer all pass before any probe is
persisted. After worker selection, the exact node-bound observer is also
server-dry-run immediately before its creation; rejection triggers probe cleanup.
SSAR checks RBAC Pod creation, not privilege; the dry-run checks the
actual observer spec against admission. Failures stop the proof. These are
operator intent and authorization prerequisites, not a new access-control
boundary: a caller with sufficient permissions can deliberately assert both
variables, and admission/permissions may change after preflight.
These targets never fall back to the host KUBECONFIG_FILE. Verify mutates
the guest cluster: it creates a uniquely named 64Mi PVC and UID/GID 1000 Pod
with hostUsers: false, then places a one-shot privileged observer on that
same node. The observer mounts BasePath and /dev read-only and reads the
worker's user-namespace sysctl. It checks XFS mount options, reads the project ID
from the exact spec.local.path of the bound PV, and matches its numeric quota
row to the PVC request (XFS report blocks are KiB). PVC UID, claimRef, PV class,
and PV node affinity are checked before accepting that binding.
The writer creates its own file, attempts FS_IOC_FSSETXATTR with project ID 0,
requires rejection and an unchanged nonzero project ID, then writes until
ENOSPC/EDQUOT within 1Mi of the 64Mi bound. The observer first requires at
least 128Mi free filesystem space and spare inodes to distinguish a quota-bound
write from a full worker filesystem. EINVAL, EPERM, or EACCES count as reset
rejection only with an unchanged project ID. Verify deletes its writer and PVC, waits for the
PV and project quota row to disappear, and removes the observer. Failures trigger
cleanup and return a named failure; missing tools or prerequisites never pass.
No standing privileged observer is installed. A run proves only the worker that
hosts the probe; repeat with scheduling controls if evaluating other workers.
Remove refuses while any PVC or PV references the class. It removes the class and provisioner resources, retaining the namespace to avoid deleting unrelated resources. Apply/remove require their explicit confirmation variables; verify's probe creation and cleanup are part of its invocation.
Chosen for the current hardware: two bare-metal storage nodes (ok-infra,
ok-gpu), which rules out Ceph's 3-monitor quorum requirement. Longhorn
fulfills the full contract at numberOfReplicas: 2.
- Redundancy lives on exactly one layer — the RKE2 host cluster. Workload (Talos) clusters do not run their own Longhorn; nesting would be 4x write amplification for no benefit.
- RWX (
ok-storage-shared) is served via Longhorn's built-in share-manager and is what makes KubeVirt live migration possible. - Both storage nodes are fully partitioned (no free NVMe), so Longhorn's
data path is
/var/lib/longhornon the root filesystem with an explicit storage reservation — seevalues/longhorn-values.yaml. - HA parameters are version-controlled here, not tribal knowledge.
Ceph is deferred, not rejected. A 2-node Ceph cluster is an anti-pattern
(split-brain risk on quorum); Ceph becomes the preferred implementation once
a third storage node exists. Because consumers only ever reference the
ok-storage-* contract names, that swap is transparent to every workload.
make prereqs # install open-iscsi + nfs-common on ok-infra, ok-gpu
make install # deploy Longhorn with the version-controlled HA values
make apply-classes # apply ok-storage-block / -shared / -local
make status # Longhorn nodes, volumes, and the contract StorageClassesCheck for a competing default StorageClass. RKE2 ships its own
local-pathStorageClass marked default out of the box. Kubernetes allows multiple(default)classes to coexist, but which one actually wins for an unqualified PVC is undefined. Aftermake install, verify:kubectl --kubeconfig ~/.kube/ok-infra.yaml get storageclassIf more than one shows
(default), un-default the other one (this is a cluster-wide RKE2 setting, not somethingmakemanages):kubectl --kubeconfig ~/.kube/ok-infra.yaml patch storageclass local-path \ -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"false"}}}'
make apply-classesbest-effort deletes the rawlonghornStorageClass that the Helm chart creates by default — but it comes back. Longhorn's own controller recreates it on its next reconcile (observed: within ~20 seconds), regardless ofpersistence.defaultClassinvalues/longhorn-values.yaml, which only controls whether it's marked default, not whether it exists. There is no known chart setting to suppress its creation entirely. ADR-Platform-009 forbids referencing implementation-specific StorageClasses directly — enforcing that in practice means code review and repo discipline, not a technical block. The delete step is left in as a courtesy for right-after-install checks, not a guarantee.
deletingConfirmationFlag is left at its default (false) — Longhorn's own
safety guard against accidental deletion. make uninstall will fail with
BackoffLimitExceeded until you explicitly confirm:
kubectl --kubeconfig ~/.kube/ok-infra.yaml -n longhorn-system \
patch settings.longhorn.io deleting-confirmation-flag --type merge -p '{"value":"true"}'
make uninstallStorageClasses are untouched by make uninstall (reclaimPolicy: Retain);
run make clean separately if you also want those removed.
tests/ contains verification manifests for each contract StorageClass —
not part of the contract itself, just proof it actually works on this
cluster. Safe to apply and delete any time; nothing here is meant to be
left running.
Both
ok-storage-blockandok-storage-sharedusereclaimPolicy: Retain. Deleting a test PVC does not delete itsPersistentVolumeor the underlying Longhorn volume — that's the point ofRetain, it protects real data from an accidental PVC deletion. For test cleanup this means an extra step: afterkubectl delete -f tests/..., also check for and remove the now-ReleasedPV and the orphaned Longhorn volume:kubectl --kubeconfig ~/.kube/ok-infra.yaml get pv | grep Released kubectl --kubeconfig ~/.kube/ok-infra.yaml delete pv <name> kubectl --kubeconfig ~/.kube/ok-infra.yaml -n longhorn-system get volumes.longhorn.io kubectl --kubeconfig ~/.kube/ok-infra.yaml -n longhorn-system delete volumes.longhorn.io <name>
ok-storage-block — confirms a replicated RWO volume schedules across
both nodes:
kubectl --kubeconfig ~/.kube/ok-infra.yaml apply -f tests/verify-block.yaml
kubectl --kubeconfig ~/.kube/ok-infra.yaml wait --for=condition=Ready pod/ok-storage-test --timeout=60s
kubectl --kubeconfig ~/.kube/ok-infra.yaml exec ok-storage-test -- sh -c 'echo hello > /data/hello.txt && cat /data/hello.txt'
# verify replica placement (expect one on each node)
PV=$(kubectl --kubeconfig ~/.kube/ok-infra.yaml get pvc ok-storage-test -o jsonpath='{.spec.volumeName}')
kubectl --kubeconfig ~/.kube/ok-infra.yaml -n longhorn-system get replicas.longhorn.io \
-l longhornvolume=$PV -o custom-columns=NAME:.metadata.name,NODE:.spec.nodeID,STATE:.status.currentState
kubectl --kubeconfig ~/.kube/ok-infra.yaml delete -f tests/verify-block.yamlok-storage-shared — confirms two pods can mount the same volume at
once (real shared access, not just independent mounts):
kubectl --kubeconfig ~/.kube/ok-infra.yaml apply -f tests/verify-shared.yaml
kubectl --kubeconfig ~/.kube/ok-infra.yaml wait --for=condition=Ready pod/ok-storage-test-a pod/ok-storage-test-b --timeout=120s
kubectl --kubeconfig ~/.kube/ok-infra.yaml exec ok-storage-test-a -- sh -c 'echo "written by pod A" > /data/shared.txt'
kubectl --kubeconfig ~/.kube/ok-infra.yaml exec ok-storage-test-b -- cat /data/shared.txt # expect: written by pod A
kubectl --kubeconfig ~/.kube/ok-infra.yaml delete -f tests/verify-shared.yamlSnapshot/restore (ok-storage-block) — confirms a crash-consistent
snapshot can be taken and restored into a new, independent volume. Uses
the Kubernetes-native VolumeSnapshot API (storageclasses/ok-storage-block-snapshot-class.yaml,
applied automatically by make apply-classes / make install) rather
than Longhorn's own Snapshot CRD, keeping the consumer API
driver-agnostic. The current Longhorn implementation explicitly uses a
local type: snap snapshot; it does not require a backup target:
# 1. Create the source PVC + pod, write data
kubectl --kubeconfig ~/.kube/ok-infra.yaml apply -f tests/verify-snapshot-restore.yaml
kubectl --kubeconfig ~/.kube/ok-infra.yaml wait --for=condition=Ready pod/ok-storage-test-src --timeout=60s
kubectl --kubeconfig ~/.kube/ok-infra.yaml exec ok-storage-test-src -- sh -c 'echo "before snapshot" > /data/state.txt'
# 2. Take the snapshot
kubectl --kubeconfig ~/.kube/ok-infra.yaml apply -f - <<'EOF'
apiVersion: snapshot.storage.k8s.io/v1
kind: VolumeSnapshot
metadata:
name: ok-storage-test-snap
spec:
volumeSnapshotClassName: ok-storage-block-snapshot
source:
persistentVolumeClaimName: ok-storage-test-src
EOF
kubectl --kubeconfig ~/.kube/ok-infra.yaml wait --for=jsonpath='{.status.readyToUse}'=true volumesnapshot/ok-storage-test-snap --timeout=60s
# Current Longhorn implementation: expect a snap:// handle, never bak://
CONTENT=$(kubectl --kubeconfig ~/.kube/ok-infra.yaml get volumesnapshot/ok-storage-test-snap -o jsonpath='{.status.boundVolumeSnapshotContentName}')
kubectl --kubeconfig ~/.kube/ok-infra.yaml get volumesnapshotcontent "$CONTENT" -o jsonpath='{.status.snapshotHandle}{"\n"}'
# 3. Change the source data, to prove restore comes from the snapshot, not the live volume
kubectl --kubeconfig ~/.kube/ok-infra.yaml exec ok-storage-test-src -- sh -c 'echo "AFTER snapshot -- should not appear in restore" > /data/state.txt'
# 4. Restore the snapshot into a new, independent PVC + pod
kubectl --kubeconfig ~/.kube/ok-infra.yaml apply -f - <<'EOF'
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: ok-storage-test-restored
spec:
storageClassName: ok-storage-block
dataSource:
name: ok-storage-test-snap
kind: VolumeSnapshot
apiGroup: snapshot.storage.k8s.io
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: 1Gi
---
apiVersion: v1
kind: Pod
metadata:
name: ok-storage-test-restored
spec:
containers:
- name: test
image: busybox:1.36
command: ["sleep", "3600"]
volumeMounts:
- name: data
mountPath: /data
volumes:
- name: data
persistentVolumeClaim:
claimName: ok-storage-test-restored
EOF
kubectl --kubeconfig ~/.kube/ok-infra.yaml wait --for=condition=Ready pod/ok-storage-test-restored --timeout=60s
# 5. Confirm: restored volume has the pre-snapshot content, source has the post-snapshot content
kubectl --kubeconfig ~/.kube/ok-infra.yaml exec ok-storage-test-restored -- cat /data/state.txt # expect: before snapshot
kubectl --kubeconfig ~/.kube/ok-infra.yaml exec ok-storage-test-src -- cat /data/state.txt # expect: AFTER snapshot ...
# 6. Clean up
kubectl --kubeconfig ~/.kube/ok-infra.yaml delete pod/ok-storage-test-restored pvc/ok-storage-test-restored
kubectl --kubeconfig ~/.kube/ok-infra.yaml delete volumesnapshot/ok-storage-test-snap
kubectl --kubeconfig ~/.kube/ok-infra.yaml delete -f tests/verify-snapshot-restore.yamlConsume it like any other StorageClass:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: example
spec:
accessModes: ["ReadWriteOnce"]
storageClassName: ok-storage-block
resources:
requests:
storage: 10Giok-storage/
├── Makefile # install / uninstall / status lifecycle targets
├── demo/
│ └── ok-storage-block-gpu-test.yaml # explicit non-HA ok-gpu demo class
├── storageclasses/
│ ├── ok-storage-block.yaml # RWO, replicated, default
│ ├── ok-storage-shared.yaml # RWX, live migration
│ ├── ok-storage-local.yaml # RWO, node-local, scratch
│ └── ok-storage-block-snapshot-class.yaml # VolumeSnapshotClass for snapshot/restore
├── values/
│ └── longhorn-values.yaml # version-controlled Longhorn HA parameters
├── scripts/
│ ├── gpu-demo-storage.py # guarded node-tag / demo-class lifecycle
│ └── prereqs.sh # open-iscsi + nfs-common host preflight
├── tests/
│ ├── verify-block.yaml # ok-storage-block verification (see Testing)
│ ├── verify-shared.yaml # ok-storage-shared verification (see Testing)
│ └── verify-snapshot-restore.yaml # ok-storage-block snapshot/restore (see Testing)
└── docs/
└── snapshot-semantics.md # crash- vs application-consistent snapshots
OpenKubes
├── ok-local — Local development (Multipass)
├── ok-cluster — Cluster Lifecycle Engine
├── ok-linux — OS profiles, Image Factory, MachineConfig
├── ok-storage — Persistent Storage Contract ← you are here
├── ok-gitops — GitOps bootstrap (ArgoCD)
└── ok-apps — Platform applications
Apache 2.0 — see LICENSE