From 286e8945a20a1f77a4d07925c40205bbd5f58947 Mon Sep 17 00:00:00 2001 From: Markus Pesch Date: Fri, 10 Sep 2021 18:37:05 +0200 Subject: [PATCH] fix: support .env file --- templates/deployment.yaml | 25 ++++++++++++++++++++----- templates/envConfig.yaml | 11 +++++++++++ templates/secrets.yaml | 4 ++++ values.yaml | 6 ++++++ 4 files changed, 41 insertions(+), 5 deletions(-) create mode 100644 templates/envConfig.yaml diff --git a/templates/deployment.yaml b/templates/deployment.yaml index 6f92b8d..d66c2d8 100644 --- a/templates/deployment.yaml +++ b/templates/deployment.yaml @@ -35,16 +35,31 @@ spec: protocol: TCP resources: {{- toYaml .Values.resources | nindent 12 }} - {{- with .Values.nodeSelector }} - nodeSelector: - {{- toYaml . | nindent 8 }} - {{- end }} + {{- if and (hasKey .Values.envFile "content") (hasKey .Values.config "DRONE_RUNNER_ENV_FILE") }} + volumeMounts: + - name: env-file + mountPath: {{ dir .Values.config.DRONE_RUNNER_ENV_FILE }} + readOnly: true + {{- end}} {{- with .Values.affinity }} affinity: {{- toYaml . | nindent 8 }} {{- end }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "droneRunner.fullname" . }} {{- with .Values.tolerations }} tolerations: {{- toYaml . | nindent 8 }} {{- end }} - serviceAccountName: {{ include "droneRunner.fullname" . }} \ No newline at end of file + {{- if and (hasKey .Values.envFile "content") (hasKey .Values.config "DRONE_RUNNER_ENV_FILE") }} + volumes: + - name: env-file + configMap: + name: {{ include "droneRunner.fullname" . }} + items: + - key: {{ base .Values.config.DRONE_RUNNER_ENV_FILE }} + path: {{ base .Values.config.DRONE_RUNNER_ENV_FILE }} + {{- end}} diff --git a/templates/envConfig.yaml b/templates/envConfig.yaml new file mode 100644 index 0000000..1935079 --- /dev/null +++ b/templates/envConfig.yaml @@ -0,0 +1,11 @@ +{{- if and (hasKey .Values.envFile "content") (hasKey .Values.config "DRONE_RUNNER_ENV_FILE") }} +apiVersion: v1 +kind: ConfigMap +metadata: + labels: + {{- include "droneRunner.labels" . | nindent 4 }} + name: {{ include "droneRunner.fullname" . }} +data: + {{ base .Values.config.DRONE_RUNNER_ENV_FILE }}: | + {{ .Values.envFile.content }} +{{- end }} \ No newline at end of file diff --git a/templates/secrets.yaml b/templates/secrets.yaml index c0bf1d5..2969f17 100644 --- a/templates/secrets.yaml +++ b/templates/secrets.yaml @@ -13,6 +13,10 @@ stringData: {{- $_ := set .Values.config "DRONE_NAMESPACE_DEFAULT" .Release.Namespace -}} {{- end -}} + {{- if and (not (hasKey .Values.config "DRONE_RUNNER_ENV_FILE")) (hasKey .Values.envFile "content") }} + {{- $_ := set .Values.config "DRONE_RUNNER_ENV_FILE" "/tmp/drone-runner/drone.conf" -}} + {{- end }} + {{/* SETUP CONFIG */}} {{ range $key, $value := .Values.config }} {{ upper $key}}: {{ quote $value }} diff --git a/values.yaml b/values.yaml index f915811..9f5afe0 100644 --- a/values.yaml +++ b/values.yaml @@ -334,6 +334,12 @@ config: # https://docs.drone.io/runner/kubernetes/configuration/reference/drone-ui-username/ # DRONE_UI_USERNAME: "" +envFile: {} + # content: | + # KEY=VALUE + + + resources: {} # We usually recommend not to specify default resources and to leave this as a conscious # choice for the user. This also increases chances charts run on environments with little