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
7 changes: 6 additions & 1 deletion helm/salt-minion/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,14 @@ See [values.yaml](values.yaml) for the complete list of configuration options.
| --- | --- | --- |
| `namespace` | Kubernetes namespace for deployment | `salt` |
| `agent.authMode` | `in_cluster` or `external` | `in_cluster` |
| `agent.image.repository` | Docker image repository | `ghcr.io/saltstack/salt-kubernetes/salt-minion` |
| `agent.image.repository` | Minion image repository | `ghcr.io/saltstack/salt-kubernetes/salt-minion` |
| `agent.image.tag` | Image tag/version | `0.1.0` |
| `agent.image.pullPolicy` | Image pull policy | `IfNotPresent` |
| `agent.image.imagePullSecrets` | Minion pull Secrets | `[]` |
| `keygen.image.repository` | Keygen image repository | `bitnami/kubectl` |
| `keygen.image.tag` | Keygen image tag | `latest` |
| `keygen.image.pullPolicy` | Keygen image pull policy | `Always` |
| `keygen.image.imagePullSecrets` | Keygen pull Secrets | `[]` |
| `agent.saltMasterHost` | Salt master hostname or comma-separated list (REQUIRED) | `""` |
| `agent.saltMasterPort` | Master request/return port | `4506` |
| `agent.saltPublishPort` | Master publish port | `4505` |
Expand Down
14 changes: 14 additions & 0 deletions helm/salt-minion/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{{/* Format an image repository and tag. */}}
{{- define "salt-minion.image" -}}
{{- printf "%s:%s" .repository (toString .tag) -}}
{{- end -}}

{{/* Resolve the minion image from chart values. */}}
{{- define "salt-minion.agentImage" -}}
{{- include "salt-minion.image" .Values.agent.image -}}
{{- end -}}

{{/* Resolve the key-generation image from chart values. */}}
{{- define "salt-minion.keygenImage" -}}
{{- include "salt-minion.image" .Values.keygen.image -}}
{{- end -}}
8 changes: 6 additions & 2 deletions helm/salt-minion/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ spec:
app.kubernetes.io/name: salt-minion
spec:
serviceAccountName: {{ .Values.serviceAccount.name }}
{{- with .Values.agent.image.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}

{{- with .Values.agent.nodeSelector }}
nodeSelector:
Expand All @@ -33,7 +37,7 @@ spec:

initContainers:
- name: prepare-minion-keys
image: {{ .Values.agent.image.repository }}:{{ .Values.agent.image.tag }}
image: {{ include "salt-minion.agentImage" . | quote }}
imagePullPolicy: {{ .Values.agent.image.pullPolicy }}
command:
- /bin/sh
Expand Down Expand Up @@ -72,7 +76,7 @@ spec:

containers:
- name: salt-minion
image: {{ .Values.agent.image.repository }}:{{ .Values.agent.image.tag }}
image: {{ include "salt-minion.agentImage" . | quote }}
imagePullPolicy: {{ .Values.agent.image.pullPolicy }}
env:
- name: SALT_MASTER
Expand Down
7 changes: 6 additions & 1 deletion helm/salt-minion/templates/keygen-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,16 @@ spec:
template:
spec:
serviceAccountName: {{ .Values.serviceAccount.name }}
{{- with .Values.keygen.image.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
automountServiceAccountToken: true
restartPolicy: OnFailure
containers:
- name: keygen
image: bitnami/kubectl:latest
image: {{ include "salt-minion.keygenImage" . | quote }}
imagePullPolicy: {{ .Values.keygen.image.pullPolicy }}
command: ["/bin/sh", "-c"]
args:
- |
Expand Down
97 changes: 97 additions & 0 deletions helm/salt-minion/tests/images_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
suite: workload images
templates:
- templates/deployment.yaml
- templates/keygen-job.yaml
tests:
- it: renders the default images
asserts:
- template: templates/deployment.yaml
equal:
path: spec.template.spec.containers[?(@.name == "salt-minion")].image
value: ghcr.io/saltstack/salt-kubernetes/salt-minion:0.1.0
- template: templates/keygen-job.yaml
equal:
path: spec.template.spec.containers[?(@.name == "keygen")].image
value: bitnami/kubectl:latest

- it: preserves quoted tags with trailing zeros
set:
agent.image.tag: '1.10'
keygen.image.tag: '1.10'
asserts:
- template: templates/deployment.yaml
equal:
path: spec.template.spec.containers[?(@.name == "salt-minion")].image
value: ghcr.io/saltstack/salt-kubernetes/salt-minion:1.10
- template: templates/keygen-job.yaml
equal:
path: spec.template.spec.containers[?(@.name == "keygen")].image
value: bitnami/kubectl:1.10

- it: renders numeric tags
set:
agent.image.tag: 123
keygen.image.tag: 123
asserts:
- template: templates/deployment.yaml
equal:
path: spec.template.spec.containers[?(@.name == "salt-minion")].image
value: ghcr.io/saltstack/salt-kubernetes/salt-minion:123
- template: templates/keygen-job.yaml
equal:
path: spec.template.spec.containers[?(@.name == "keygen")].image
value: bitnami/kubectl:123

- it: uses each configured repository
set:
agent.image.repository: mirror.example:5000/team/minion
keygen.image.repository: other.example/team/kubectl
asserts:
- template: templates/deployment.yaml
equal:
path: spec.template.spec.containers[?(@.name == "salt-minion")].image
value: mirror.example:5000/team/minion:0.1.0
- template: templates/deployment.yaml
equal:
path: spec.template.spec.initContainers[?(@.name == "prepare-minion-keys")].image
value: mirror.example:5000/team/minion:0.1.0
- template: templates/keygen-job.yaml
equal:
path: spec.template.spec.containers[?(@.name == "keygen")].image
value: other.example/team/kubectl:latest

- it: uses separate pull secrets for each workload
set:
agent.image.imagePullSecrets:
- name: agent-secret
keygen.image.imagePullSecrets:
- name: keygen-secret
asserts:
- template: templates/deployment.yaml
equal:
path: spec.template.spec.imagePullSecrets
value:
- name: agent-secret
- template: templates/keygen-job.yaml
equal:
path: spec.template.spec.imagePullSecrets
value:
- name: keygen-secret

- it: does not apply the minion pull secret to keygen
set:
agent.image.imagePullSecrets:
- name: agent-secret
asserts:
- template: templates/keygen-job.yaml
notExists:
path: spec.template.spec.imagePullSecrets

- it: does not apply the keygen pull secret to the minion
set:
keygen.image.imagePullSecrets:
- name: keygen-secret
asserts:
- template: templates/deployment.yaml
notExists:
path: spec.template.spec.imagePullSecrets
8 changes: 8 additions & 0 deletions helm/salt-minion/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ agent:

# ── in_cluster mode settings ──────────────────────────────────────────────
image:
imagePullSecrets: []
# Published by this repo (see ../docs/releasing.md and CHANGELOG.md for
# exactly which Salt/extension versions this tag carries) - preloaded
# with saltext.vault and saltext.kubernetes on top of core Salt. Point
Expand Down Expand Up @@ -171,6 +172,13 @@ agent:
# `kubectl get nodes` for hostnames.
nodeSelector: {}

keygen:
image:
imagePullSecrets: []
repository: bitnami/kubectl
tag: latest
pullPolicy: Always

serviceAccount:
name: salt-minion
# Add EKS IRSA or other provider-specific annotations here.
Expand Down
Loading