Files
seaweedfs/seaweed-block/docs/quickstart-kubernetes.md
T
pingqiu-cpu 5ee720d341 docs: Kubernetes quickstart answers the C4 cell run (#993)
Merge note (batch b1; pull_request_target spec-trace workflow has a startup_failure, so its checks run locally):
- One Test run (47164144583) succeeded (go test (linux), process-level tests (real binaries)) on the integration tree 59f6e6ec = main 3ebcac06 + #971 #985 #992 #993  in this order; these squash merges reproduce that tree, verified after the last one.
- spec-trace-check.sh and public-text-check.sh, run with main's scripts against this head and body: both exit 0.
- Docs review ACCEPT on 8e08f88a: v1.1.0 is named as affected on all three pages, no fixed tag or digest is invented, images use $TAG, and the reader is placed on another Ready node that runs the CSI node plugin.
- Independent first-time operator run of this quickstart (three-node k3s) found these documentation gaps; this change answers them. The runtime rerun waits for the release that carries the generated-pod fix.
2026-12-03 10:20:17 -08:00

18 KiB

Kubernetes Quick Start

Use this when: you install the Kubernetes alpha with Helm on a supported test cluster and want to create, verify and clean up a first PVC-backed volume.

It shows the user loop:

generate Helm values
-> helm install
-> create a PVC-backed volume
-> write data from one app pod
-> read the same data from a replacement app pod
-> inspect read-only report/dashboard evidence
-> clean up

The current quickstart is for supported test clusters, not production. For the release boundary and exact QA evidence, see docs/releases/README.md. user-capabilities.md contains the current operations command matrix.

What This Proves

The quickstart proves:

  • Helm can install the alpha blockmaster and CSI components.
  • A PVC can dynamically provision a Seaweed Block-backed PV.
  • A writer pod can mount the PVC and write /data/demo.bin.
  • A replacement reader pod can mount the same PVC and verify the same data.
  • Product-owned status evidence, a local read-only report, and a local read-only dashboard are available.
  • The report/dashboard include operator-snapshot.json, a read-only operator-facing status projection. It is not a mutating operator.
  • The gated operator-status path can publish the same read-only vocabulary into SwBlockCluster / SwBlockVolume .status and Kubernetes Events. It is status/events only and does not create CR objects or mutate storage.
  • The example resources and host-side residue are cleaned up.

It does not prove production HA, backup/restore, broad upgrade safety, broad platform compatibility, a mutating operator, or a production UI; see what you should not expect yet.

Prerequisites

Run from a Linux host with access to your Kubernetes cluster:

  • kubectl configured for the target cluster.
  • helm installed.
  • sudo access for iSCSI checks and cleanup.
  • iscsiadm available on nodes that will stage volumes.
  • the sw-block CLI and a checkout of the release tag (Step 0).

Check the cluster:

kubectl get nodes -o wide
sudo iscsiadm -m session || true

Expected before starting:

at least one Ready node
iscsiadm: No active sessions.

Step 0 - Get The Repository And The CLI

v1.1.0 is affected: do not use it for this procedure. Its generated blockvolume pod cannot start: it cannot create /run/sw-block as uid 65532, and its node TLS Secret must also be found in the app's namespace. Use the first release that contains both fixes; its release notes name them. This procedure is validated only on that release.

Run everything from a checkout of the release tag you install, so the chart, the scripts and the images match. Set TAG to that release:

TAG=<the fixed release tag>        # not v1.1.0, see above
git clone --depth 1 --branch $TAG https://github.com/seaweedfs/seaweed-block && cd seaweed-block

kubectl access. On k3s, /etc/rancher/k3s/k3s.yaml is readable only by root unless k3s was installed with --write-kubeconfig-mode 0644. Give your user its own copy:

mkdir -p ~/.kube && sudo cp /etc/rancher/k3s/k3s.yaml ~/.kube/config
sudo chown "$(id -u):$(id -g)" ~/.kube/config && chmod 600 ~/.kube/config
export KUBECONFIG=$HOME/.kube/config
kubectl get nodes

On other distributions, keep your existing KUBECONFIG.

The sw-block CLI. Take it from the release tarball (see operations manual, section 1 for the checksum step):

curl -fsSLO https://github.com/seaweedfs/seaweed-block/releases/download/$TAG/sw-block-$TAG-linux-amd64.tar.gz
curl -fsSLO https://github.com/seaweedfs/seaweed-block/releases/download/$TAG/SHA256SUMS
sha256sum -c --ignore-missing SHA256SUMS && tar -xzf sw-block-$TAG-linux-amd64.tar.gz --strip-components=1
export PATH="$PWD:$PATH"
sw-block --version

To build it instead, install the Go version that go.mod names, as in appendix A of the operations manual, then run go build -o sw-block ./cmd/sw-block.

Step 1 — Generate Helm Values

From the repository root:

sw-block ops generate-helm-values \
  --out values.day1.yaml \
  --image ghcr.io/seaweedfs/seaweed-block:$TAG \
  --csi-image ghcr.io/seaweedfs/seaweed-block-csi:$TAG

Use the images of the same release as the checkout: the chart passes flags (for example --tls-cert and --master-tls-cert) that older images do not know, and such a pod restarts in a loop until helm install --wait times out.

What this command does:

  • reads Kubernetes nodes through kubectl get nodes -o wide,
  • selects Ready schedulable nodes with non-loopback InternalIP,
  • writes values.day1.yaml for the Helm chart.

Single-node behavior:

  • one selected node,
  • loopback iSCSI/status mode,
  • CHAP disabled.

Multi-node behavior:

  • multiple selected nodes,
  • non-loopback iSCSI addresses (volume status stays on loopback),
  • CHAP enabled,
  • loopback publish-target rejection recorded in values.

Inspect the generated values:

grep -E "externalISCSI|externalStatus|replicationFactor|ackProfile|enabled:|internalIP" values.day1.yaml

To check what you pulled, compare the image index digests with the ones on the release page of $TAG.

Use release tags (vX.Y.Z). A sha-<commit> tag exists only for some commits, and an old one does not match a newer chart. Mutable :alpha is a smoke/demo tag only. Do not use it as release evidence.

Step 2 — Install Seaweed Block With Helm

blockmaster listens on the pod network only with mutual TLS, so create its Secrets first. For a trial, the helper issues a development CA and one node certificate per server id. The server ids must be exactly the blockNodes[].name values in values.day1.yaml (or their serverID, where set). Read them from the file instead of typing them; generate-helm-values prints node-a node-b node-c as placeholders:

NODES=$(awk '/^blockNodes:/{f=1; next} f && /^[^ -]/{f=0} f && /^ *- name:/{print $3}' values.day1.yaml)
echo $NODES                                   # your node names, for example az1-c4a az1-c4b az1-c4c
bash scripts/k8s-alpha-certs.sh kube-system ~/.sw-block-alpha-tls $NODES

It applies sw-block-master-tls, sw-block-roles, one Secret per in-cluster client (sw-block-csi-controller-tls, sw-block-csi-node-tls, sw-block-operator-status-tls, sw-block-failback-executor-tls, each with the least role it needs) and sw-block-node-tls-<server id>. Keep the directory private: a node key controls that host's volumes. For production, issue them from your own CA (operator guide).

helm install sw-block charts/seaweed-block \
  --namespace kube-system \
  --create-namespace \
  -f values.day1.yaml \
  --wait \
  --timeout 10m

Check readiness:

kubectl -n kube-system get deploy,ds,pods -l app.kubernetes.io/instance=sw-block -o wide
kubectl get storageclass

Expected:

sw-blockmaster ready
sw-block-csi-controller ready
sw-block-csi-node ready on selected nodes
StorageClass present

Step 3 — Create And Verify The First Volume

Run the first-volume helper in Helm mode:

SW_BLOCK_INSTALL_MODE=helm \
SW_BLOCK_HELM_RELEASE=sw-block \
SW_BLOCK_HELM_NAMESPACE=kube-system \
SW_BLOCK_HELM_VALUES_FILE=values.day1.yaml \
  bash scripts/run-basic-app-example.sh "$PWD"

The "$PWD" argument is the repository root. The helper uses it to locate the example manifests and chart metadata.

The helper applies the example StorageClass/PVC, waits for the PVC to bind, runs a writer pod, deletes it, runs a reader pod, collects status evidence, generates a local report, and cleans the example resources by default.

Current helper scope: the example app resources use the default namespace. Use the documented example as-is for the v0.3 alpha gate. Cross-namespace helpers are a later usability enhancement; Kubernetes can still consume the installed CSI driver from other namespaces through normal PVC manifests.

Expected final line:

[basic-app] PASS: basic app PVC writer/reader loop complete

Read the first-volume summary:

APP_DIR="$(ls -td /tmp/sw-block-basic-app-* | head -1)"
cat "$APP_DIR/first-volume-summary.txt"

Expected fields:

first_volume_status=ok
pvc=sw-block-example-pvc
pvc_phase=Bound
writer_verified=true
reader_verified=true
inventory_status=ok
status_evidence=status/cluster-evidence.json,status/inventory
cluster_evidence=status/cluster-evidence.json
inventory_bundle=status/inventory
status_report=status/report/index.html
operator_snapshot=status/report/operator-snapshot.json
cleanup_status=ok

The writer and reader are ordinary app pods. The reader is a replacement pod, so this proves the data is on the PVC-backed volume, not only in the writer container.

Step 4 — Inspect Report Or Dashboard

The first-volume helper writes a status report:

ls "$APP_DIR/status/report"
cat "$APP_DIR/status/report/summary.txt"

Expected files:

index.html
cluster-evidence.json
timeline.jsonl
operator-snapshot.json
summary.txt

sw-block ops report writes static artifacts. sw-block ops dashboard serves the same evidence locally over HTTP. operator-snapshot.json uses the same ManagedVolume status vocabulary as the report/dashboard and is the status-only foundation for future Kubernetes operator work.

Important status vocabulary:

  • Ready=True reason=first_volume_verified means the report has positive writer/reader evidence for the volume.
  • Blocked=True reason=<stable_reason_code> means the product found a known blocker, such as csi_node_image_pull_failed.
  • EvidenceStale=True or Ready=Unknown means the evidence is missing, stale, or still reconverging. The alpha status surface should not claim Ready=True without current evidence.

Serve the collected bundle:

sw-block ops dashboard --from-bundle "$APP_DIR" --listen 127.0.0.1:9334

$APP_DIR is the basic-app artifact root. The dashboard/report loader finds the nested status/report/, status/cluster-evidence.json, and inventory artifacts under that root.

Open:

http://127.0.0.1:9334/

The dashboard is read-only. It has no promote, repair, rebuild, delete, failback, backup, restore, or cleanup controls.

To generate live evidence from blockmaster:

kubectl -n kube-system port-forward deploy/sw-blockmaster 9333:9333

In another terminal:

MASTER_TLS=(--master-tls-cert "$HOME/.sw-block-alpha-tls/operator-status.crt"
            --master-tls-key "$HOME/.sw-block-alpha-tls/operator-status.key"
            --master-ca "$HOME/.sw-block-alpha-tls/ca.crt")
sw-block ops cluster --master-api 127.0.0.1:9333 "${MASTER_TLS[@]}"
sw-block ops report --master-api 127.0.0.1:9333 "${MASTER_TLS[@]}" --out /tmp/sw-block-report
sw-block ops dashboard --master-api 127.0.0.1:9333 "${MASTER_TLS[@]}" --listen 127.0.0.1:9334

These read-only commands use the viewer certificate issued for operator-status in Step 2. Keep its private key local. The flags default to SW_BLOCK_TLS_CERT, SW_BLOCK_TLS_KEY, and SW_BLOCK_TLS_CA when set. Supply all three TLS files; the client verifies the master certificate against the CA.

Use Your Own PVC

The standard volume creation path is Kubernetes PVC creation. Start from the example, which is written for the default namespace:

kubectl apply -f examples/kubernetes/basic-app/storageclass-pvc.yaml
kubectl get pvc sw-block-example-pvc

Then mount the PVC from your own pod, or use the example writer and reader:

kubectl apply -f examples/kubernetes/basic-app/writer-pod.yaml
kubectl wait --for=jsonpath='{.status.phase}'=Succeeded pod/sw-block-example-writer --timeout=240s
kubectl logs sw-block-example-writer

WRITER_NODE=$(kubectl get pod sw-block-example-writer -o jsonpath='{.spec.nodeName}')
kubectl delete pod sw-block-example-writer

Several nodes: read on another node. To show that the data follows the volume, run the reader on a node other than the writer's. The node must be Ready and run a CSI node plugin pod: setting spec.nodeName bypasses the scheduler, so pick it from the plugin pods:

READER_NODE=$(kubectl -n kube-system get pods -l app=sw-block-csi-node --field-selector=status.phase=Running \
    -o jsonpath='{range .items[*]}{.spec.nodeName}{"\n"}{end}' | grep -vx "$WRITER_NODE" |
  while read -r n; do
    test "$(kubectl get node "$n" -o jsonpath='{.status.conditions[?(@.type=="Ready")].status}')" = True && echo "$n"
  done | head -1)
echo "reader node: ${READER_NODE:-none eligible}"
test -n "$READER_NODE" &&
  kubectl patch --local -f examples/kubernetes/basic-app/reader-pod.yaml --type merge \
    -p "{\"spec\":{\"nodeName\":\"$READER_NODE\"}}" -o yaml | kubectl apply -f -
kubectl wait --for=jsonpath='{.status.phase}'=Succeeded pod/sw-block-example-reader --timeout=240s
kubectl logs sw-block-example-reader
echo "writer ran on $WRITER_NODE, reader on $(kubectl get pod sw-block-example-reader -o jsonpath='{.spec.nodeName}')"

If it prints none eligible, no other node qualifies, and the cross-node read is not shown; use the single-node path below.

One node: apply examples/kubernetes/basic-app/reader-pod.yaml unchanged. The reader then runs on the writer's node. The helper in Step 3 does not choose nodes either.

The generated blockvolume workload is reconciled by blockmaster. You should not manually apply generated blockvolume YAML on the supported alpha path.

Script Fallback Path

The script path remains available for development, local images, and fallback diagnostics:

bash scripts/activate-k8s-alpha.sh "$PWD"
bash scripts/run-basic-app-example.sh "$PWD"

The "$PWD" argument is the repository root for both helper scripts.

Use Helm unless you are specifically testing local script activation.

Troubleshooting

Start with the latest basic-app artifact directory:

APP_DIR="$(ls -td /tmp/sw-block-basic-app-* | head -1)"
cat "$APP_DIR/first-volume-summary.txt" 2>/dev/null || true
find "$APP_DIR" -maxdepth 3 -type f | sort

Common evidence:

cat "$APP_DIR/status/cluster-evidence.json" 2>/dev/null || true
cat "$APP_DIR/status/inventory/volume-inventory-summary.txt" 2>/dev/null || true
cat "$APP_DIR/diagnostics/writer/writer-describe.txt" 2>/dev/null || true
cat "$APP_DIR/diagnostics/reader/reader-describe.txt" 2>/dev/null || true

If a pod cannot mount the PVC, writer-describe.txt or reader-describe.txt should include the Kubernetes event explaining why, such as image pull failure, iSCSI connection failure, missing CHAP secret, or scheduling mismatch.

Attach the artifact directory and any /tmp/sw-block-report output when filing an issue.

After a failed helper run, the example resources stay (StorageClass, PVC and PV, the writer or reader pod, the generated blockvolume Deployment). Remove them before running the helper again or uninstalling:

kubectl delete pod sw-block-example-writer sw-block-example-reader --ignore-not-found
kubectl delete -f examples/kubernetes/basic-app/storageclass-pvc.yaml --ignore-not-found
kubectl get pv,deploy -A | grep sw-block-example || echo "example resources gone"   # the PV and Deployment go within seconds

Cleanup

The first-volume helper cleans the example resources by default (after a failed run, see Troubleshooting first). To uninstall the alpha stack:

helm uninstall sw-block --namespace kube-system
bash scripts/uninstall-k8s-alpha.sh "$PWD"
# the Step 2 TLS Secrets: the uninstall leaves them
kubectl -n kube-system delete secret sw-block-master-tls sw-block-roles sw-block-csi-controller-tls \
  sw-block-csi-node-tls sw-block-operator-status-tls sw-block-failback-executor-tls --ignore-not-found
kubectl -n kube-system get secret -o name | grep '^secret/sw-block-node-tls-' | xargs -r kubectl -n kube-system delete
bash scripts/verify-helm-cleanup.sh

Two things stay on purpose:

  • The custom resource definitions. Helm never deletes CRDs, and the uninstall script removes only swblockreplicafailbacks. The other five (swblockclusters, swblockfrontendpublications, swblockreplicaeligibilities, swblockreplicarebuilds, swblockvolumes, all .block.seaweedfs.com) stay, and a later install reuses them. To remove them, and every object of those kinds: kubectl delete -f charts/seaweed-block/crds/ --ignore-not-found.
  • An empty kubelet plugin directory on each node, /var/lib/kubelet/plugins/block.csi.seaweedfs.com. It holds nothing; remove it on each node with sudo rmdir /var/lib/kubelet/plugins/block.csi.seaweedfs.com if you want. The verifier's hostpath_residue_count does not look at it.

The uninstall script removes Kubernetes resources and scrubs Seaweed Block iSCSI sessions and iSCSI node DB records. The verifier checks the same residue classes used by release QA.

Manual spot checks:

kubectl get sc | grep sw-block || echo "no sw-block StorageClass"
kubectl get deploy -A | grep sw-block || echo "no sw-block deployments"
sudo iscsiadm -m session || true
sudo iscsiadm -m node | grep io.seaweedfs || echo "no Seaweed Block iSCSI node records"

Expected clean state:

cleanup_status=ok
k8s_residue_count=0
iscsi_residue_count=0
multipath_residue_count=0
process_residue_count=0
hostpath_residue_count=0
no sw-block StorageClass
no sw-block deployments
iscsiadm: No active sessions.
no Seaweed Block iSCSI node records

Do not run broad cluster cleanup commands in a shared cluster unless you know no other run owns the resources.

Current Alpha Limitations

This is an alpha Helm path, not a production installer or operator. The dashboard is local and read-only. Broad upgrade and rollback safety are not claimed beyond the gated alpha smoke path, and performance, RTO and SLO numbers are not claimed. The full list is in what you should not expect yet.