Skip to content

Pilot cluster installation guide

Step-by-step record of how the pilot cluster is built, with the reason for every step. Written while installing; each step was run and verified before the next one.

  • Repo files used by later steps live in this folder (apps/, playtelly/). See README.md for the layout.
  • Commands are run as the normal test user with sudo where shown.

0. Environment

Node (Kubernetes name) OS hostname IP Role
jas-mnt-01 JAS-MNT-01 10.4.1.78 control-plane + etcd + worker
jas-mnt-02 JAS-MNT-02 10.4.1.79 control-plane + etcd + worker
jas-ans-01 JAS-ANS-01 10.4.0.43 control-plane + etcd + worker
  • OS: Oracle Linux Server 9.6, SELinux Permissive, firewalld inactive.
  • Disks (identical on all three): / 103G, /data 1.1T (own LV, shared by every data product), /data/app 150G (separate LV, not used).
  • Kubernetes node names must be lowercase, so they are set explicitly with node-name even though the OS hostnames are uppercase.
  • The nodes have internet access (GitHub and Nexus reachable), so k3s is installed online.
  • The join token is a secret. It is shown as <TOKEN> below; never commit it.

1. Preflight (all nodes)

Read-only checks to find what the nodes already have before installing anything:

cat /etc/os-release | head -3
hostnamectl --static; getenforce; swapon --show; systemctl is-active firewalld chronyd iscsid multipathd
rpm -q iscsi-initiator-utils nfs-utils container-selinux
curl -sI --max-time 8 https://get.k3s.io | head -1; curl -sI --max-time 8 https://registry.nexus.castis.io | head -1

What each check is for:

