Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

Commit

Permalink
feat: add ConfigMap support for static configuration (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
morremeyer authored Apr 15, 2022
1 parent b20776a commit ac4ae23
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 4 deletions.
2 changes: 1 addition & 1 deletion charts/cronjob/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: cronjob
description: Run jobs on a schedule
type: application
version: 2.0.5
version: 2.1.0
maintainers:
- name: morremeyer
email: [email protected]
22 changes: 21 additions & 1 deletion charts/cronjob/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# cronjob

![Version: 2.0.5](https://img.shields.io/badge/Version-2.0.5-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square)
![Version: 2.1.0](https://img.shields.io/badge/Version-2.1.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square)

Run jobs on a schedule

Expand Down Expand Up @@ -33,6 +33,22 @@ envValueFrom:
key: user
```
### configMap
If you want to pass yaml as a value, you need to specify it in block style:
```yaml
configMap:
enabled: true
data:
config.yml: |
foo: bar
map:
list:
- foo
- bar
```
## Upgrading
### To 2.0.0
Expand Down Expand Up @@ -60,6 +76,10 @@ The following default values have been changed:
| annotations | object | `{}` | |
| args | list | `[]` | arguments to pass to the command or binary being run |
| command | list | `[]` | the command or binary to run |
| configMap.data | object | `{}` | The data for the ConfigMap. Both keys and values need to be strings. |
| configMap.enabled | bool | `false` | If a ConfigMap with configurable values should be created |
| configMap.mountFiles | list | `[]` | Mounting of individual keys in the ConfigMap as files |
| configMap.mountPath | string | `""` | If specified, the ConfigMap is mounted as a directory at this path |
| env | list | `[]` | Directly set environment variables |
| envValueFrom | object | `{}` | Set environment variables from configMaps or Secrets |
| failedJobsHistoryLimit | string | `nil` | The number of failed finished jobs to retain. |
Expand Down
16 changes: 16 additions & 0 deletions charts/cronjob/README.md.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,22 @@ envValueFrom:
key: user
```

### configMap

If you want to pass yaml as a value, you need to specify it in block style:

```yaml
configMap:
enabled: true
data:
config.yml: |
foo: bar
map:
list:
- foo
- bar
```

## Upgrading

### To 2.0.0
Expand Down
13 changes: 13 additions & 0 deletions charts/cronjob/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{- if .Values.configMap.enabled }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "cronjob.fullname" . }}
labels:
{{- include "cronjob.labels" . | nindent 4 }}
data:
{{- range $key, $value := .Values.configMap.data }}
{{ $key }}: |
{{- $value | nindent 4 }}
{{- end }}
{{- end }}
20 changes: 18 additions & 2 deletions charts/cronjob/templates/cronjob.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,23 @@ spec:
valueFrom: {{- $value | toYaml | nindent 20 }}
{{- end }}
{{- end }}
{{- if or .Values.persistence.enabled .Values.additionalVolumeMounts }}
{{- if or .Values.persistence.enabled .Values.additionalVolumeMounts .Values.configMap.mountPath .Values.configMap.mountFiles }}
volumeMounts:
{{- if .Values.persistence.enabled }}
- name: data
mountPath: {{ .Values.persistence.mountPath }}
{{- end }}
{{- with .Values.configMap.mountPath }}
- name: configmap
mountPath: {{ . }}
readOnly: true
{{- end }}
{{- range $file := .Values.configMap.mountFiles }}
- name: configmap
mountPath: {{ .mountPath }}
subPath: {{ .subPath }}
readOnly: true
{{- end }}
{{- with .Values.additionalVolumeMounts }}
{{- toYaml . | nindent 16 }}
{{- end }}
Expand All @@ -89,7 +100,7 @@ spec:
{{- with .Values.tolerations }}
tolerations: {{- toYaml . | nindent 12 }}
{{- end }}
{{- if or .Values.persistence.enabled .Values.additionalVolumes }}
{{- if or .Values.persistence.enabled .Values.additionalVolumes .Values.configMap.mountPath .Values.configMap.mountFiles }}
volumes:
{{- if .Values.persistence.enabled }}
- name: data
Expand All @@ -99,4 +110,9 @@ spec:
{{- with .Values.additionalVolumes }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- if or .Values.configMap.mountPath .Values.configMap.mountFiles }}
- name: configmap
configMap:
name: {{ include "cronjob.fullname" . }}
{{- end }}
{{- end }}
15 changes: 15 additions & 0 deletions charts/cronjob/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,21 @@ labels: {}

annotations: {}

configMap:
# -- If a ConfigMap with configurable values should be created
enabled: false

# -- The data for the ConfigMap. Both keys and values need to be strings.
data: {}

# -- If specified, the ConfigMap is mounted as a directory at this path
mountPath: ""

# -- Mounting of individual keys in the ConfigMap as files
mountFiles: []
# - subPath: "config.yml"
# mountPath: /app/config.yml

persistence:
enabled: false

Expand Down

0 comments on commit ac4ae23

Please sign in to comment.