OpenEBS LVM-LocalPV Block CSI Provisioning and Live In-Guest OverlayFS Pivot Verification
此内容尚不支持你的语言。
Source:
docs/enhancements/0016-k8s-block-csi-and-overlayfs-live-e2e/README.md· Status:implemented· Area:core· Milestone:v0.3.1
- CEP Number:
0016 - Status:
implementable - Target Version:
v0.3.1 - Components:
pkg/controller/manifests.go,pkg/controller/kubetypes.go,pkg/controller/kubeclient.go,deploy/k8s/,test/k8s-e2e/
1. Summary
Section titled “1. Summary”Deploys a real Block CSI Driver (OpenEBS LVM-LocalPV backed by an LVM Volume Group cubepod-vg on the Kubernetes worker node) in the live Kubernetes test cluster (https://192.168.1.207:6443) and verifies CubePod’s flagship volumeMode: Block + podd-init ext4 format/heal + Guest Kernel OverlayFS (upperdir/workdir) + pivot_root(2) path end-to-end on real Kubernetes Pods.
2. Motivation
Section titled “2. Motivation”- Provision an LVM Volume Group (
cubepod-vg) and deploy the OpenEBS LVM-LocalPV CSI driver (StorageClass: cubepod-lvm-block) on the Kubernetes cluster so Kubernetes can dynamically provisionvolumeMode: BlockPVCs and attach raw block devices (/dev/cubepod-rootfsand/dev/cubepod-workspace) viavolumeDevices. - Ensure
BuildKataPod(pkg/controller/manifests.go&pkg/controller/kubetypes.go) supportsvolumeMode: Blockon both Kata MicroVM clusters (runtimeClassName: kata-qemu) and standard container clusters (runtimeClassName: "", injectingsecurityContext.privileged: trueso PID 1podd-inithasCAP_SYS_ADMINto format/mountext4on/dev/cubepod-rootfs&/dev/cubepod-workspace, mountoverlay, and executepivot_root(2)). - Verify the full in-guest
podd-initblock lifecycle intest/k8s-e2e/k8s_block_e2e_test.go:rootfs-pvcandworkspace-pvcare dynamically provisioned withvolumeMode: Blockoncubepod-lvm-blockand mapped into the Pod at/dev/cubepod-rootfsand/dev/cubepod-workspace./run/cubepod/init-state.jsoninside the running sandbox reports"pivoted": true,"rootfs_action": "formatted"(on initial creation) and"mounted"or"healed"(after Pause + Auto-Resume!).- System packages/files written outside
/workspace(e.g.,/etc/cubepod-rootfs-persist.confor/usr/local/bin/custom-tool) persist across Pause & Auto-Resume because they live on the persistentext4upperdirblock volume (/dev/cubepod-rootfs). ResetRootFS(rootfsGeneration: 1 -> 2) rotatesrootfs-pvcto a fresh block device (wiping/etc/cubepod-rootfs-persist.conf), while/workspace(/dev/cubepod-workspace) remains 100% intact.
Non-Goals
Section titled “Non-Goals”- Replacing existing
nfs-storage(volumeMode: Filesystem) support; bothBlockandFilesystemstorage modes remain first-class options.
3. Proposal
Section titled “3. Proposal”User Stories
Section titled “User Stories”- As an AI Agent Platform Engineer, I want
pip install/apt-get installor system configuration changes inside the sandbox RootFS to survive across SandboxPause(scale-to-zero) andAuto-ResumeviavolumeMode: Block+OverlayFS, while still being able to reset the RootFS cleanly without losing/workspace.
Risks and Mitigations
Section titled “Risks and Mitigations”- Risk: In standard
runc/containerdPods (whenruntimeClassNameis empty rather thankata-qemu), mountingext4block devices andoverlayfsinside the container requiresCAP_SYS_ADMINand access to loop/LVM block device nodes. - Mitigation: When
volumeMode == "Block",ContainerManifestsetsPrivileged: true(securityContext.privileged: true) on thesandboxcontainer sopodd-initcan mount/dev/cubepod-rootfs,/dev/cubepod-workspace, andoverlaycleanly before dropping privileges (1000:1000) for user commands inpodd.
4. Design Details
Section titled “4. Design Details”4.1 Controller Manifest Changes (pkg/controller/manifests.go, kubetypes.go, kubeclient.go)
Section titled “4.1 Controller Manifest Changes (pkg/controller/manifests.go, kubetypes.go, kubeclient.go)”- Add
SecurityContext *SecurityContext(Privileged *bool) toContainerManifestandcoreV1Container. - In
BuildKataPod:- When
volumeMode == "Block", attachVolumeDevices(/dev/cubepod-rootfsand/dev/cubepod-workspace) and setPrivileged: trueon thesandboxcontainer so PID 1podd-initcan executemount(2)(ext4+overlay) andpivot_root(2). - Respect explicit
RuntimeClassNameconfiguration (do not force"kata-qemu"when the cluster operator explicitly configures--runtime-class=""on a non-Kata test cluster).
- When
4.2 OpenEBS LVM-LocalPV Block CSI Setup (deploy/k8s/)
Section titled “4.2 OpenEBS LVM-LocalPV Block CSI Setup (deploy/k8s/)”- Create a 50GiB loopback-backed LVM Volume Group (
cubepod-vg) on the worker node (gpu-214) located under the dedicated directory/storage/cubepod/(/storage/cubepod/cubepod-lvm-loop.imgon the worker’s 28TB/storageRAID partition). - Configure a persistent systemd service (
/etc/systemd/system/cubepod-loop.service) ongpu-214to automatically attach/dev/loop0and activatecubepod-vgon system boots. - Deploy OpenEBS LVM-LocalPV (
lvm.csi.openebs.io) andStorageClasscubepod-lvm-block(volgroup: cubepod-vg,volumeBindingMode: Immediate).
4.3 Dual-Runtime Behavior
Section titled “4.3 Dual-Runtime Behavior”- Production Kubernetes (
volumeMode: Block+cubepod-lvm-block): LVM LV block devices attached at/dev/cubepod-rootfsand/dev/cubepod-workspace, formatted asext4bypodd-init, mounted viaOverlayFS(lowerdir=/,upperdir=/mnt/cubepod-upper/upper,workdir=/mnt/cubepod-upper/work), and pivoted viapivot_root(2). - Local Development (
Docker + Loopback ext4): Continues using sparse loopbackext4files viapkg/runtime.
5. Test Plan
Section titled “5. Test Plan”- Unit tests in
pkg/controllerverifyingvolumeMode: BlockPod spec generation (volumeDevices,securityContext.privileged,runtimeClassName). - Live Kubernetes E2E test (
TestK8sBlockLiveE2Eintest/k8s-e2e/k8s_e2e_test.go) verifying:volumeMode: BlockPVCs bound oncubepod-lvm-block;/run/cubepod/init-state.jsonshows"pivoted": trueand"rootfs_action": "formatted";- RootFS changes (
/etc/cubepod-block-test.txt) AND/workspacechanges survivePause+Auto-Resume(with"rootfs_action": "mounted"on resume); ResetRootFSwipes/etc/cubepod-block-test.txtwhile preserving/workspace.
6. Graduation Criteria & PRR
Section titled “6. Graduation Criteria & PRR”- All offline unit/E2E tests (
make test,make test-e2e) and live Kubernetes Block CSI E2E tests (make test-k8s-e2e) pass 100% with zero leaked Pods, PVCs, or LVM LVs.
7. Alternatives Considered
Section titled “7. Alternatives Considered”- Longhorn / Rook-Ceph: Excessive memory/CPU overhead and multi-daemon complexity for a single-node test cluster compared to OpenEBS LVM-LocalPV.