Skip to content

Commit

Permalink
add extraVolume and extraVolumeMounts options to helm
Browse files Browse the repository at this point in the history
Signed-off-by: Burak Sekili <[email protected]>
  • Loading branch information
buraksekili committed Jul 4, 2023
1 parent 77b754e commit 3f8b8b1
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 6 deletions.
4 changes: 4 additions & 0 deletions config/helm/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ patchesStrategicMerge:
- manager_env_vars_patch.yaml
# add custom node selector
- manager_node_selector_patch.yaml
# add extraVolume for manager pod
- manager_extra_volume.yaml
# add extraVolumeMounts for manager pod
- manager_extra_volumemounts.yaml

# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in
# crd/kustomization.yaml
Expand Down
10 changes: 10 additions & 0 deletions config/helm/manager_extra_volume.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: controller-manager
namespace: system
spec:
template:
spec:
volumes:
- name: CONTROLLER_MANAGER_EXTRA_VOLUME
13 changes: 13 additions & 0 deletions config/helm/manager_extra_volumemounts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: controller-manager
namespace: system
spec:
template:
spec:
containers:
- name: manager
volumeMounts:
- mountPath: CONTROLLER_MANAGER_EXTRA_VOLUMEMOUNTS

14 changes: 14 additions & 0 deletions hack/helm/pre_helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ func main() {
{securityContext, securityContextTPL},
{imageRBAC, imageRBACTPL},
{nodeSelector, nodeSelectorTPL},
{extraVolume, extraVolumeTPL},
{extraVolumeMounts, extraVolumeMountsTPL},

{"OPERATOR_FULLNAME", `{{ include "tyk-operator-helm.fullname" . }}`},
{"RELEASE_NAMESPACE", "{{ .Release.Namespace }}"},
Expand Down Expand Up @@ -127,3 +129,15 @@ const nodeSelectorTPL = `{{- if .Values.nodeSelector }}
nodeSelector:
{{ toYaml .Values.nodeSelector | indent 8 }}
{{- end }}`

const extraVolume = `- name: CONTROLLER_MANAGER_EXTRA_VOLUME`

const extraVolumeTPL = ` {{ if .Values.extraVolumes }}
{{ toYaml .Values.extraVolumes | nindent 6 }}
{{ end }}`

const extraVolumeMounts = `- mountPath: CONTROLLER_MANAGER_EXTRA_VOLUMEMOUNTS`

const extraVolumeMountsTPL = ` {{ if .Values.extraVolumeMounts }}
{{ toYaml .Values.extraVolumeMounts | nindent 8 }}
{{ end }}`
12 changes: 6 additions & 6 deletions helm/templates/all.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -456,12 +456,12 @@ spec:
{{- toYaml . | nindent 10 }}
{{- end }}
volumeMounts:
{{ if .Values.extraVolumeMounts }}
{{ toYaml .Values.extraVolumeMounts | nindent 8 }}
{{ end }}
- mountPath: /tmp/k8s-webhook-server/serving-certs
name: cert
readOnly: true
{{ if .Values.extraVolumeMounts }}
{{ toYaml .Values.extraVolumeMounts | nindent 8 }}
{{ end }}
- mountPath: /controller_manager_config.yaml
name: manager-config
subPath: controller_manager_config.yaml
Expand Down Expand Up @@ -490,13 +490,13 @@ spec:
serviceAccountName: {{ include "tyk-operator-helm.fullname" . }}-controller-manager
terminationGracePeriodSeconds: 10
volumes:
{{ if .Values.extraVolumes }}
{{ toYaml .Values.extraVolumes | nindent 6 }}
{{ end }}
- name: cert
secret:
defaultMode: 420
secretName: webhook-server-cert
{{ if .Values.extraVolumes }}
{{ toYaml .Values.extraVolumes | nindent 6 }}
{{ end }}
- configMap:
name: {{ include "tyk-operator-helm.fullname" . }}-manager-config
name: manager-config
Expand Down

0 comments on commit 3f8b8b1

Please sign in to comment.