Skip to content

Commit 961c003

Browse files
authored
Integrate SecretsStoreCSI Driver (Vault Provider) as secrets source option (#118)
1 parent 61cb63b commit 961c003

File tree

4 files changed

+91
-1
lines changed

4 files changed

+91
-1
lines changed

docs/configuration.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,14 @@ Terraform Enterprise now supports the inclusion of a custom pod template via `ag
6161
With this, you can define your own specifications for the creation of the agent worker pods.
6262
The custom pod template must be a valid `corev1.PodTemplateSpec` and should be provided in YAML format. The `PodTemplateSpec` is
6363
documented at <https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-template-v1/#PodTemplateSpec>.
64+
65+
66+
## Vault CSI Provider
67+
Terraform Enterprise now supports [Vault CSI provider](https://developer.hashicorp.com/vault/docs/platform/k8s/csi). This allows TFE pods to consume Vault secrets using CSI Secrets Store volumes.
68+
69+
The settings for this can be found in the `values.yaml` file under the `csi` section.
70+
If `csi.enabled` is set to true, the Vault CSI provider will be used to retrieve secrets, as it is the only supported provider. This requires using an external Vault.
71+
72+
The Secrets Store CSI Driver also supports syncing to Kubernetes secret objects. The `secretObjects` section adds secret syncing for TFE if values are provided.
73+
74+
**Note:** The Vault CSI Provider requires the [CSI Secret Store Driver](https://secrets-store-csi-driver.sigs.k8s.io/getting-started/installation.html) to be installed.

templates/deployment.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,14 @@ spec:
5959
secret:
6060
secretName: terraform-enterprise-ca-certificates
6161
{{- end }}
62+
{{- if .Values.csi.enabled }}
63+
- name: secrets-store
64+
csi:
65+
driver: secrets-store.csi.k8s.io
66+
readOnly: true
67+
volumeAttributes:
68+
secretProviderClass: "{{ .Values.csi.secretProviderClass }}"
69+
{{- end }}
6270
{{- with .Values.extraVolumes }}
6371
{{- toYaml . | nindent 8 }}
6472
{{- end }}
@@ -127,6 +135,11 @@ spec:
127135
mountPath: {{ include "cacert.path" . }}
128136
subPath: {{ .Values.tls.caCertFileName }}
129137
{{- end }}
138+
{{- if .Values.csi.enabled }}
139+
- name: secrets-store
140+
mountPath: "{{ .Values.csi.mountPath }}"
141+
readOnly: true
142+
{{- end }}
130143
{{- with .Values.extraVolumeMounts }}
131144
{{- toYaml . | nindent 10 }}
132145
{{- end }}

templates/secretproviderclass.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{{- if .Values.csi.enabled }}
2+
apiVersion: secrets-store.csi.x-k8s.io/v1
3+
kind: SecretProviderClass
4+
metadata:
5+
name: {{ .Values.csi.secretProviderClass }}
6+
namespace: {{ .Release.Namespace }}
7+
{{- with .Values.csi.annotations }}
8+
annotations:
9+
{{- toYaml . | nindent 4 }}
10+
{{- end }}
11+
{{- with .Values.csi.labels }}
12+
labels:
13+
{{- toYaml . | nindent 4 }}
14+
{{- end }}
15+
spec:
16+
provider: vault
17+
parameters:
18+
roleName: "{{ .Values.csi.vaultRole }}"
19+
vaultAddress: "{{ .Values.csi.vaultAddress }}"
20+
objects: |
21+
{{- range .Values.csi.secrets }}
22+
- objectName: "{{ .objectName }}"
23+
secretPath: "{{ .secretPath }}"
24+
secretKey: "{{ .secretKey }}"
25+
{{- end }}
26+
{{- if .Values.csi.secretObjects }}
27+
secretObjects:
28+
{{- range .Values.csi.secretObjects }}
29+
- data:
30+
{{- range .data }}
31+
- key: {{ .key }}
32+
objectName: {{ .objectName }}
33+
{{- end }}
34+
secretName: {{ .secretName }}
35+
type: {{ .type }}
36+
{{- end }}
37+
{{- end }}
38+
{{- end }}

values.yaml

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ agents:
298298
annotations: {}
299299
labels: {}
300300

301-
# Extra volumes to add to the deployment's pod.
301+
# Extra volumes to add to the deployment's pod.
302302
# Reference: https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#volumes
303303
# Usecases:
304304
## mount external secrets, such as certificates from cert-manager
@@ -331,3 +331,31 @@ pdb:
331331
replicaCount: 1
332332
annotations: {}
333333
labels: {}
334+
335+
# CSI driver settings for Vault provider
336+
csi:
337+
enabled: false
338+
annotations: {}
339+
labels: {}
340+
secretProviderClass: terraform-enterprise-vault-secrets
341+
vaultRole: ""
342+
vaultAddress: "" # Example: http://vault.vault-namespace.svc.cluster.local:8200
343+
mountPath: "" # Example: /mnt/secrets-store
344+
secrets:
345+
# The path to the secret defined in Vault. Example: secret/data/db
346+
- secretPath: ""
347+
# The key of the secret defined in Vault.
348+
secretKey: ""
349+
# A name for the secret
350+
objectName: ""
351+
# If this is added, secrets will be synced to Kubernetes secrets.
352+
secretObjects:
353+
- data:
354+
# secret key from secrets section
355+
- key: ""
356+
# Object name from secrets section
357+
objectName: ""
358+
# Name of the Kubernetes secret
359+
secretName: ""
360+
# Type of the Kubernetes secret. Example: Opaque
361+
type: ""

0 commit comments

Comments
 (0)