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

Update defaults for extra values to support lists #522

Merged
merged 5 commits into from
Apr 21, 2020
Merged
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
8 changes: 4 additions & 4 deletions elasticsearch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,10 @@ helm install --name elasticsearch elastic/elasticsearch --set imageTag=7.6.2
| `esMajorVersion` | Used to set major version specific configuration. If you are using a custom image and not running the default Elasticsearch version you will need to set this to the version you are running (e.g. `esMajorVersion: 6`) | `""` |
| `esConfig` | Allows you to add any config files in `/usr/share/elasticsearch/config/` such as `elasticsearch.yml` and `log4j2.properties`. See [values.yaml](https://github.com/elastic/helm-charts/tree/master/elasticsearch/values.yaml) for an example of the formatting. | `{}` |
| `extraEnvs` | Extra [environment variables](https://kubernetes.io/docs/tasks/inject-data-application/define-environment-variable-container/#using-environment-variables-inside-of-your-config) which will be appended to the `env:` definition for the container | `[]` |
| `extraVolumes` | Templatable string of additional volumes to be passed to the `tpl` function | `""` |
| `extraVolumeMounts` | Templatable string of additional volumeMounts to be passed to the `tpl` function | `""` |
| `extraContainers` | Templatable string of additional containers to be passed to the `tpl` function | `""` |
| `extraInitContainers` | Templatable string of additional init containers to be passed to the `tpl` function | `""` |
| `extraVolumes` | Templatable string of additional volumes to be passed to the `tpl` function | `[]` |
| `extraVolumeMounts` | Templatable string of additional volumeMounts to be passed to the `tpl` function | `[]` |
| `extraContainers` | Templatable string of additional containers to be passed to the `tpl` function | `[]` |
| `extraInitContainers` | Templatable string of additional init containers to be passed to the `tpl` function | `[]` |
| `secretMounts` | Allows you easily mount a secret as a file inside the statefulset. Useful for mounting certificates and other secrets. See [values.yaml](https://github.com/elastic/helm-charts/tree/master/elasticsearch/values.yaml) for an example | `[]` |
| `image` | The Elasticsearch docker image | `docker.elastic.co/elasticsearch/elasticsearch` |
| `imageTag` | The Elasticsearch docker image tag | `7.6.2` |
Expand Down
28 changes: 28 additions & 0 deletions elasticsearch/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,14 @@ spec:
{{- end }}
{{ end }}
{{- if .Values.extraVolumes }}
domgoodwin marked this conversation as resolved.
Show resolved Hide resolved
# Currently some extra blocks accept strings
# to continue with backwards compatibility this is being kept
# whilst also allowing for yaml to be specified too.
{{- if eq "string" (printf "%T" .Values.extraVolumes) }}
{{ tpl .Values.extraVolumes . | indent 8 }}
{{- else }}
{{ toYaml .Values.extraVolumes | indent 8 }}
{{- end }}
{{- end }}
{{- if .Values.imagePullSecrets }}
imagePullSecrets:
Expand Down Expand Up @@ -183,7 +190,14 @@ spec:
{{- end }}
{{ end }}
{{- if .Values.extraInitContainers }}
# Currently some extra blocks accept strings
# to continue with backwards compatibility this is being kept
# whilst also allowing for yaml to be specified too.
{{- if eq "string" (printf "%T" .Values.extraInitContainers) }}
{{ tpl .Values.extraInitContainers . | indent 6 }}
{{- else }}
{{ toYaml .Values.extraInitContainers | indent 6 }}
{{- end }}
{{- end }}
containers:
- name: "{{ template "elasticsearch.name" . }}"
Expand Down Expand Up @@ -290,7 +304,14 @@ spec:
subPath: {{ $path }}
{{- end -}}
{{- if .Values.extraVolumeMounts }}
# Currently some extra blocks accept strings
# to continue with backwards compatibility this is being kept
# whilst also allowing for yaml to be specified too.
{{- if eq "string" (printf "%T" .Values.extraVolumeMounts) }}
{{ tpl .Values.extraVolumeMounts . | indent 10 }}
{{- else }}
{{ toYaml .Values.extraVolumeMounts | indent 10 }}
{{- end }}
{{- end }}
{{- if .Values.masterTerminationFix }}
{{- if eq .Values.roles.master "true" }}
Expand Down Expand Up @@ -351,5 +372,12 @@ spec:
{{ toYaml .Values.lifecycle | indent 10 }}
{{- end }}
{{- if .Values.extraContainers }}
# Currently some extra blocks accept strings
# to continue with backwards compatibility this is being kept
# whilst also allowing for yaml to be specified too.
{{- if eq "string" (printf "%T" .Values.extraContainers) }}
{{ tpl .Values.extraContainers . | indent 6 }}
{{- else }}
{{ toYaml .Values.extraContainers | indent 6 }}
{{- end }}
{{- end }}
57 changes: 57 additions & 0 deletions elasticsearch/tests/elasticsearch_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,29 @@ def test_adding_a_extra_volume_with_volume_mount():
} in extraVolumeMounts


def test_adding_a_extra_volume_with_volume_mount_as_yaml():
config = """
extraVolumes:
- name: extras
emptyDir: {}
extraVolumeMounts:
- name: extras
mountPath: /usr/share/extras
readOnly: true
"""
r = helm_template(config)
extraVolume = r["statefulset"][uname]["spec"]["template"]["spec"]["volumes"]
assert {"name": "extras", "emptyDir": {}} in extraVolume
extraVolumeMounts = r["statefulset"][uname]["spec"]["template"]["spec"][
"containers"
][0]["volumeMounts"]
assert {
"name": "extras",
"mountPath": "/usr/share/extras",
"readOnly": True,
} in extraVolumeMounts


def test_adding_a_extra_container():
config = """
extraContainers: |
Expand All @@ -323,6 +346,22 @@ def test_adding_a_extra_container():
} in extraContainer


def test_adding_a_extra_container_as_yaml():
config = """
extraContainers:
- name: do-something
image: busybox
command: ['do', 'something']
"""
r = helm_template(config)
extraContainer = r["statefulset"][uname]["spec"]["template"]["spec"]["containers"]
assert {
"name": "do-something",
"image": "busybox",
"command": ["do", "something"],
} in extraContainer


def test_adding_a_extra_init_container():
config = """
extraInitContainers: |
Expand All @@ -341,6 +380,24 @@ def test_adding_a_extra_init_container():
} in extraInitContainer


def test_adding_a_extra_init_container_as_yaml():
config = """
extraInitContainers:
- name: do-something
image: busybox
command: ['do', 'something']
"""
r = helm_template(config)
extraInitContainer = r["statefulset"][uname]["spec"]["template"]["spec"][
"initContainers"
]
assert {
"name": "do-something",
"image": "busybox",
"command": ["do", "something"],
} in extraInitContainer


def test_sysctl_init_container_disabled():
config = """
sysctlInitContainer:
Expand Down
8 changes: 4 additions & 4 deletions elasticsearch/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -112,21 +112,21 @@ persistence:
enabled: true
annotations: {}

extraVolumes: ""
extraVolumes: []
# - name: extras
# emptyDir: {}

extraVolumeMounts: ""
extraVolumeMounts: []
# - name: extras
# mountPath: /usr/share/extras
# readOnly: true

extraContainers: ""
extraContainers: []
# - name: do-something
# image: busybox
# command: ['do', 'something']

extraInitContainers: ""
extraInitContainers: []
# - name: do-something
# image: busybox
# command: ['do', 'something']
Expand Down