Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mounts puppetserver.extraSecrets into pods #221

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
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
33 changes: 33 additions & 0 deletions templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,39 @@ Return puppetdb certificate name without extension
{{- end -}}
{{- end -}}

{{/*
Return unique list of volumes from puppetserver.extraSecrets
*/}}
{{- define "puppetserver.extraSecrets.volumes" -}}
{{- $secretList := list -}}
{{- range $secret := .Values.puppetserver.extraSecrets -}}
{{- if not (has $secret.name $secretList) -}}
{{- $secretList = append $secretList $secret.name -}}
{{- end -}}
{{- end -}}
{{- range $secretName := $secretList }}
- name: {{ $secretName }}-volume
secret:
secretName: {{ $secretName }}
{{- end -}}
{{- end -}}

{{/*
Return volumeMounts from puppetserver.extraSecrets
*/}}
{{- define "puppetserver.extraSecrets.volumeMounts" -}}
{{- range $secret := .Values.puppetserver.extraSecrets }}
- name: {{ $secret.name }}-volume
{{- range $k, $v := $secret }}
{{- if not (eq $k "name") }}
{{ $k }}: {{ $v }}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}



{{/* *************************************************************************************
The following definitions were more complex and necessary during part of this development.
Now they are essentially just stubs but left here in case they might be needed again soon.
Expand Down
10 changes: 5 additions & 5 deletions templates/puppet-preInstall.job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ spec:
{{- end }}
- name: puppet-serverdata-storage
mountPath: /opt/puppetlabs/server/data/puppetserver/
{{- include "puppetserver.extraSecrets.volumeMounts" . | nindent 12 }}
securityContext:
runAsUser: 0
runAsNonRoot: false
Expand Down Expand Up @@ -167,6 +168,7 @@ spec:
mountPath: /crl
{{- end }}
{{- end }}
{{- include "puppetserver.extraSecrets.volumeMounts" . | nindent 12 }}
{{- if .Values.global.runAsNonRoot }}
securityContext:
runAsUser: {{ .Values.global.securityContext.runAsUser }}
Expand Down Expand Up @@ -225,6 +227,7 @@ spec:
mountPath: /crl
{{- end }}
{{- end }}
{{- include "puppetserver.extraSecrets.volumeMounts" . | nindent 12 }}
{{- if .Values.global.runAsNonRoot }}
securityContext:
runAsUser: {{ .Values.global.securityContext.runAsUser }}
Expand Down Expand Up @@ -299,6 +302,7 @@ spec:
mountPath: /docker-custom-entrypoint.d/{{ $key }}
subPath: {{ $key }}
{{- end }}
{{- include "puppetserver.extraSecrets.volumeMounts" . | nindent 12 }}
securityContext:
runAsUser: 0
runAsNonRoot: false
Expand Down Expand Up @@ -368,11 +372,7 @@ spec:
secretName: {{ template "puppetserver.hiera.privateSecret" . }}
{{- end }}
{{- end }}
{{- range $extraSecret := .Values.puppetserver.extraSecrets }}
- name: {{ $extraSecret.name }}
secret:
secretName: {{ $extraSecret.name }}
{{- end }}
{{- include "puppetserver.extraSecrets.volumes" . | nindent 8 }}
{{- if or .Values.puppetserver.preGeneratedCertsJob.enabled .Values.singleCA.enabled }}
- name: puppetserver-certs
{{- if not .Values.singleCA.enabled }}
Expand Down
8 changes: 3 additions & 5 deletions templates/puppet-r10k-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ spec:
- name: r10k-code-volume
mountPath: /etc/puppetlabs/puppet/r10k_code.yaml
subPath: r10k_code.yaml
{{- include "puppetserver.extraSecrets.volumeMounts" . | nindent 10 }}
readinessProbe:
exec:
command:
Expand Down Expand Up @@ -176,6 +177,7 @@ spec:
mountPath: /etc/puppetlabs/puppet/eyaml/keys/private_key.pkcs7.pem
subPath: private_key.pkcs7.pem
{{- end }}
{{- include "puppetserver.extraSecrets.volumeMounts" . | nindent 12 }}
readinessProbe:
exec:
command: ["/bin/sh", "-ec", "test -f {{ .Values.r10k.hiera.cronJob.successFile }}"]
Expand Down Expand Up @@ -271,9 +273,5 @@ spec:
name: {{ .Values.hiera.eyaml.existingMap }}
{{- end }}
{{- end }}
{{- range $extraSecret := .Values.puppetserver.extraSecrets }}
- name: {{ $extraSecret.name }}
secret:
secretName: {{ $extraSecret.name }}
{{- end }}
{{- include "puppetserver.extraSecrets.volumes" . | nindent 8 }}
{{- end }}
11 changes: 5 additions & 6 deletions templates/puppetserver-deployment-compilers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ spec:
{{- end }}
- name: puppet-serverdata-storage
mountPath: /opt/puppetlabs/server/data/puppetserver/
{{- include "puppetserver.extraSecrets.volumeMounts" . | nindent 12 }}
{{- end }}
containers:
- name: {{ template "puppetserver.fullname" . }}
Expand Down Expand Up @@ -305,6 +306,7 @@ spec:
mountPath: /etc/puppetlabs/puppet/eyaml/keys
{{- end }}
{{- end }}
{{- include "puppetserver.extraSecrets.volumeMounts" . | nindent 12 }}
securityContext:
{{- if .Values.global.runAsNonRoot }}
runAsUser: {{ .Values.global.securityContext.runAsUser }}
Expand Down Expand Up @@ -380,7 +382,7 @@ spec:
mountPath: /etc/puppetlabs/code/
- name: puppet-puppet-storage
mountPath: /etc/puppetlabs/puppet/

{{- include "puppetserver.extraSecrets.volumeMounts" . | nindent 10 }}
readinessProbe:
exec:
command:
Expand Down Expand Up @@ -440,6 +442,7 @@ spec:
mountPath: /etc/puppetlabs/code/
- name: puppet-puppet-storage
mountPath: /etc/puppetlabs/puppet/
{{- include "puppetserver.extraSecrets.volumeMounts" . | nindent 10 }}
readinessProbe:
exec:
command: ["/bin/sh", "-ec", "test -f {{ .Values.r10k.hiera.cronJob.successFile }}"]
Expand Down Expand Up @@ -690,11 +693,7 @@ spec:
persistentVolumeClaim:
claimName: {{ template "puppetserver.persistence.confd.claimName" . }}
{{- end }}
{{- range $extraSecret := .Values.puppetserver.extraSecrets }}
- name: {{ $extraSecret.name }}
secret:
secretName: {{ $extraSecret.name }}
{{- end }}
{{- include "puppetserver.extraSecrets.volumes" . | nindent 8 }}
{{- if .Values.nodeSelector }}
nodeSelector:
{{ toYaml .Values.nodeSelector | nindent 10 }}
Expand Down
10 changes: 5 additions & 5 deletions templates/puppetserver-deployment-masters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ spec:
subPath: site.pp
- name: puppet-serverdata-storage
mountPath: /opt/puppetlabs/server/data/puppetserver/
{{- include "puppetserver.extraSecrets.volumeMounts" . | nindent 12 }}
{{- end }}
containers:
- name: {{ template "puppetserver.fullname" . }}
Expand Down Expand Up @@ -328,6 +329,7 @@ spec:
{{- end }}
{{- end }}
{{- end }}
{{- include "puppetserver.extraSecrets.volumeMounts" . | nindent 12 }}
securityContext:
{{- if .Values.global.runAsNonRoot }}
runAsUser: {{ .Values.global.securityContext.runAsUser }}
Expand Down Expand Up @@ -412,6 +414,7 @@ spec:
- name: r10k-code-volume
mountPath: /etc/puppetlabs/puppet/r10k_code.yaml
subPath: r10k_code.yaml
{{- include "puppetserver.extraSecrets.volumeMounts" . | nindent 10 }}
readinessProbe:
exec:
command:
Expand Down Expand Up @@ -471,6 +474,7 @@ spec:
mountPath: /etc/puppetlabs/code/
- name: puppet-puppet-storage
mountPath: /etc/puppetlabs/puppet/
{{- include "puppetserver.extraSecrets.volumeMounts" . | nindent 10 }}
readinessProbe:
exec:
command: ["/bin/sh", "-ec", "test -f {{ .Values.r10k.hiera.cronJob.successFile }}"]
Expand Down Expand Up @@ -733,11 +737,7 @@ spec:
persistentVolumeClaim:
claimName: {{ template "puppetserver.persistence.confd.claimName" . }}
{{- end }}
{{- range $extraSecret := .Values.puppetserver.extraSecrets }}
- name: {{ $extraSecret.name }}
secret:
secretName: {{ $extraSecret.name }}
{{- end }}
{{- include "puppetserver.extraSecrets.volumes" . | nindent 8 }}
{{- if .Values.nodeSelector }}
nodeSelector:
{{ toYaml .Values.nodeSelector | nindent 10 }}
Expand Down
9 changes: 8 additions & 1 deletion values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,14 @@ puppetserver:
# #!/bin/sh
# echo hi

## Optional Secrets to mount in puppetserver container
## Optional Secrets to mount in puppetserver container. Each secret is defined by its desired
## volumeMounts properties
##
## Sample:
## extraSecrets:
## - name: myBigSecret
## mountPath: /custom/path/secret
## readOnly: true
##
extraSecrets: []

Expand Down
Loading