Skip to content

Architecture

This page describes how CubeSandbox is delivered via the Kubernetes / Helm Chart: component layers, the four compute DaemonSets, install and startup order, and runtime paths for DNS / Proxy / Egress.

For install steps, see Helm Install. For compute image upgrades, see Upgrade. For troubleshooting, see FAQ.

Difference from “product architecture”

Architecture Overview covers CubeSandbox product components (CubeMaster / Cubelet / MicroVM, etc.). This page covers how those components are placed, scheduled, and started on K8s.

1. Overall layers

LayerComponentKubernetes formMain responsibility
Control planeCubeMasterDeployment + Service + Secret + PVC/hostPathNode registration, template/rootfs artifacts, embedded DB migration, scheduling/metadata
Control-plane APICubeAPIDeployment + ServiceExternal E2B-compatible HTTP API; reads/writes MySQL; talks to CubeMaster
Ops backendCubeOpsDeployment + ServiceJWT ops API + WebUI SDK; listens on 0.0.0.0:3010; reads/writes MySQL; talks to CubeMaster
Admin entryWebUIDeployment + Service + ConfigMapStatic console; reverse-proxies /opsapi/ and /cubeapi/v1/ to CubeOps (depends on cubeOps.enabled)
Ops entrycubemastercliDeploymentCLI for kubectl exec; injects this Release’s CubeMaster endpoint
Dependent storageMySQL / RedisBuilt-in StatefulSet or third-partyBusiness data / Proxy and lifecycle state
Compute · runtimecube-node (Big Pod)Native apps/v1 DaemonSetwait-node-prep init + cubelet / network-agent + optional egress
Compute · artifactscube-node-installerNative apps/v1 DaemonSetInstalls shim / kernel / guest into the host toolbox
Compute · node bootstrapcube-node-bootstrapNative apps/v1 DaemonSetwait-pvm-host, cube-node-init, writes node-prep-ready
Compute · PVM hostcube-node-pvmNative apps/v1 DaemonSet (placement.pvm only)PVM host kernel install (may reboot); manages L0 taints and writes fingerprints
Data-plane entryCubeProxy + cluster DNSDeployment; optionally rewrites CoreDNSHTTP/HTTPS sandbox entry; *.domain wildcard resolution
Lifecyclecube-lifecycle-managerDeployment + ClusterIPsandbox pause/resume; discovers Proxy replicas via Redis

Default full deployment:

2. Resource and image responsibilities

2.1 Control plane

ResourceChart templateNotes
cube-mastertemplates/master.yamlimages.master; mounts Chart-rendered conf.yaml; embedded schema migration
cube-master-configtemplates/master-config-secret.yamlRendered result of files/cube-master/conf.yaml
cube-master-storagemaster.yaml / master-pvc.yamlDefault PVC; optional existingClaim / hostPath / emptyDir
cube-apitemplates/api.yamlimages.api (external E2B)
cube-opstemplates/ops.yamlimages.ops; ClusterIP; bind 0.0.0.0:3010
cubemasterclitemplates/cubemastercli.yamlimages.cubemastercli
cube-webuitemplates/webui.yamlimages.webui + nginx ConfigMap (upstream CubeOps)
cube-secrettemplates/secret.yamlMySQL / Redis / Proxy passwords, etc.
volume-cos (optional)templates/volume-cos-secret.yamlCOS credentials (volume-cos.conf); mounted on Master + Cubelet when volumeCos.enabled

2.2 MySQL / Redis

ModeBehavior
Built-in MySQLmysql.host="" → StatefulSet + Headless Service; optional mysql.persistence.hostPath
Third-party MySQLNon-empty mysql.host → do not install built-in MySQL
Built-in Redisredis.host="" and control plane or Proxy needs it → install
Third-party RedisNon-empty redis.host → do not install built-in Redis

2.3 Compute plane: four DaemonSets

cube-node / cube-node-installer / cube-node-bootstrap use placement.compute (without allow-pvm-bootstrap). cube-node-pvm uses placement.pvm (includes allow-pvm-bootstrap), so non-PVM nodes do not pull the large cube-pvm-host-bootstrap image.

All four compute lines (Big Pod / installer / bootstrap / PVM) are native apps/v1 DaemonSets. Stateless control plane (master/api/ops/webui/proxy/lifecycle/cubemastercli) uses native Deployments; MySQL/Redis continue to use native StatefulSets.

Big Pod: cube-node

  • hostNetwork: false (Pod network); native apps/v1 DaemonSet.
  • initContainer: wait-node-prep (exits 0 when the fingerprint matches; not a long-running sidecar).
  • Image / resource / Pod template changes recreate the Big Pod (PodIP/netns change; existing sandboxes interrupt). See Upgrade.
  • NodeID = spec.nodeName; Endpoint = status.podIP.
  • toolbox whole tree hostPath: /usr/local/services/cubetoolbox.
ContainerImageResponsibility
wait-node-prep (init)images.waitNodePrepRead-only hostPath node-prep-ready self-describing fingerprint; exits when matched so run containers can start
network-agentimages.networkAgentStarts after self-stage
cubeletimages.cubeletStarts after self-stage
cube-egress / cube-egress-netmatching imagesOptional; transparent egress / TPROXY

