Skip to content
This repository was archived by the owner on Mar 22, 2024. It is now read-only.

Commit b7f8c86

Browse files
committed
Add extra initContainers, containers, volumes to agent and server
With plugin support, agents and servers need more customization. This patch enables initContainers, extraContainers, extraVolumes and extraVolumeMounts to be added to those services. Signed-off-by: Kevin Fox <[email protected]>
1 parent 81ac89a commit b7f8c86

File tree

7 files changed

+106
-0
lines changed

7 files changed

+106
-0
lines changed

.github/tests/extras/values.yaml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
spire-agent:
2+
initContainers:
3+
- name: extra-init
4+
image: busybox
5+
command:
6+
- sh
7+
- -xec
8+
- |
9+
echo 'hi there' > /extra/file
10+
volumeMounts:
11+
- name: extra
12+
mountPath: /extra
13+
extraContainers:
14+
- name: extra
15+
image: busybox
16+
command:
17+
- sh
18+
- -xec
19+
- |
20+
[ -f /extra/file ]
21+
while true; do sleep 1000; done
22+
volumeMounts:
23+
- name: extra
24+
mountPath: /extra
25+
extraVolumeMounts:
26+
- name: extra
27+
mountPath: /extra
28+
extraVolumes:
29+
- name: extra
30+
emptyDir: {}
31+
32+
spire-server:
33+
initContainers:
34+
- name: extra-init
35+
image: busybox
36+
command:
37+
- sh
38+
- -xec
39+
- |
40+
echo 'hi there' > /extra/file
41+
volumeMounts:
42+
- name: extra
43+
mountPath: /extra
44+
extraContainers:
45+
- name: extra
46+
image: busybox
47+
command:
48+
- sh
49+
- -xec
50+
- |
51+
[ -f /extra/file ]
52+
while true; do sleep 1000; done
53+
volumeMounts:
54+
- name: extra
55+
mountPath: /extra
56+
extraVolumeMounts:
57+
- name: extra
58+
mountPath: /extra
59+
extraVolumes:
60+
- name: extra
61+
emptyDir: {}

charts/spire/charts/spire-agent/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,17 @@ A Helm chart to install the SPIRE agent.
1616
|-----|------|---------|-------------|
1717
| bundleConfigMap | string | `"spire-bundle"` | |
1818
| clusterName | string | `"example-cluster"` | |
19+
| extraContainers | list | `[]` | |
20+
| extraVolumeMounts | list | `[]` | |
21+
| extraVolumes | list | `[]` | |
1922
| fullnameOverride | string | `""` | |
2023
| healthChecks.port | int | `9980` | override the host port used for health checking |
2124
| image.pullPolicy | string | `"IfNotPresent"` | |
2225
| image.registry | string | `"ghcr.io"` | |
2326
| image.repository | string | `"spiffe/spire-agent"` | |
2427
| image.version | string | `""` | |
2528
| imagePullSecrets | list | `[]` | |
29+
| initContainers | list | `[]` | |
2630
| logLevel | string | `"info"` | |
2731
| nameOverride | string | `""` | |
2832
| nodeSelector | object | `{}` | |

charts/spire/charts/spire-agent/templates/daemonset.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ spec:
4343
args: ["-t", "30", "-h", "{{ .Release.Name }}-server", "-p", {{ .Values.server.port | quote }}]
4444
resources:
4545
{{- toYaml .Values.waitForIt.resources | nindent 12 }}
46+
{{- if gt (len .Values.initContainers) 0 }}
47+
{{- toYaml .Values.initContainers | nindent 8 }}
48+
{{- end }}
4649
containers:
4750
- name: {{ .Chart.Name }}
4851
image: {{ template "spire-agent.image" (dict "appVersion" $.Chart.AppVersion "image" .Values.image) }}
@@ -67,6 +70,9 @@ spec:
6770
readOnly: false
6871
- name: spire-token
6972
mountPath: /var/run/secrets/tokens
73+
{{- if gt (len .Values.extraVolumeMounts) 0 }}
74+
{{- toYaml .Values.extraVolumeMounts | nindent 12 }}
75+
{{- end }}
7076
livenessProbe:
7177
httpGet:
7278
path: /live
@@ -81,6 +87,9 @@ spec:
8187
periodSeconds: 60
8288
resources:
8389
{{- toYaml .Values.resources | nindent 12 }}
90+
{{- if gt (len .Values.extraContainers) 0 }}
91+
{{- toYaml .Values.extraContainers | nindent 8 }}
92+
{{- end }}
8493
{{- with .Values.nodeSelector }}
8594
nodeSelector:
8695
{{- toYaml . | nindent 8 }}
@@ -103,3 +112,6 @@ spec:
103112
hostPath:
104113
path: {{ include "spire.agent-socket-path" . | dir }}
105114
type: DirectoryOrCreate
115+
{{- if gt (len .Values.extraVolumes) 0 }}
116+
{{- toYaml .Values.extraVolumes | nindent 8 }}
117+
{{- end }}

