Repository navigation
salt-master: Salt master cluster mode as a StatefulSet; pin Salt 3008.5 - #35
Merged
Merged
Conversation
…n Salt 3008.5 - salt-master chart: replace the Deployment with a StatefulSet and add agent.replicas and agent.cluster.* (cluster_id, cluster_peers, cluster_pki_dir, cluster_secret, cluster_pool_port). storageMode is "isolated" (Salt 3008 cluster_isolated_filesystem, per-pod PVCs) or "shared" (one ReadWriteMany claim). The chart generates and keeps a cluster_secret unless one is supplied. - master image entrypoint renders the cluster config from SALT_CLUSTER_* and resolves peer DNS names to IPs; unresolvable peers are skipped. - Pin Salt to 3008.5 in the master and minion Dockerfiles, chart defaults, CI script and docs. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
- prepare-cluster-dirs root init container: PVC subPath dirs are root-owned. - entrypoint: wait for all peers and fail clearly if none resolve (Salt refuses a member with no peers); chart requires replicas >= 2. - set interface and id to the pod IP: Salt uses `interface` as the cluster node identity. - add agent.cluster.keysCacheDriver, autoReplaceVoters (default off) and minVoters; document that a restarted pod gets a new identity. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…hart prepare-master-keys (classic) and prepare-cluster-dirs (cluster) ran as root with CHOWN/FOWNER/DAC_OVERRIDE. They now use agent.containerSecurityContext, mount the whole volume and create their directories as the master's own user (the pod's fsGroup makes volumes group-writable), and the master mounts the existing subdirectories. The master-key Secret is mounted 0440. Removes the unused agent.initContainers.fixCachePerms value. Verified on a real cluster: cluster mode on fresh Longhorn volumes (3 voters form) and classic mode with a chart-generated key (Salt keeps the supplied key, storing it by master id). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Rewrote or corrected the docs against the current code (charts, Dockerfiles, entrypoints, workflows) after the StatefulSet, non-root and cluster-mode changes: - README, src/README: layout, components, master modes (classic and cluster, with the pod-restart limitation), the minion StatefulSet model, testing, Salt 3008.5. - salt-master chart and image: classic vs cluster, all agent.cluster.* values, storage modes, non-root init containers, entrypoint variables, correct defaults and Secret key names, removed per-ordinal Service and other features that do not exist. NOTES.txt updated. - salt-minion chart and images: StatefulSet identity, per-pod keys, keygen Job behaviour, guard rails, real build args, the extension constraint. - docs/: building, releasing, release-prep, ci-debug, helm-test (registry projects and private-CA trust), complete-system-test and the compliance guide rewritten against the real workflows and charts. - salt-key-operator docs: renamed to salt-master, how it relates to trustedMinions and per-pod minion keys. - CHANGELOGs corrected; the never-published master chart v1.0.0 text no longer claims a StatefulSet. - scripts/salt-kubernetes-e2e-local-test.sh: the workloads are StatefulSets, not Deployments (the minion since the previous merge). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
saifuddinrangwala
force-pushed
the
feat/master-cluster-statefulset
branch
from
November 25, 2026 15:44
1ae3f74 to
d70622f
Compare
The multi-master links targeted /en/3006/ and the master-cluster links /en/latest/. The images and charts are pinned to Salt 3008.5, so link to /en/3008/ (both pages exist there). Also updates the comments in the entrypoint scripts. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Release workflows - Kubernetes minion image: trigger on salt-minion-kubernetes-v* (what scripts/release-docker-tags.sh pushes). The old glob salt-minion-v* never matched that tag, so no Kubernetes minion image was published, and it also matched salt-minion-vcf-v* tags. - Key operator chart: version was injected into helm/salt-minion/Chart.yaml instead of its own chart. - Minion and key operator charts: push to oci://ghcr.io/<owner>/helm, not //helm. - Chart workflows: strip the tag prefix that actually triggers them. Charts - Default image repositories for the minion and key operator charts pointed at ghcr.io/saltstack/salt-kubernetes/..., which does not exist; use ghcr.io/saltstack/<image>, where the workflows publish. - salt-master: add agent.image.imagePullSecrets and a keygen block (image, pull policy, pull secrets, restricted security contexts); the keygen image was hardcoded and the Job had no security context. - salt-minion: keygen Job runs with a restricted security context; remove agent.minion.grains and masterId and the unmounted minion-config ConfigMap (no effect); remove the unused scripts/ and salt-extensions.txt; Chart.yaml describes a StatefulSet. Images and scripts - Remove the unused SALT_GPG_KEY_URL and SALT_APT_REPO_URL build args and fix comments that named the old chart and file paths. - e2e script: no internal CA, mirror or IP; configurable by environment variables. - scripts/ci.sh: fix stale paths and re-enable the chart template checks, including configurations the charts must reject. Docs and changelogs updated to match. Checked on a real cluster: both keygen Jobs complete under the restricted security context and create their Secrets. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
A master's cluster identity is its `interface`. By default that is the pod IP, which changes on restart, so a restarted master cannot rejoin. agent.cluster.hostNetwork runs the masters on the host network: the identity is the node's IP and a pod that returns to the same node keeps it. Adds hostNetwork, dnsPolicy ClusterFirstWithHostNet and a required pod anti-affinity (one master per node); it needs exactly replicas labelled nodes selected with agent.nodeSelector so a replacement can only land on its own node. Rejected without cluster mode. The entrypoint now identifies itself by POD_NAME (the hostname is the node's under hostNetwork) and drops any peer that resolves to its own address. Tested on a real cluster, 3 masters on 3 nodes: after four restarts (the leader three times among them) the cluster stayed at 3 voters with no learners, leadership failed over and every pod returned on its own node with the same IP. Docs, changelogs and ci.sh updated. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
watchNamespace defaulted to "salt-master". The operator's Role and RoleBinding were created in that namespace, but its Deployment goes into the release namespace, so installing the salt-master chart (which bundles this chart) with defaults into any other namespace failed with `namespaces "salt-master" not found` and left a half-installed release. watchNamespace now defaults to the release namespace (empty), and cluster-wide watching is the explicit `clusterWide: true` (it used to be watchNamespace: ""). The salt-master chart prints a warning in its notes when the release namespace differs from `namespace` while trusted minions are enabled. Docs, changelog and ci.sh updated. Found by installing the master chart with its defaults on a real cluster. Re-tested: the default install, and a 3-replica classic multi-master install with a shared key, both work end to end (a SaltMinionKey is accepted, and removed again, on every master). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The Kubernetes minion image is published as salt-minion and the chart tag is chart-salt-minion-vX, so tag the image salt-minion-vX.Y.Z, not salt-minion-kubernetes-vX.Y.Z. That tag prefix also matches salt-minion-vcf-v* tags, which would start the Kubernetes workflow as well. The workflow now matches salt-minion-v[0-9]*, so a digit has to follow the "v" and only the VCF workflow runs for a salt-minion-vcf-vX tag. scripts/release-docker-tags.sh creates the same tag. Docs, the minion changelog and stale comments that still named the old chart updated. The managed_by grain value is left unchanged: it is a runtime value that external states may target. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The entrypoints set the grain managed_by: salt-minion-kubernetes, the old chart name. Use salt-minion, the package name, in both the Kubernetes and the VCF image (the VCF image is run through the salt-minion chart too). Behaviour change: any states or targeting that match the old grain value need updating; noted in the minion image changelog. Checked by running both entrypoints against a stub salt-minion and reading the generated config. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
agent.cluster.*), per the Salt master cluster docs. It is opt-in:agent.cluster.enableddefaults tofalse, which keeps the classic single or multi-master behaviour.storageMode: isolated(default) uses Salt 3008'scluster_isolated_filesystem, with one PVC per pod and no shared storage.file_rootsandpillar_rootschanges are propagated withsalt-run cluster.sync_roots.storageMode: sharedmounts one existing ReadWriteMany claim for the cluster pki dir, cachedir,file_rootsandpillar_roots.masterKeySecretNameand the keygen Job are not used, andtrustedMinionswrites intocluster_pki_dir.cluster_secretonce and keeps it across upgrades, unlessagent.cluster.secretNameis set.agent.replicas(default1). The leftoverdeployment.yamland standalonejob-cache-pvc.yamlare removed, and the job cache is now avolumeClaimTemplate. Classic multi-master still works and fails fast whenreplicas > 1withoutmasterKeySecretName.prepare-master-keysin classic mode,prepare-cluster-dirsin cluster mode) now run withagent.containerSecurityContextas the master's own non-root user. They create their directories themselves, relying on the pod'sfsGroup, and the master mounts the existing subdirectories. This is the same pattern the salt-minion chart uses. The master-key Secret is mounted0440, and the unusedagent.initContainers.fixCachePermsvalue is removed. A user-supplied volume (sharedStorage.existingClaim) must already be writable by uid/gid 10001.SALT_CLUSTER_*.scripts/ci.shand the docs. Isolated-filesystem clustering needs 3008.salt-key-operatorcreated its Role and RoleBinding in a fixedsalt-masternamespace but ran in the release namespace, so a default install into any other namespace failed half-way (namespaces "salt-master" not found).watchNamespacenow defaults to the release namespace, and cluster-wide watching is the explicitclusterWide: true. The master chart warns in its notes when the release namespace andnamespacediffer.docs/, the three chart READMEs, both image READMEs,NOTES.txtand the CHANGELOGs were checked against the current code and rewritten where stale. Examples: wrong defaults, a master-key Secret documented with the wrong key names, a per-ordinal Service that does not exist,deployment/...commands for what are now StatefulSets, old paths, and registry instructions that a project-based registry rejects. The never-published master chart "v1.0.0" no longer claims a StatefulSet.Release workflow, chart and script fixes
Found while reviewing the docs against the code, fixed here:
salt-minion-v*, which also matchessalt-minion-vcf-v*tags, whilescripts/release-docker-tags.shpushedsalt-minion-kubernetes-vX, a tag that matched no workflow, sosalt-minion-kubernetes-v0.1.0never produced an image. Image and chart tags now use the package name (salt-minion-vX.Y.Zandchart-salt-minion-vX.Y.Z): the workflow matchessalt-minion-v[0-9]*, so a digit has to follow thevand asalt-minion-vcf-vXtag starts only the VCF workflow, and the release script pushessalt-minion-vX.helm/salt-minion/Chart.yamlinstead of its own chart.oci://ghcr.io/<owner>//helm(double slash); fixed to/helm, as the master chart already had. The chart workflows also strip the tag prefix that actually triggers them.ghcr.io/saltstack/salt-kubernetes/..., which does not exist. Images are published toghcr.io/saltstack/<image>(for examplesalt-master:0.1.0andsalt-key-operator:0.1.0exist there), so the defaults now point there.agent.image.imagePullSecrets, and akeygenblock for the key-generation Job (image, pull policy, pull secrets, and restricted security contexts). The Job image was hardcoded and the Job had no security context.agent.minion.grainsandagent.minion.masterIdand the<release>-minion-configConfigMap they went into: nothing mounted it, so they never had any effect. Removed the unusedscripts/copies andsalt-extensions.txtfrom the chart, andChart.yamlnow describes a StatefulSet.SALT_GPG_KEY_URLandSALT_APT_REPO_URLbuild args and fixed comments that named the old chart and file paths.scripts/salt-kubernetes-e2e-local-test.sh: the workloads are StatefulSets now (the minion since salt-minion: StatefulSet with a unique ID and keypair per replica #36), sodeployment/...becamestatefulset/.... It also no longer hardcodes an environment-specific CA, package mirror or IP; those are optional environment variables (BUILD_CA,PIP_INDEX_URL,PACKAGES_ADD_HOST,PLATFORM,KUBE_CONTEXT).scripts/ci.sh: fixed stale paths and re-enabled the chart template checks, including configurations the charts must reject.The workflow changes cannot be run before merging; they were checked by reading them and by confirming the YAML parses. The new keygen security contexts were checked on a real cluster: both Jobs complete under them and create their Secrets.
What testing on a real cluster found
The first version of this PR was only linted and rendered. Running it on a real cluster (5 nodes, Longhorn storage, 3 replicas) found several problems, all fixed here:
subPathdirectories. Kubelet creates PVC subPath directories as root, so the non-root master crashed onchmodof its pki directory. The init container now creates the directories itself, as the master's user (see above).Dynamic peer discovery is not supported), so there is no single founding master. The entrypoint now waits for all peers to resolve and fails clearly if none do, and the chart requiresreplicas >= 2in cluster mode.interfaceandidmust be the pod IP. Salt usesinterfaceas the consensus node identity and matches it againstcluster_peers; with the0.0.0.0default, Raft replies were dropped. The pod IP is now passed through the downward API.keys.cache_driver: mmap_keycould not read its own keys on Longhorn volumes, although it worked on a local bind mount. The chart now uses Salt's defaultlocalfs_key, withagent.cluster.keysCacheDriverto opt in to others (saltstack/salt#70951).helm upgrade --reuse-valuesleft newly added values unset; the template now falls back to the default.With these fixes, 3 masters start, elect a leader and form a 3-voter cluster in which every pod reports the same membership. That was re-checked after the non-root change, on fresh volumes. Classic mode was also run on the cluster (1 replica, chart-generated key): the pod starts as the non-root user, listens on 4505 and 4506, and Salt 3008 keeps the supplied key (it stores it under the master id and links
master.pem/master.pubto it).Pod restarts in cluster mode, and the
hostNetworkoptionBy default a restarted or rescheduled master cannot rejoin the cluster. A master's cluster identity is its
interface, which by default is the pod IP, and Salt 3008.5 has no setting to separate identity from bind address. A pod IP changes on every restart, so the restarted pod joins as a new learner and waits for a join reply, while its old identity stays a dead voter. Each restart leaves one more dead voter, so quorum is lost after the second restart.Salt's own recovery,
cluster_auto_replace_voters, is off by default. When I turned it on, the leader flagged a healthy voter as unhealthy and demoted it instead of the dead one, which broke quorum (saltstack/salt#70952). The chart exposesautoReplaceVotersandminVotersbut leaves auto-replace off.New opt-in
agent.cluster.hostNetworkmakes the identity a stable node IP. The masters run on the host network, one per node (required pod anti-affinity), so a pod that comes back on the same node keeps its identity. It needs exactlyagent.replicaslabelled nodes selected withagent.nodeSelector, so the only node a replacement can land on is the one that was freed; the ports 4505, 4506 andpoolPortmust be free on them, and the namespace must allowhostNetworkpods. The entrypoint now identifies itself byPOD_NAME, because underhostNetworkthe container's hostname is the node's, and drops any peer that resolves to its own address. Tested on a real cluster with 3 masters on 3 nodes: after four restarts, the leader three times among them, the cluster stayed at 3 voters with no learners, leadership failed over each time, and every pod came back on its own node with the same IP. On the first start one master came up as a joiner and did not become ready (Failed to decrypt join-notify); deleting that pod fixed it. This was seen once.Not tested with
hostNetwork: a node failing or being drained so that a master has to move,trustedMinions, minions connecting through the cluster. WithouthostNetwork, treat pod restarts in cluster mode as unsupported. Cluster mode stays opt-in. See the master chart README.Testing
helm lintpasses for all three charts, andhelm templaterenders classic, cluster-isolated and cluster-shared, with trustedMinions on and off. The guards fire: shared without a claim, classicreplicas > 1without a key, and cluster mode withreplicas < 2all fail with clear messages.helm unitteston the minion chart: 44 of 44 pass. Hadolint is clean on the three Dockerfiles. Relative links in all Markdown files resolve.hostNetworkand four restarts, and classic mode (1 replica), as described above.trustedMinionson, with the key operator) came up with the releasedeployed; aSaltMinionKeywas accepted on the master in about 50 seconds as a real file, its status showedAccepted=True, and deleting it removed the key again;SaltMinionKeywas accepted on all three masters within 20 seconds and removed from all three within 30 seconds, and the per-pod DNS names resolve.Not tested:
storageMode: shared.docs/complete-system-test.mdand the compliance guide were checked against the code, not run.Notes
salt-master-chartv1.1.0,salt-master-imagev1.1.0 and a minion image entry. Nothing is tagged. Onlyv0.1.0of each component has been published so far.mainafter Make minion images configurable #32, Fix minion PKI preparation and security defaults #34 and salt-minion: StatefulSet with a unique ID and keypair per replica #36 merged.🤖 Generated with Claude Code