Container names / volumeMount / securityContext / imagePullPolicy changes also recreate.

Installer: cube-node-installer

  • Containers: cube-shim-install / cube-kernel-install / cube-guest-install.
  • Replaces whole directories of shim / kernel / guest from the image into the host toolbox; during directory swap the version matrix is briefly marked incomplete, then restored on success.
  • Can RollingUpdate independently; for day-to-day artifact upgrades only bump Installer images.

Bootstrap: cube-node-bootstrap

  • init: wait-pvm-hostcube-node-init; main container writes node-prep-ready.
  • wait-pvm-host: checks whether the node has allow-pvm-bootstrap—if yes, waits for PVM host ready and records “this node uses PVM guest”; if not, records “this node uses bm guest”.
  • Sentinel directory: /var/lib/cube-node-bootstrap (shared with Big Pod wait-node-prep / PVM DS).
  • hostPID: true (nsenter --target 1); low-frequency changes; for node-init upgrades only bump Bootstrap / nodeInit images.

PVM: cube-node-pvm

  • Native apps/v1 DaemonSet; created only when bootstrap.pvmHostKernel.enabled=true; scheduled only to placement.pvm.
  • startupGate is on by default: when the target node fingerprint is not ready, a Helm pre-install/pre-upgrade Hook writes cube.tencent.com/pvm-not-ready=true:NoSchedule, then probes CNI node by node; if the fingerprint already matches, that taint is not written.
  • Before install/upgrade there is also a cubevs CIDR Hook (weight -110): if cubeNode.network.cidr (default 172.16.0.0/18) overlaps the cluster Service CIDR / ClusterIP, fail-fast.
  • init: pvm-host-bootstrap; mutate strictly follows ensure taint → delete dependent Pods in this namespace/this release/this node → invalidate → Lease → mutate/reboot.
  • Success path: write ready → verify live fingerprint → clear taint; main container reconciles split state every 30 seconds.
  • Only the PVM DaemonSet tolerates the temporary gate. CNI and kube-proxy must tolerate the gate with Exists or an explicit key. PVM stays on Pod network.
  • For PVM image upgrades only bump images.pvmHostBootstrap; do not recreate the Big Pod.

Why four pieces: separate artifact install from rebootable PVM bootstrap; non-PVM compute nodes do not pull the large PVM image; Installer / Bootstrap / PVM bumps can leave the Big Pod template untouched.

2.3.1 Markers you will see on the node

MarkerMeaning
pvm-host-readyHost PVM kernel is installed as expected; content includes a fingerprint that must match current uname after kernel swap to count as ready
effective-pvmWhether this node’s guest should use PVM (1) or bm (0); with allow-pvm-bootstrap and host ready → 1, otherwise → 0
node-prep-readyBootstrap preflight passed; Big Pod may start
/run/wait-node-prep.readyPer-Pod temporary marker for this round; gone on restart
“component ready” markers under toolboxThat component staged successfully; artifacts can be collected into the version matrix
“component replacing” markers under toolboxDirectory swap in progress; matrix marked incomplete; cleared on success, left until next success on failure

Guest kernel selection: first check effective-pvm; if missing, try to keep the kernel already in use on the node; only then fall back to the Chart’s first-install default (cubeNode.pvmGuestKernel.enabled).

2.4 Data-plane entry

ResourceChart templateResponsibility
cube-proxytemplates/proxy.yamlsandbox HTTP/HTTPS; placement.controlPlane; Pod network
cube-lifecycle-managertemplates/lifecycle-manager.yamlpause/resume; Proxy discovers replicas via Redis
cube-proxy-certsproxy.yamlTLS: selfSigned / inline / existingSecret / certManager
Service / Ingressproxy-service.yaml / proxy-ingress.yamlClusterIP; Ingress SSL passthrough, TLS terminated at Proxy
cluster DNStemplates/cluster-dns.yamlWhen enabled, rewrite *.cubeProxy.domain to the Proxy Service

CubeProxy forwards to the target compute-node sandbox via owner metadata in Redis.

3. DNS

The Chart does not deploy its own CoreDNS. When Proxy is enabled and configureClusterDNS=true (default):

  • A Helm hook rewrites domain / *.domain to <release>-proxy.<ns>.svc.cluster.local.
  • cubeNode.dns.sandbox.followNodeDns=true: guest follows node/cluster DNS.
  • Domain: cubeProxy.domain (default cube.app).
  • If the platform forbids changing kube-system/coredns, set cubeProxy.configureClusterDNS=false.
  • External clients still need their own public/Private DNS or LB.

4. Install and startup

4.1 Helm render

Main validations:

  • When enabling control plane / compute / Proxy, the matching placement.*.nodeSelector must be set.
  • configureClusterDNS=true requires cubeProxy.domain.
  • compute-only requires externalControlPlane.masterEndpoint.
  • When pvmHostKernel.enabled=true, placement.pvm must include allow-pvm-bootstrap, and it must not be written under placement.compute.
  • security.hostNetwork has been removed; cube-node is fixed to Pod network.

