Skip to content

Commit

Permalink
v3.0.757
Browse files Browse the repository at this point in the history
  • Loading branch information
env0 User committed May 22, 2024
1 parent 40974b5 commit ec08f68
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
22 changes: 22 additions & 0 deletions templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,25 @@ securityContext:
runAsGroup: {{ .Values.runAsGroup | default 1000 }}
{{- end }}
{{- end }}

{{- define "env0-agent.shouldUsePVC" -}}
{{- $secretValue := dict -}}
{{- if (hasKey .Values "env0ConfigSecretName") -}}
{{- $secretValue = (lookup "v1" "Secret" .Release.Namespace .Values.env0ConfigSecretName).data -}}
{{- end -}}

{{- if (hasKey .Values "env0StateEncryptionKey") -}}
false
{{- else if (not (hasKey .Values "env0ConfigSecretName")) -}}
{{- /* no env0StateEncryptionKey in Values AND no env0ConfigSecretName provided */ -}}
true
{{- else -}}
{{- if (hasKey $secretValue "ENV0_STATE_ENCRYPTION_KEY") -}}
{{- /* k8s Secret contains ENV0_STATE_ENCRYPTION_KEY - no need for PVC */ -}}
false
{{- else -}}
{{- /* k8s Secret does NOT contain ENV0_STATE_ENCRYPTION_KEY */ -}}
true
{{- end -}}
{{- end -}}
{{- end -}}
2 changes: 1 addition & 1 deletion templates/persistent-volume-claim.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{ if not (hasKey .Values "env0StateEncryptionKey") }}
{{- if (eq (include "env0-agent.shouldUsePVC" .) "true") }}
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
Expand Down
9 changes: 4 additions & 5 deletions templates/scaled-job.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{{- $stateMountPath := ternary "/mnt/public/" .Values.stateMountPath (.Values.strictSecurityContext | default false) -}}

# a cron job that never runs.
# its job template is used to trigger jobs via k8s api
apiVersion: {{ if .Capabilities.APIVersions.Has "batch/v1/CronJob" }}batch/v1{{ else }}batch/v1beta1{{ end }}
Expand Down Expand Up @@ -36,11 +35,11 @@ spec:
{{ end }}
spec:
volumes:
{{ if not (hasKey .Values "env0StateEncryptionKey") }}
{{- if (eq (include "env0-agent.shouldUsePVC" .) "true") }}
- name: env0-state-volume
persistentVolumeClaim:
claimName: env0-state-volume-claim
{{ end }}
{{- end }}
- name: tmp
emptyDir: { }
- name: home
Expand Down Expand Up @@ -97,10 +96,10 @@ spec:
- update-ca-certificates;
node --enable-source-maps main.js;
volumeMounts:
{{ if not (hasKey .Values "env0StateEncryptionKey") }}
{{- if (eq (include "env0-agent.shouldUsePVC" .) "true") }}
- name: env0-state-volume
mountPath: {{ $stateMountPath }}
{{ end }}
{{- end }}
{{ if .Values.customCertificates }}
- name: etc-ssl-certs
mountPath: /etc/ssl/certs
Expand Down

0 comments on commit ec08f68

Please sign in to comment.