Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/release-docker-minion-k8s.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ name: Release Docker - Salt Minion K8s
on:
push:
tags:
- 'salt-minion-v*'
# A digit must follow the "v" so salt-minion-vcf-v* tags do not match.
- 'salt-minion-v[0-9]*'
schedule:
- cron: '0 3 * * 1' # Every Monday at 3:00 AM UTC
workflow_dispatch:
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/release-helm-key-operator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
run: |
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
TAG_NAME=${GITHUB_REF#refs/tags/}
VERSION=${TAG_NAME#chart-operator-v}
VERSION=${TAG_NAME#chart-salt-key-operator-v}
echo "is_tag=true" >> $GITHUB_OUTPUT
else
VERSION="0.0.0-snapshot"
Expand All @@ -50,8 +50,8 @@ jobs:
# Ensure ONLY the clean numeric semver (e.g., 0.1.0) is injected
CLEAN_VERSION=$(echo "${{ steps.vars.outputs.version }}" | sed -E 's/.*-v?([0-9]+\.[0-9]+\.[0-9]+.*)/\1/')

sed -i "s/^version:.*/version: ${CLEAN_VERSION}/g" helm/salt-minion/Chart.yaml
sed -i "s/^appVersion:.*/appVersion: \"${CLEAN_VERSION}\"/g" helm/salt-minion/Chart.yaml
sed -i "s/^version:.*/version: ${CLEAN_VERSION}/g" helm/salt-key-operator/Chart.yaml
sed -i "s/^appVersion:.*/appVersion: \"${CLEAN_VERSION}\"/g" helm/salt-key-operator/Chart.yaml

echo "CLEAN_VERSION=${CLEAN_VERSION}" >> $GITHUB_ENV

Expand All @@ -61,7 +61,7 @@ jobs:

- name: Push Helm Chart OCI Artifact to GHCR
run: |
helm push .dist/salt-key-operator-${{env.CLEAN_VERSION}}.tgz oci://ghcr.io/${{ steps.vars.outputs.registry_owner }}//helm
helm push .dist/salt-key-operator-${{env.CLEAN_VERSION}}.tgz oci://ghcr.io/${{ steps.vars.outputs.registry_owner }}/helm

- name: Create GitHub Release
if: steps.vars.outputs.is_tag == 'true'
Expand All @@ -73,7 +73,7 @@ jobs:
Automated Helm Chart release for **Salt Key Operator**.
Install with:
```bash
helm pull oci://ghcr.io/${{ steps.vars.outputs.registry_owner }}//helm/salt-key-operator --version ${{env.CLEAN_VERSION}}
helm pull oci://ghcr.io/${{ steps.vars.outputs.registry_owner }}/helm/salt-key-operator --version ${{env.CLEAN_VERSION}}
```
draft: false
prerelease: false
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-helm-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
run: |
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
TAG_NAME=${GITHUB_REF#refs/tags/}
VERSION=${TAG_NAME#chart-master-v}
VERSION=${TAG_NAME#chart-salt-master-v}
echo "is_tag=true" >> $GITHUB_OUTPUT
else
VERSION="0.0.0-snapshot"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release-helm-minion.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
run: |
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
TAG_NAME=${GITHUB_REF#refs/tags/}
VERSION=${TAG_NAME#chart-minion-v}
VERSION=${TAG_NAME#chart-salt-minion-v}
echo "is_tag=true" >> $GITHUB_OUTPUT
else
VERSION="0.0.0-snapshot"
Expand Down Expand Up @@ -60,7 +60,7 @@ jobs:

- name: Push Helm Chart OCI Artifact to GHCR
run: |
helm push .dist/salt-minion-${{env.CLEAN_VERSION}}.tgz oci://ghcr.io/${{ steps.vars.outputs.registry_owner }}//helm
helm push .dist/salt-minion-${{env.CLEAN_VERSION}}.tgz oci://ghcr.io/${{ steps.vars.outputs.registry_owner }}/helm

- name: Create GitHub Release
if: steps.vars.outputs.is_tag == 'true'
Expand Down
205 changes: 142 additions & 63 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,88 +1,167 @@
# salt-kubernetes

Helm charts for deploying different flavours of Salt images to Kubernetes.
Container images and Helm charts for running Salt on Kubernetes: a Salt master,
Salt minions that run as pods, and an operator that manages the master's
accepted minion keys declaratively.

## Charts
Salt version: **3008.5** (pinned in the Dockerfiles, `helm/salt-master/values.yaml`
and `scripts/ci.sh`). The images install Salt with the official
[bootstrap script](https://github.com/saltstack/salt-bootstrap) (onedir).
Each component's `CHANGELOG.md` records which Salt and extension versions a
given release carries.

| Chart | Description |
## Repository layout

| Path | Contents |
| --- | --- |
| [salt-master-kubernetes](salt-master-kubernetes) | Installs a Salt master StatefulSet, supporting Salt's native [multi-master mode](https://docs.saltproject.io/en/3006/topics/tutorials/multimaster.html) for active-active horizontal scaling (all replicas share one pre-seeded keypair). Exposed via a flat Service, a headless Service (in-cluster per-ordinal addressing), and optionally one NodePort Service per replica (external per-ordinal addressing). Deliberately minimal - no RBAC, no saltext.kubernetes install. |
| [salt-minion-kubernetes](salt-minion-kubernetes) | Installs Salt Minion and RBAC. Has built-in support to run CIS Kubernetes compliance assessments via kube-bench on-demand Jobs. Supports in-cluster (minion runs as a pod) and external (RBAC only) modes. Like `salt-minion-vcf`, this is a full project directory - its own `Dockerfile` builds a Salt minion preloaded with `saltext.vault` and `saltext.kubernetes`, with `kubectl` bundled in. |
| [salt-minion-vcf](salt-minion-vcf) | Extensible Salt Minion image (Docker, Docker Compose, Kubernetes, and Helm) preloaded with configurable Salt extensions - `saltext.vcf` (VMware Cloud Foundation automation: vCenter, NSX, SDDC-M, VCF Ops) by default, but not limited to it. Includes `saltext.vault` integration for sourcing credentials from HashiCorp Vault into Pillar instead of storing them on disk. Unlike the other entries here, this directory is the full project (Dockerfile, Docker Compose, scripts, docs), not a chart-only directory - the Helm chart itself lives at [`salt-minion-vcf/helm/salt-minion-vcf`](salt-minion-vcf/helm/salt-minion-vcf). |
| [salt-key-operator](salt-key-operator) | A small Go/controller-runtime operator + `SaltMinionKey` CRD - the declarative replacement for running `salt-key -a <minion-id>` by hand, which (unlike a manual `salt-key -a`, which only ever affects one pod) keeps a minion trusted consistently across every replica of an active-active `salt-master-kubernetes` release. |
| `helm/salt-master` | Chart: Salt master as a StatefulSet (classic or cluster mode). |
| `helm/salt-minion` | Chart: Salt minion as a StatefulSet (one minion and one keypair per pod), plus RBAC. |
| `helm/salt-key-operator` | Chart: the `SaltMinionKey` CRD and its controller. Also a dependency of the master chart. |
| `src/master` | Dockerfile and entrypoint for the master image. |
| `src/minion/kubernetes` | Minion image with `saltext.kubernetes`, `saltext.vault` and `kubectl`. |
| `src/minion/vcf` | Minion image with the VCF extensions (configurable extension list) and `saltext.vault`. |
| `src/salt-key-operator` | Go source of the operator. |
| `docs/` | Build, release, test and CI guides (see below). |
| `scripts/` | Release tag helpers and CI/e2e helper scripts. |

There is no Helm chart for the VCF minion image. Use the `salt-minion` chart
and point `agent.image.repository` at the VCF image.

## Components

| Chart | Image | What it does | Details |
| --- | --- | --- | --- |
| `salt-master` | `salt-master` | StatefulSet `salt-master` plus a flat Service and a headless Service. | [chart README](helm/salt-master/README.md), [image README](src/master/README.md) |
| `salt-minion` | `salt-minion` (from `src/minion/kubernetes`) or `salt-minion-vcf` | StatefulSet of minions, RBAC, key generation Job. `authMode: external` creates RBAC only. | [chart README](helm/salt-minion/README.md), [image README](src/minion/README.md) |
| `salt-key-operator` | `salt-key-operator` | Writes `SaltMinionKey` public keys into the master's trusted-minions ConfigMap. | [README](src/salt-key-operator/README.md) |

### Master modes

`agent.cluster.enabled` selects the mode (see the
[master chart README](helm/salt-master/README.md) for all values):

- **Classic** (default, `false`): one replica, or classic multi-master
(`agent.replicas > 1`) where every replica shares one keypair supplied in
`agent.masterKeySecretName` (required; the chart refuses to render
otherwise). Minions list each master through the headless Service
(`salt-master-<N>.salt-master-headless.<namespace>.svc.cluster.local`).
- **Cluster** (`true`): a Salt master cluster (Salt 3007+, isolated storage
needs 3008+). Needs `agent.replicas >= 2` (use 3 or more). Each master has
its own keypair, minions connect to the flat `salt-master` Service, and any
replica can serve any minion. Opt-in. **Known limitation:** a master's identity
is its pod IP, so a restarted pod cannot rejoin unless you set
`agent.cluster.hostNetwork` (one master per labelled node; see the master chart
README).

The master is a StatefulSet. A release installed from an older chart version
that used a Deployment cannot be upgraded in place: reinstall.

### Minion model

The minion chart runs a StatefulSet named `agent.minion.idPrefix` (default
`salt-minion`). Pods are `<name>-0 ... <name>-N-1` and each pod is its own
minion: the minion ID is the pod name and each pod has its own keypair.
`agent.minion.id` and the single inline `privateKeyB64`/`publicKeyB64` pair
only work with `agent.replicas: 1`. One key source is required in `in_cluster`
mode: `agent.minion.keySecretName`, inline keys, or
`agent.minion.allowSelfGeneratedKey` (a keygen Job that writes Secret
`<release>-keys`; it only runs when `agent.minion.keySecretName` is empty). See the
[minion chart README](helm/salt-minion/README.md).

### Minion acceptance

The master chart installs `salt-key-operator` as a subchart when
`agent.trustedMinions.enabled` is true (the default), and a sidecar in each
master pod copies the trusted-minions ConfigMap into Salt's key directory.
Keys that are not in the ConfigMap are removed from that directory, so with
this enabled you accept minions with a `SaltMinionKey` (one per minion,
i.e. one per minion pod), not with `salt-key -a`. Set
`agent.trustedMinions.enabled=false` to accept with `salt-key` instead. See
[`src/salt-key-operator/README.md`](src/salt-key-operator/README.md).

## Quick start (from a checkout)

The charts default to locally built images, so build them first (see
[`docs/building.md`](docs/building.md)) and make them available to your
nodes, or override the image values.

## Quick install (published images/charts)
```bash
# Images
docker build -t salt-master:3008.5 src/master
docker build -t salt-minion:0.1.0 src/minion/kubernetes
docker build -t salt-key-operator:0.1.0 src/salt-key-operator

# Master (also installs the salt-key-operator subchart; the operator image
# defaults to ghcr.io/saltstack/salt-key-operator:0.1.0, override
# with --set salt-key-operator.image.repository=... if you built your own)
helm dependency update helm/salt-master
helm install salt-master helm/salt-master \
--namespace salt-master --create-namespace

# Minion
helm install salt-minion helm/salt-minion \
--namespace salt --create-namespace \
--set agent.saltMasterHost=salt-master.salt-master.svc.cluster.local \
--set agent.minion.allowSelfGeneratedKey=true
```

The fastest path to a working deployment: install straight from the
published GHCR OCI charts, no local Docker/Helm build required. See
[`docs/releasing.md`](docs/releasing.md) for the full list of published
artifacts, and each component's own `CHANGELOG.md` for exactly which
Salt/extension versions a given tag carries (the tag itself is just that
component's own semver, independent of Salt's version).
The minion chart's default image is
`ghcr.io/saltstack/salt-minion:0.1.0`; set
`agent.image.repository`/`agent.image.tag` to use the image you built. The
master chart's default is the unqualified `salt-master:3008.5`.

### salt-master-kubernetes
Then trust the minion (the key Secret is `<release>-keys`):

```bash
helm install salt-master-kubernetes \
oci://ghcr.io/saltstack/salt-kubernetes/charts/salt-master-kubernetes \
--version 1.0.0 \
--namespace salt-master --create-namespace \
--set agent.image.repository=ghcr.io/saltstack/salt-kubernetes/salt-master \
--set agent.image.tag=1.0.0
kubectl -n salt get secret salt-minion-keys -o jsonpath='{.data.minion\.pub}' | base64 -d
# put that PEM into a SaltMinionKey named salt-minion-0 in namespace salt-master,
# see src/salt-key-operator/README.md
kubectl -n salt-master exec salt-master-0 -c salt-master -- salt 'salt-minion-0' test.ping
```

For active-active (multiple replicas) and replacing manual `salt-key -a`
with the `SaltMinionKey` CRD, see
[`salt-master-kubernetes/README.md`](salt-master-kubernetes/README.md) and
[`salt-key-operator/README.md`](salt-key-operator/README.md).
[`docs/complete-system-test.md`](docs/complete-system-test.md) has the full
step-by-step version including the operator, multi-master and cluster mode.

```bash
helm install salt-key-operator \
oci://ghcr.io/saltstack/salt-kubernetes/charts/salt-key-operator \
--version 0.1.0 \
--namespace salt-master
```
## Published artifacts

### salt-minion-kubernetes
Release workflows publish to GHCR on component tags (see
[`docs/releasing.md`](docs/releasing.md) for tag patterns and exact paths).
Which versions exist depends on which tags have been pushed.

```bash
helm install salt-minion-kubernetes \
oci://ghcr.io/saltstack/salt-kubernetes/charts/salt-minion-kubernetes \
--version 1.0.0 \
--set agent.saltMasterHost=salt-master.example.com
```
## Testing

Pull requests to `main` run `.github/workflows/ci-cd-pr.yml`:

(`agent.image.repository` already defaults to the published
`ghcr.io/saltstack/salt-kubernetes/salt-minion-kubernetes` image - no override
needed there.)
- hadolint on every Dockerfile under `src/`
- `helm unittest` on the three charts (only `helm/salt-minion` has test
suites, in `helm/salt-minion/tests`)
- `helm lint` on the three charts
- `go fmt` and `go vet` for the operator
- builds of all four images (nothing is pushed) and Trivy scans in log-only
mode (vulnerabilities do not fail the build)
- `helm package` of the three charts

### salt-minion-vcf
The same workflow without the unit tests runs again after merge
(`post-merge.yml`). To run the chart unit tests locally:

```bash
helm install salt-minion-vcf \
oci://ghcr.io/saltstack/salt-kubernetes/charts/salt-minion-vcf \
--version 1.0.0 \
--set image.repository=ghcr.io/saltstack/salt-kubernetes/salt-minion-vcf \
--set image.tag=0.1.1 \
--set salt.master=salt-master.example.com
helm plugin install https://github.com/helm-unittest/helm-unittest
helm unittest helm/salt-minion
```

`salt-minion-vcf` also runs as a plain Docker container, pulling the
published image directly - no Kubernetes required. See
[`salt-minion-vcf/README.md`](salt-minion-vcf/README.md) for the full guide,
including Docker Compose and the local Vault-backed testing workflow.
There are no unit tests for the master or key operator charts and no Go unit
tests run in CI (`go test` is not part of the workflow). The cluster-level
test procedure is in [`docs/complete-system-test.md`](docs/complete-system-test.md).

```bash
docker run -d \
--name salt-minion-vcf \
-e SALT_MASTER=salt-master.example.com \
-v salt-minion-vcf-pki:/etc/salt/pki/minion \
ghcr.io/saltstack/salt-kubernetes/salt-minion-vcf:0.1.1
```
## Documentation

See each chart's `values.yaml` for the full list of configurable parameters.
- [`docs/building.md`](docs/building.md): build images and charts from source
- [`docs/releasing.md`](docs/releasing.md), [`docs/release-prep.md`](docs/release-prep.md): publishing
- [`docs/helm-test.md`](docs/helm-test.md): try a chart on a real cluster with a private registry
- [`docs/complete-system-test.md`](docs/complete-system-test.md): end-to-end test of all components
- [`docs/kubernetes-compliance-guide.md`](docs/kubernetes-compliance-guide.md): CIS assessment workflow
- [`docs/ci-debug.md`](docs/ci-debug.md): reproduce CI failures locally

## Building from source
## License

Need a patched image, a different Salt version, or an air-gapped build with
no route to GHCR? See [`docs/building.md`](docs/building.md).
See [`LICENSE`](LICENSE).
Loading
Loading