Scheduling: control plane uses placement.controlPlane; cube-node / installer / bootstrap use placement.compute; cube-node-pvm uses placement.pvm. Chart-managed containers get TZ injected via global.timezone (default Asia/Shanghai).

4.2 Control-plane startup

No separate cube-db-migrate Job; cubemastercli is not mixed into master/node images.

4.3 Compute-node startup

Probe conventions:

  • cubelet: startup waits on 9999; readiness defaults to exec (9999 + network-agent /readyz + sock); liveness checks 9999.
  • cube-egress: 127.0.0.1:9090/admin/v1/health.
  • cube-egress-net: cube-dev, ip rule, table 100, mangle TRANSPROXY.

4.4 Registration and acceptance checkpoints

  • CubeMaster /notify/health, CubeOps /health, CubeAPI /health (if enabled).
  • CubeAPI (or via CubeOps SDK) can see healthy nodes.
  • cube-node / installer / bootstrap ready counts equal the number of nodes matching placement.compute; cube-node-pvm ready count equals nodes matching placement.pvm.
  • When egress is enabled, sidecars are Ready.

5. Runtime data flows

5.1 WebUI / CubeOps / CubeAPI / Master

5.2 Sandbox entry

Without an Ingress Controller you can disable cubeProxy.ingress.enabled and wire external traffic to the Service yourself. Production should provide real certificates and point the sandbox domain at Ingress.

5.3 Outbound egress

Master / API / Node share cube-egress-ca so template builds and runtime trust stay consistent.

5.4 Template build

CubeMaster builds templates in-process via go-containerregistry (download + rootfs export). No Docker-in-Docker sidecar is required; artifacts are written to Master storage.

6. compute-only / external control plane

yaml
controlPlane:
  enabled: false
externalControlPlane:
  enabled: true
  masterEndpoint: <external-master>:8089
  apiEndpoint: http://<external-api>:3000  # optional, for helm test

Does not install built-in Master / API / MySQL / Redis / WebUI; by default does not install Proxy (to avoid inconsistency with an external data plane). When apiEndpoint is set, helm test validates the external API and node registration.

7. Key values toggles

values pathDefaultEffect
global.timezoneAsia/ShanghaiInjects TZ into Chart-managed containers
storageClass.create / name / provisionercreate=falseWhether the chart creates a StorageClass; default is no (PVCs use cluster default SC; TKE uses values-tke.yaml)
persistence.storageClassName""Shared SC for the three PVCs; "" → cluster default
*.persistence.storageClassName (master/mysql/redis)""Per-component override; non-empty wins over top-level
controlPlane.enabledtrueBuilt-in control plane
externalControlPlane.enabledfalseExternal CubeMaster
placement.controlPlane.nodeSelectorcube-control=trueControl-plane scheduling
placement.compute.nodeSelectorcube-node=trueCompute (without allow-pvm)
placement.pvm.nodeSelectoralso includes allow-pvm-bootstrap=truePVM host DaemonSet only
cubeProxy.domaincube.appsandbox domain
cubeProxy.configureClusterDNStrueWhether to write cluster CoreDNS
cubeNode.dns.sandbox.followNodeDnstrueguest follows node DNS
cubeNode.pvmGuestKernel.enabledtrueWhether first-install default prefers PVM guest
bootstrap.pvmHostKernel.enabledtruehost kernel bootstrap (may reboot nodes)
bootstrap.pvmHostKernel.startupGate.enabledtrueHard NoSchedule node taint gate when PVM is not ready
bootstrap.pvmHostKernel.bootArgsnopti pti=offCurrent kvm_pvm does not support host KPTI
bootstrap.nodeInit.*severalPreflight, XFS, KVM, CIDR
mysql.host / redis.host""Non-empty → use third-party
cubeProxy.enabled / ingress.enabledtrueProxy / Ingress
lifecycleManager.enabledtrueRequired when Proxy is enabled
cubeEgress.enabledtrueBig Pod egress sidecar
cubeOps.enabledtrueCubeOps (JWT ops API; WebUI upstream)
webui.enabledtrueWebUI (requires cubeOps.enabled=true)

8. Helm test

Test PodCoverage
<release>-health-testMaster / Ops / API / node registration / WebUI / Proxy / workload Ready / Egress presence
<release>-mysql-test / redis-testBuilt-in dependency connectivity
<release>-dns-testcube.app / wildcard → Proxy Service
<release>-node-image-testRuntime tools and assets inside the image
<release>-node-runtime-test/dev/kvm, cubelet / network-agent sockets
bash
helm test <release> -n <namespace> --timeout 20m --logs

9. Ownership and uninstall boundaries

The Chart manages and removes with the release: control- and compute-plane workloads, built-in MySQL/Redis, Proxy, CA/TLS/config Secrets, Helm test RBAC, diagnostics ConfigMap, etc.

The Chart does not manage: node labels/taints, third-party DBs, external DNS/LB, hostPath data, host kernel / GRUB / udev / fstab / XFS and other node-level persistent changes. After uninstall, clean host leftovers per platform runbook.


Next steps