charts/spire/charts/spire-agent/values.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,9 @@ telemetry:
8686

8787
# -- Priority class assigned to daemonset pods
8888
priorityClassName: ""
89+
90+
extraVolumes: []
91+
extraVolumeMounts: []
92+
extraContainers: []
93+
94+
initContainers: []

charts/spire/charts/spire-server/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,16 @@ A Helm chart to install the SPIRE server.
4949
| dataStorage.enabled | bool | `true` | |
5050
| dataStorage.size | string | `"1Gi"` | |
5151
| dataStorage.storageClass | string | `nil` | |
52+
| extraContainers | list | `[]` | |
53+
| extraVolumeMounts | list | `[]` | |
54+
| extraVolumes | list | `[]` | |
5255
| fullnameOverride | string | `""` | |
5356
| image.pullPolicy | string | `"IfNotPresent"` | |
5457
| image.registry | string | `"ghcr.io"` | |
5558
| image.repository | string | `"spiffe/spire-server"` | |
5659
| image.version | string | `""` | |
5760
| imagePullSecrets | list | `[]` | |
61+
| initContainers | list | `[]` | |
5862
| jwtIssuer | string | `"oidc-discovery.example.org"` | |
5963
| logLevel | string | `"info"` | |
6064
| nameOverride | string | `""` | |

charts/spire/charts/spire-server/templates/statefulset.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ spec:
3232
shareProcessNamespace: true
3333
securityContext:
3434
{{- toYaml .Values.podSecurityContext | nindent 8 }}
35+
{{- if gt (len .Values.initContainers) 0 }}
36+
initContainers:
37+
{{- toYaml .Values.initContainers | nindent 8 }}
38+
{{- end }}
3539
containers:
3640
- name: {{ .Chart.Name }}
3741
securityContext:
@@ -87,6 +91,9 @@ spec:
8791
mountPath: /run/spire/upstream_ca
8892
readOnly: false
8993
{{ end }}
94+
{{- if gt (len .Values.extraVolumeMounts) 0 }}
95+
{{- toYaml .Values.extraVolumeMounts | nindent 12 }}
96+
{{- end }}
9097
{{- if eq (.Values.controllerManager.enabled | toString) "true" }}
9198
- name: spire-controller-manager
9299
securityContext:
@@ -124,6 +131,9 @@ spec:
124131
subPath: controller-manager-config.yaml
125132
readOnly: true
126133
{{- end }}
134+
{{- if gt (len .Values.extraContainers) 0 }}
135+
{{- toYaml .Values.extraContainers | nindent 8 }}
136+
{{- end }}
127137
{{- with .Values.nodeSelector }}
128138
nodeSelector:
129139
{{- toYaml . | nindent 8 }}
@@ -156,6 +166,9 @@ spec:
156166
configMap:
157167
name: {{ include "spire-controller-manager.fullname" . }}
158168
{{- end }}
169+
{{- if gt (len .Values.extraVolumes) 0 }}
170+
{{- toYaml .Values.extraVolumes | nindent 8 }}
171+
{{- end }}
159172
volumeClaimTemplates:
160173
{{- if eq (.Values.dataStorage.enabled | toString) "true" }}
161174
- metadata:

charts/spire/charts/spire-server/values.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,3 +161,9 @@ controllerManager:
161161
telemetry:
162162
prometheus:
163163
enabled: false
164+
165+
extraVolumes: []
166+
extraVolumeMounts: []
167+
extraContainers: []
168+
169+
initContainers: []

0 commit comments

Comments
 (0)