Check Why
OS, SELinux decides which k3s packages are needed
Swap Kubernetes expects swap off; swapping also hurts etcd and Longhorn latency
firewalld would have to be stopped or opened for k3s ports
chronyd time must be in sync across nodes (etcd, certificates)
iscsid, iscsi-initiator-utils Longhorn attaches volumes over iSCSI
nfs-utils Longhorn ReadWriteMany volumes (Grafana's PVC) use NFS
multipathd conflicts with Longhorn devices; must be off
curl to get.k3s.io / Nexus confirms the nodes can reach the k3s installer and Nexus (a 400 from Nexus on a bare URL is normal)

Result on all three nodes: everything fine except swap on, container-selinux missing, and no /data/... folders.

2. Prepare the nodes (all nodes)

Create the data folders (required). Longhorn stores its replicas under /data/longhorn, and the local-path provisioner (section 6b) puts the VictoriaMetrics, VictoriaLogs and ClickHouse volumes under /data/local-path (one folder per claim, created automatically). A pod fails to start if its path does not exist.

sudo mkdir -p /data/longhorn /data/local-path
sudo chown -R 101:101 /data/local-path         # ClickHouse runs as uid 101; the provisioner makes the claim folders 0777

A new install needs only these two folders. Earlier drafts of this guide also created one folder per product (/data/victoriametrics/..., /data/victorialogs/..., /data/clickhouse/..., and /data/victorialogs/vlselect-cache) for hand-written static PVs. Static PVs were dropped in favour of the provisioner, which creates its own folders under /data/local-path, so those product folders are empty and unused. If you created them, remove them (rmdir refuses to delete a folder that is not empty, so it is safe):

sudo rmdir /data/victoriametrics/* /data/victorialogs/* /data/clickhouse/* 2>/dev/null
sudo rmdir /data/victoriametrics /data/victorialogs /data/clickhouse

Turn swap off (recommended).

sudo swapoff -a && sudo sed -i '/\sswap\s/ s/^/#/' /etc/fstab && swapon --show     # prints nothing

Deliberately skipped:

  • /etc/hosts entries: k3s nodes join by IP, so name resolution between nodes is not needed.
  • container-selinux: only needed for k3s's SELinux policy; SELinux is Permissive, so the installer is told to skip it (INSTALL_K3S_SKIP_SELINUX_RPM=true). Revisit if SELinux is ever set to Enforcing.

Verify: swapon --show; ls -ld /data/longhorn /data/local-path

3. First k3s server: jas-mnt-01

Generate a join token once and keep it safe:

openssl rand -hex 24

Config file (/etc/rancher/k3s/config.yaml):

sudo mkdir -p /etc/rancher/k3s && sudo tee /etc/rancher/k3s/config.yaml <<'EOF'
token: <TOKEN>
cluster-init: true
node-name: jas-mnt-01
node-ip: 10.4.1.78
tls-san:
  - 10.4.1.78
  - jas-mnt-01
write-kubeconfig-mode: "644"
disable:
  - traefik
  - local-storage
EOF

Install (version pinned to v1.36.4+k3s1, the stable release at install time):

curl -sfL https://get.k3s.io | sudo INSTALL_K3S_VERSION='v1.36.4+k3s1' INSTALL_K3S_SKIP_SELINUX_RPM=true sh -s - server
sudo systemctl is-active k3s; kubectl get nodes -o wide

Expected: jas-mnt-01 Ready control-plane,etcd.

Why these settings:

Setting Why
cluster-init: true starts the embedded etcd cluster (HA, same as production); the other nodes join it
node-name / node-ip lowercase Kubernetes name regardless of OS hostname; pin the interface/IP the cluster uses
tls-san extra names/IPs the API server certificate must be valid for
write-kubeconfig-mode: "644" lets a normal user read /etc/rancher/k3s/k3s.yaml, so kubectl works without sudo
disable: traefik APISIX is the ingress, Traefik is not needed
disable: local-storage removes k3s's built-in local-path provisioner and default StorageClass (see below)
ServiceLB (left enabled) exposes LoadBalancer services (APISIX) on the node IPs, so MetalLB is not needed

Why disable: local-storage (changed later: see 6b)

Update: the pilot now uses the local-path provisioner for the big data volumes, so - local-storage is removed from the disable: list again (section 6b). The reasoning below is why it was first off.

Rebuilding from scratch? Skip the two-step path: in sections 3 to 5 write the final config directly (disable: with only - traefik, plus the line default-local-storage-path: /data/local-path), and in section 6b do only the checks.

k3s ships a provisioner that creates a folder on the node's root disk for any claim that does not name a StorageClass. Left on, a claim that forgets its class would silently land on unreplicated local disk, and two "default" storage systems would compete. The pilot first used only static local-path-vm PVs (Victoria, ClickHouse) and Longhorn, and every claim in the repo names its class explicitly, so nothing depends on the default. Longhorn-backed volumes stay Pending until Longhorn is installed (that is expected).

Why kubectl works directly

The installer creates /usr/local/bin/kubectl as a symlink to the k3s binary, which has kubectl built in. That kubectl reads /etc/rancher/k3s/k3s.yaml by default, and write-kubeconfig-mode: "644" makes the file readable by a normal user. Helm and other standalone tools do not know this file, so before any Helm command run:

export KUBECONFIG=/etc/rancher/k3s/k3s.yaml
echo 'export KUBECONFIG=/etc/rancher/k3s/k3s.yaml' >> ~/.bashrc     # optional, permanent

The file is readable by every user on the node, which means any local login is cluster admin. Acceptable for the pilot; tighten with write-kubeconfig-mode: "600" later.

4. Join jas-mnt-02

Join one server at a time (etcd adds members one by one). Same token and same disable: list as node 1; no cluster-init; server: points at node 1.

sudo mkdir -p /etc/rancher/k3s && sudo tee /etc/rancher/k3s/config.yaml <<'EOF'
server: https://10.4.1.78:6443
token: <TOKEN>
node-name: jas-mnt-02
node-ip: 10.4.1.79
tls-san:
  - 10.4.1.79
  - jas-mnt-02
write-kubeconfig-mode: "644"
disable:
  - traefik
  - local-storage
EOF
curl -sfL https://get.k3s.io | sudo INSTALL_K3S_VERSION='v1.36.4+k3s1' INSTALL_K3S_SKIP_SELINUX_RPM=true sh -s - server
sudo systemctl is-active k3s; kubectl get nodes -o wide

Result (confirmed): jas-mnt-01 and jas-mnt-02 both Ready control-plane,etcd, same list, v1.36.4+k3s1.

What makes two nodes one cluster: the server: line says which cluster to join, and the token is the password that cluster checks. The token alone is not enough; a node with the token but no server: would start its own new cluster. Proof of a shared cluster is both nodes appearing in the same kubectl get nodes.

Note: with only two etcd members the cluster needs both to keep quorum (no fault tolerance yet). The third join fixes this.

5. Join jas-ans-01

Same as section 4 with this node's name and IP. After this, etcd has three members and tolerates losing one node.

sudo mkdir -p /etc/rancher/k3s && sudo tee /etc/rancher/k3s/config.yaml <<'EOF'
server: https://10.4.1.78:6443
token: <TOKEN>
node-name: jas-ans-01
node-ip: 10.4.0.43
tls-san:
  - 10.4.0.43
  - jas-ans-01
write-kubeconfig-mode: "644"
disable:
  - traefik
  - local-storage
EOF
curl -sfL https://get.k3s.io | sudo INSTALL_K3S_VERSION='v1.36.4+k3s1' INSTALL_K3S_SKIP_SELINUX_RPM=true sh -s - server
sudo systemctl is-active k3s; kubectl get nodes -o wide

Note: jas-ans-01 is on a different subnet (10.4.0.x) from the other two (10.4.1.x). It must be able to reach 10.4.1.78:6443 and the other nodes on the k3s ports (etcd 2379-2380, kubelet 10250, flannel VXLAN 8472/udp). firewalld is inactive, so a failure here would be a network/router rule.

Result (confirmed): all three nodes Ready control-plane,etcd, v1.36.4+k3s1, one cluster, etcd now has 3 members. jas-ans-01 runs Oracle Linux 9.8 (kernel 5.14.0-687) while the other two run 9.6; k3s joined without issue, but keep it in mind if a kernel-specific problem (Longhorn iSCSI, CNI) shows up on that node only.

6. Node labels and Helm

Labels. The Victoria, ClickHouse charts and StatefulSets select nodes by label, so pods stay Pending without them. Run once, on any node:

kubectl label node jas-mnt-01 jas-mnt-02 jas-ans-01 \
  node.victoriametrics.com/storage=true node.victoriametrics.com/role=metrics \
  victorialogs=enabled clickhouse=true
Label Used by
node.victoriametrics.com/storage=true vmstorage nodeSelector
node.victoriametrics.com/role=metrics vmselect, vminsert, vmagent, vmalert, alertmanager, kube-state-metrics
victorialogs=enabled vlstorage, vlselect, vlinsert, vmauth (VictoriaLogs chart)
clickhouse=true ClickHouse and Keeper StatefulSets

Helm (optional). Nothing is installed with it: ArgoCD runs Helm itself for Longhorn, APISIX, cert-manager, VictoriaMetrics and VictoriaLogs. A local Helm is only used to inspect charts (helm show values, helm template, and the image list in section 12). Install it on any node (Helm is only a client; it talks to the cluster through KUBECONFIG). Version used: v3.22.0:

curl -fsSL https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | DESIRED_VERSION=v3.22.0 sudo -E bash
export KUBECONFIG=/etc/rancher/k3s/k3s.yaml
helm version --short

Result (confirmed): each label is on all 3 nodes (clickhouse=true x3, victorialogs=enabled x3). Helm upgraded from v3.14.0 to v3.22.0 on jas-ans-01. The script prints helm not found. Is /usr/local/bin on your $PATH? Failed to install helm because it checks the path under sudo (shorter secure_path); the binary is installed and helm version --short prints v3.22.0+g144ca65, so the message is harmless. Helm was installed on jas-ans-01; the repo commands in sections 7 to 13 were run from jas-mnt-01.

6b. Local-path provisioner for the big data volumes (replaces the static PVs)

Plan change: instead of hand-written static PVs, VictoriaMetrics, VictoriaLogs and ClickHouse (+ Keepers) get their volumes from the Rancher local-path provisioner, through the StorageClass local-path-retain-expand (apps/monitoring-base/storage-class.yaml):

Setting Why
provisioner: rancher.io/local-path the provisioner k3s ships; creates one folder per claim on the node where the pod is scheduled
reclaimPolicy: Retain the data folder is kept when a claim is deleted (the k3s default class deletes it)
allowVolumeExpansion: true a claim's size can be raised. The provisioner does not enforce sizes, so this only changes the recorded number; real growth is the disk (lvextend -r on /data)
volumeBindingMode: WaitForFirstConsumer the folder is made on the node the pod lands on
parameters.nodePath: /data/local-path folders go under /data/local-path/pvc-<uid>_<namespace>_<claim>, not on the 103G root disk (allowed only because k3s is started with default-local-storage-path: /data/local-path, see below)

Consequences: no PV files, no per-product host folders, and no selector on the claims (Kubernetes does not allow a selector with dynamic provisioning).

The provisioner is the one built into k3s, which section 3 turned off. Turn it back on, one node at a time (wait for the node to be Ready before the next):

sudo sed -i '/^  - local-storage$/d' /etc/rancher/k3s/config.yaml
echo 'default-local-storage-path: /data/local-path' | sudo tee -a /etc/rancher/k3s/config.yaml
cat /etc/rancher/k3s/config.yaml
sudo systemctl restart k3s && kubectl get nodes

default-local-storage-path is required, not optional. The Rancher provisioner only accepts folders listed in its own config (local-path-config ConfigMap in kube-system, managed by k3s), which by default lists only /var/lib/rancher/k3s/storage. Without this setting, claims stay Pending with config doesn't contain path /data/local-path on node ... in the provisioner log (found while installing; it fails safely instead of writing to the root disk). Set it on all three servers, one at a time. Afterwards confirm the path and restart the provisioner: it retries a failing claim only about 15 times, so a claim that failed before the fix stays Pending until the provisioner is restarted and looks at it again:

kubectl -n kube-system get configmap local-path-config -o jsonpath='{.data.config\.json}'; echo       # path must be /data/local-path
kubectl -n kube-system rollout restart deploy local-path-provisioner

The disable: list should now contain only traefik. k3s then creates its own default StorageClass local-path (marked default); every claim in this repo names its class, so nothing uses it.

Important check after the first volume is created (when the VictoriaMetrics or ClickHouse claims appear):

kubectl get pv -o custom-columns=NAME:.metadata.name,CLASS:.spec.storageClassName,PATH:.spec.hostPath.path,CLAIM:.spec.claimRef.name

PATH must start with /data/local-path/. If it shows /var/lib/rancher/k3s/storage/..., the nodePath parameter was ignored and the data would land on the root disk: stop before any data is written and fix the StorageClass / k3s setting.

Result (confirmed): kubectl get configmap local-path-config shows /data/local-path; volumes are created under /data/local-path/pvc-<uid>_<namespace>_<claim> (checked with the PATH query above). A custom pathPattern in the StorageClass is rejected by the provisioner (pathPattern must start with ...), so it is not used. The StorageClass cannot be edited in place: delete it and ArgoCD recreates it.

7. Put the repo files on the node

ArgoCD installs everything else from git, but the first steps are kubectl apply on files in this folder: ArgoCD itself (section 10), the secrets (section 11) and the root Application (section 13). So environments/pilot/ must exist on the node you work from (here jas-mnt-01).

Option A, git (recommended; ArgoCD reads the same repo from main):

git config --global credential.helper store            # remember the login after the first time
git clone https://mashup.castis.io/3bb-tv/jastv-iac.git ~/jastv-iac
# asks once for Username / Password: use the pilot deploy token (username gitlab+deploy-token-15, password = the token)
cd ~/jastv-iac/environments/pilot
git pull                                               # later updates, no login prompt

The same deploy token is what ArgoCD uses to read the repo (playtelly/repo-secret.yml). credential.helper store keeps it in ~/.git-credentials (file mode 600) on that node, so only do this on a node you trust.

Option B, copy from the workstation without pushing:

scp -r environments/pilot test@<node-ip>:~/pilot      # run on the workstation, from the repo root

Result (confirmed): the repo is cloned on jas-mnt-01 (~/jastv-iac, deploy token as login). From here on every change is: commit and push on the workstation, git pull on the node.

8. Longhorn (replicated storage for Grafana, APISIX etcd and playtelly)

Longhorn gives the volumes that must survive a node loss (3 copies, one per node). VictoriaMetrics, VictoriaLogs and ClickHouse do not use it; they use local-path volumes on /data, which is why Longhorn is limited to a small slice of /data.

Values file: apps/longhorn/longhorn-values.yaml.

Value Why
defaultDataPath: /data/longhorn replicas are stored here on every node
defaultReplicaCount: 3 one copy per node
storageReservedPercentageForDefaultDisk: 90 /data is 1.1T and shared with local-path volumes Longhorn cannot see; reserving 90% leaves Longhorn about 110Gi per node
storageOverProvisioningPercentage: 100 no over-provisioning: it applies to what is left after the reservation, so Longhorn schedules at most about 110Gi per node (not the whole 1.1T)
persistence.defaultClass: false every claim names its class, Longhorn must not become the cluster default

Because of the 3-way replication, every node holds a copy of every volume, so usable Longhorn capacity is about 110Gi in total (not 330Gi). Requested volumes: Grafana 15, Postgres 20, SeaweedFS 20, NATS 5, VerneMQ 3, Valkey 1, cproxy 0.1 and APISIX etcd 3 x 2 = 6, about 70Gi, which fits. SeaweedFS (object storage) is the one most likely to outgrow its 20Gi; revisit the reservation if it does.

Preflight on all three nodes (Longhorn talks to the kernel over iSCSI):

sudo modprobe iscsi_tcp && lsmod | grep iscsi_tcp
echo iscsi_tcp | sudo tee /etc/modules-load.d/iscsi_tcp.conf      # load it again after reboot
systemctl is-active iscsid

Install. Nothing is run by hand: ArgoCD does it. argocd/apps/10-longhorn.yaml (wave 1) is the Helm chart longhorn 1.12.2 (repo https://charts.longhorn.io) with apps/longhorn/longhorn-values.yaml, and argocd/apps/20-longhorn-config.yaml (wave 2) applies the StorageClasses and backup target in apps/longhorn/config/. To check:

kubectl -n argocd get applications longhorn longhorn-config
kubectl -n longhorn-system get pods
kubectl get sc

Expected StorageClasses, among others: longhorn (created by the chart, not default), longhorn-worker, longhorn-control-plane, apisix-etcd-longhorn, local-path-retain-expand, and k3s's own local-path (the only one marked (default)).

Result (confirmed): Longhorn is installed by ArgoCD (Application longhorn, wave 1), not by hand. One setting is required for ArgoCD: preUpgradeChecker.jobEnabled: false. The chart's longhorn-pre-upgrade Job is a Helm hook that ArgoCD runs before the rest of the chart, it needs a ServiceAccount the chart creates later, so it never completes and the sync hangs (waiting for completion of hook batch/Job/longhorn-pre-upgrade). Requires the iscsi_tcp kernel module on every node (section 1/2).

9. TLS certificate for the *.cdn.3bbtv.com routes (gslb-tls-secret)

The ApisixTls objects of the monitoring routes (metric, logs, monitor, clickhouse) read the Secret gslb-tls-secret from their own namespace, so it must exist in monitoring and clickhouse. It is not in git. It was copied from production by hand, because the two clusters are separate and cannot reach each other.

  1. On the production node, print a clean Secret manifest (no namespace, no cluster-specific fields):
kubectl -n monitoring get secret gslb-tls-secret -o go-template='apiVersion: v1{{"\n"}}kind: Secret{{"\n"}}type: kubernetes.io/tls{{"\n"}}metadata:{{"\n"}}  name: gslb-tls-secret{{"\n"}}data:{{"\n"}}  tls.crt: {{index .data "tls.crt"}}{{"\n"}}  tls.key: {{index .data "tls.key"}}{{"\n"}}'
  1. Get the output onto a pilot node as /tmp/gslb-tls-secret.yaml (copy it with scp, or paste into cat > ...).
  2. Create it in both namespaces (any node works: it is one cluster) and delete the file:
for ns in monitoring clickhouse; do kubectl create namespace $ns --dry-run=client -o yaml | kubectl apply -f -; kubectl apply -n $ns -f /tmp/gslb-tls-secret.yaml; done
kubectl get secret gslb-tls-secret -n monitoring; kubectl get secret gslb-tls-secret -n clickhouse
shred -u /tmp/gslb-tls-secret.yaml

Result (confirmed): gslb-tls-secret kubernetes.io/tls 2 in both namespaces.

Notes: - Certificate: CN=cdn.3bbtv.com, SAN *.cdn.3bbtv.com + cdn.3bbtv.com, Let's Encrypt, valid 16 Oct 2026 to 14 Jan 2027. It must be renewed before then; copy the renewed secret the same way (or reissue it in the pilot). - The Secret contains the private key. Never commit it, and do not paste it into chats or tickets. - The namespaces monitoring and clickhouse now exist; the ArgoCD apps use CreateNamespace, so they adopt them.

10. Install ArgoCD (by hand, once)

ArgoCD cannot install itself, so this is the one thing that is applied manually (then the repo secret and one root Application are applied by hand; everything else is deployed by ArgoCD from git).

(This folder was apps/argocd when ArgoCD was first installed; it now lives in argocd/install, next to the root app.)

The repo is cloned on jas-mnt-01 (~/jastv-iac, see section 7), and the vendored install file is used, so nothing is downloaded:

export KUBECONFIG=/etc/rancher/k3s/k3s.yaml
kubectl apply --server-side --force-conflicts -k ~/jastv-iac/environments/pilot/argocd/install
kubectl -n argocd rollout status deploy/argocd-server --timeout=300s
kubectl -n argocd get pods

--server-side --force-conflicts is needed because the upstream install file contains very large CRDs that exceed the client-side apply annotation limit.

Result (confirmed): all seven pods Running (application-controller, applicationset-controller, dex-server, notifications-controller, redis, repo-server, server), 0 restarts.

11. Secrets applied by hand (done)

Right after installing ArgoCD, create the repo credential and the Nexus pull secrets:

kubectl apply -f ~/jastv-iac/environments/pilot/playtelly/repo-secret.yml            # ArgoCD can read the git repo
for ns in ingress-apisix cert-manager production; do
  kubectl create namespace $ns --dry-run=client -o yaml | kubectl apply -f -
  kubectl apply -n $ns -f ~/jastv-iac/environments/pilot/playtelly/registry-secret.yml   # nexus-registry-secret
done

Result (confirmed): infra-platform-repo in argocd, nexus-registry-secret in the three namespaces. monitoring and clickhouse have no pull secret: their images (Grafana, ClickHouse, VictoriaMetrics, VictoriaLogs) come from public registries (section 12).

12. Images and Nexus

A k3s registry mirror (/etc/rancher/k3s/registries.yaml) is not used in the pilot. Images come from Nexus (registry.nexus.castis.io) only where the manifest or values file names that registry, with the login from nexus-registry-secret (section 11). That is already the case for APISIX, etcd, the ingress controller, cert-manager and the playtelly apps. Everything else is pulled from the public registries.

Every image that a manifest points at Nexus must exist there, under the same path and tag. Copy a missing one with (command used by the team):

docker buildx imagetools create -t registry.nexus.castis.io/<path>:<tag> <source>

This was done for vernemq/vernemq:2.1.2-alpine: docker buildx imagetools create -t registry.nexus.castis.io/vernemq/vernemq:2.1.2-alpine docker.io/vernemq/vernemq:2.1.2-alpine.

To list the images the cluster really runs (nothing to install; ArgoCD already renders the charts):

kubectl get pods -A -o jsonpath='{range .items[*]}{range .spec.initContainers[*]}{.image}{"\n"}{end}{range .spec.containers[*]}{.image}{"\n"}{end}{end}' | sort -u

Known gap: Nexus only has clickhouse/clickhouse-server:24.3; the pilot runs 26.7.5.10 (as production does), so the ClickHouse image still comes from Docker Hub until that tag is copied and the manifest is pointed at Nexus.

Status: the images that still come from public registries are Grafana, ClickHouse and Keeper, vmalert, busybox, curl, and the images of the Longhorn, VictoriaMetrics and VictoriaLogs charts. Moving them to Nexus means copying each one (command above) and changing its image: line (manifests) or image.repository (values files) to registry.nexus.castis.io/<path>.

13. The root Application (everything else is automatic)

argocd/root-app.yaml is the only Application applied by hand. It manages itself: a second source includes this very file, so later changes to it are applied by ArgoCD. That only works because the Application health check in argocd/install reports pilot-root as always Healthy (otherwise the root waits for its own health and deadlocks). It deploys argocd/apps/, one Application per piece (the playtelly ApplicationSet is in the same folder), ordered by sync wave (the Application health check added to argocd-cm makes each wave wait for the previous one to be Synced + Healthy):

Wave Application What
0 monitoring-base namespace monitoring, StorageClass local-path-retain-expand
1 longhorn Helm chart longhorn 1.12.2
2 longhorn-config StorageClasses (longhorn-worker, longhorn-control-plane, apisix-etcd-longhorn), backup target
3 apisix, cert-manager Helm chart apisix 2.15.0 (gateway, ingress controller 2.1.0, etcd, Apisix CRDs); Helm chart cert-manager v1.21.0 (CRDs included)
4 apisix-gateway, monitoring-auth IngressClass + GatewayProxy; basic-auth consumer
5 clickhouse, cert-manager-config ClickHouse + Keepers (volumes created on demand by local-path); Cloudflare secret, ClusterIssuer, wildcard Certificate and ApisixTls for jasplay.castis.io
6 vm-stack, vlogs-cluster Helm charts victoria-metrics-k8s-stack 0.99.1, victoria-logs-cluster 0.2.13
7 victoria-metrics-extras, victoria-logs-extras, grafana NodePorts, routes, rules, scrape; Grafana
8 playtelly (ApplicationSet) creates one <folder>-pilot Application per folder in playtelly/

Chart versions are the pilot's own pins (not production's): Longhorn 1.12.2, APISIX 2.15.0, cert-manager v1.21.0, VM stack 0.99.1, VictoriaLogs cluster 0.2.13. All five Helm charts were checked with helm template before the first sync.

kubectl apply --server-side --force-conflicts -k ~/jastv-iac/environments/pilot/argocd/install     # adds the health check (needed for the waves)
kubectl apply -f ~/jastv-iac/environments/pilot/argocd/root-app.yaml
kubectl -n argocd get applications -w

Result (confirmed): all Applications Synced / Healthy, all pods Running, all claims Bound. The running root is the self-managing version above (argocd/install was re-applied first so the health check treats pilot-root as Healthy, then root-app.yaml). If a bad edit ever breaks the root, re-apply argocd/root-app.yaml by hand.

14. Problems met during the install, and the fix

Symptom Cause Fix
Application longhorn / apisix stuck OutOfSync / Missing, message waiting for completion of hook ... Helm hook Jobs run before the objects they need exist (ArgoCD runs them as sync hooks) Longhorn: preUpgradeChecker.jobEnabled: false. APISIX: etcd.preUpgradeJob.enabled: false. To clear a stuck run: delete the Job, then terminate the operation (kubectl -n argocd patch application <name> --type merge -p '{"status":{"operationState":{"phase":"Terminating"}}}') and start a sync (... -p '{"operation":{"initiatedBy":{"username":"admin"},"sync":{"revision":"main","syncStrategy":{"hook":{}}}}}'). {"operation":null} does not stop a running operation
vm-stack failed in helm template (can't index item of type bool) defaultRules has a new format in chart 0.99 defaultRules.enabled: true plus component toggles (kubeEtcd, kubeScheduler, kubeControllerManager, kubeProxy off on k3s)
VictoriaLogs claim names did not match the static PVs; vlselect has no volume chart 0.2.13 differs from what the PVs assumed confirmed with helm template; later all of this was replaced by dynamic local-path volumes
vmstorage claims Pending: config doesn't contain path /data/local-path the Rancher provisioner only accepts paths in its own config k3s default-local-storage-path: /data/local-path on all three servers (section 6b)
then pathPattern must start with ... custom pathPattern rejected removed from the StorageClass; recreate the class
apisix permanently OutOfSync IngressClass apisix is created by the chart AND by apisix-gateway; generated Secrets, webhook caBundle and the etcd StatefulSet differ on every render ignoreDifferences in argocd/apps/30-apisix.yaml (whole IngressClass, the two generated Secrets, the webhook caBundle, the etcd StatefulSet template/volume templates)
Root pilot-root stuck Progressing, waiting for healthy state of Application/pilot-root the root included itself while the Application health check made a syncing Application Progressing the health check reports pilot-root Healthy (or keep the root outside the folder it deploys)
clickhouse OutOfSync, StatefulSet ... Forbidden: updates to statefulset spec ... a StatefulSet's volume templates cannot change; the claims were on the old static PVs delete the StatefulSets and their claims together, then start a sync (volumes are empty at install time)
ImagePullBackOff on five playtelly apps overlay tags older than production's current tags, gone from Nexus overlays follow production's current prod-... tags
ImagePullBackOff on vernemq (not found) tag 2.1.2-alpine not in Nexus copied into Nexus with docker buildx imagetools create
authapi CrashLoopBackOff, then 401 Errors.Token.Invalid databases authapi / coreapi did not exist; then the Zitadel token was production's Job playtelly/postgres/04-create-databases-job.yaml (empty databases, apps create their own tables); Zitadel pat-publisher sidecar publishes its machine-user token as Secret zitadel-pat, authapi reads it. Zitadel only writes the token on its very first start, so after adding the sidecar to a running instance, drop the zitadel database once and restart the pod
APISIX answered HTTP 000 to curl -k https://<node-ip> no SNI with a bare IP test with curl --resolve <host>:443:<node-ip> https://<host>/

15. Verification

kubectl -n argocd get applications | grep -v 'Synced *Healthy'              # nothing (or only an app that is still starting)
kubectl get pods -A | grep -v -E 'Running|Completed'                         # nothing
kubectl get pvc -A | grep -v Bound                                           # nothing
kubectl get certificate -A                                                   # jasplay-castis-io-tls READY True
kubectl -n ingress-apisix get pods -o wide | grep -E 'NAME|apisix-[0-9a-f]'   # 3 gateway pods, 3 different nodes
curl -sk -o /dev/null -w 'grafana: HTTP %{http_code}\n' --resolve monitor.cdn.3bbtv.com:443:<node-ip> https://monitor.cdn.3bbtv.com/    # 302
curl -sk --resolve id.jasplay.castis.io:443:<node-ip> https://id.jasplay.castis.io/health                                                   # {"status":"ok"}

Checked on this install: all Applications healthy, Grafana answers 302 and authapi /health answers {"status":"ok"} through APISIX.

16. Open items

  • ClickHouse is empty: the analytics tables (and the rollups behind dashboards 11 to 14) come from the production SQL; create them with ON CLUSTER main_cluster and Replicated... engines (section 17).
  • CastisadminZa (ClickHouse admin) keeps production's password hash; its plaintext is not in the repo. Set a new hash in apps/clickhouse/clickhouse-cluster.yaml if nobody has it.
  • DNS: the *.cdn.3bbtv.com and jasplay.castis.io names must point at a node IP before users can reach the pilot (and only one cluster at a time can own them).
  • apps/victoria-metrics/vmstatic-scrape-all-servers.yaml scrapes 32 production hosts and vmrule-cdn-content.yaml expects cdn_prod_* metrics. Comment both out of apps/victoria-metrics/kustomization.yaml if the pilot must not use them (ArgoCD has prune: true, so the next sync deletes them from the cluster).
  • Alertmanager has three receivers (default, critical, warning) with no destination, so alerts are not sent anywhere yet (apps/victoria-metrics/helm/vm-k8s-stack-values.yaml).
  • apps/victoria-logs/helm/victoria-logs-collector-values.yaml is not used by any Application, so the pilot's own pod logs are not collected. Add an Application for the collector chart if you want them.
  • No authentication on the NodePorts 30480 (vminsert), 30481 (vlinsert) and 30482 (ClickHouse HTTP); the ClickHouse route has no basic-auth and CastisadminZa may connect from any address. Restrict before the pilot is reachable from outside (a firewall rule for the Vector servers, or vmauth in front).
  • Move the remaining images (Grafana, ClickHouse and Keeper, vmalert, busybox, curl, the Longhorn, VictoriaMetrics and VictoriaLogs chart images) to Nexus (section 12).
  • Rotate the secrets committed in plain text (Grafana admin and SMTP app password, ClickHouse grafana user, APISIX basic-auth user, Cloudflare token, deploy token, Nexus login) before this leaves the internal network.
  • The gslb-tls-secret certificate expires on 14 Jan 2027 and was copied by hand (section 9).
  • Optional cleanup: the unused product folders under /data (section 2), and the leftover playtelly/coreapi/zitadel-migrate/ (namespace staging, not deployed: the ApplicationSet only reads the first level of each folder).

17. Details worth knowing (how the pieces work)

Grafana reads ClickHouse with its own read-only user

Grafana's ClickHouse datasource must log in. Instead of the admin CastisadminZa, ClickHouse has a user grafana (apps/clickhouse/clickhouse-cluster.yaml, users.xml): profile grafana_readonly (readonly=2, 3GB memory, 60s per query), allowed only from the pod network 10.42.0.0/16. ClickHouse stores only the SHA-256 hash; the plaintext is clickhouse-password in apps/grafana/secret.yaml, and the datasource (provisioning-datasources.yaml) logs in as grafana. Users are defined in users.xml (not by SQL), and the file is mounted with subPath, so after a change restart both:

kubectl -n clickhouse rollout restart statefulset clickhouse
kubectl -n monitoring rollout restart deploy/vm-stack-grafana
Test from a pod that is not ClickHouse itself (the user is limited to the pod network):
PW=$(kubectl -n monitoring get secret vm-stack-grafana -o jsonpath='{.data.clickhouse-password}' | base64 -d)
kubectl -n monitoring run ch-test --rm -it --restart=Never --image=curlimages/curl:8.22.0 -- \
  curl -s --user "grafana:$PW" --data 'SELECT 1' http://clickhouse.clickhouse.svc.cluster.local:8123/    # prints 1

ClickHouse replication

remote_servers/main_cluster is only the list of the 3 replicas (one shard). Data is copied only by tables that use the Replicated... engine, whose log is kept in the 3 ClickHouse Keepers (Raft, needs 2 of 3). There is no primary replica.

The playtelly database job and the Zitadel token

  • playtelly/postgres/04-create-databases-job.yaml (PostSync Job) creates the empty databases authapi and coreapi; the apps create their own tables.
  • Zitadel writes its machine-user token to a file on first start. A sidecar (pat-publisher in playtelly/zitadel/03-deployment.yaml, RBAC in 05-pat-rbac.yaml) publishes it as Secret zitadel-pat, and authapi reads it through ZITADEL_PAT. If the Zitadel database is reset, the token is regenerated and the Secret follows.