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

Conditional init container, default to disabled #132

Closed
wants to merge 3 commits into from
Closed
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
2 changes: 2 additions & 0 deletions elasticsearch/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ spec:
imagePullSecrets:
{{ toYaml .Values.imagePullSecrets | indent 8 }}
{{- end }}
{{- if .Values.sysctlInitContainer.enabled }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will need to go after the initContainers: block otherwise this will break extraInitContainers. There is a template test that catches this use case too which is failing:

________________________________ test_adding_a_extra_init_container _________________________________

    def test_adding_a_extra_init_container():
        config = '''
    extraInitContainers: |
      - name: do-something
        image: busybox
        command: ['do', 'something']
    '''
        r = helm_template(config)
>       extraInitContainer = r['statefulset'][uname]['spec']['template']['spec']['initContainers']
E       KeyError: 'initContainers'

initContainers:
- name: configure-sysctl
securityContext:
Expand All @@ -116,6 +117,7 @@ spec:
{{- if .Values.extraInitContainers }}
{{ tpl .Values.extraInitContainers . | indent 6 }}
{{- end }}
{{- end }}
containers:
- name: "{{ template "name" . }}"
image: "{{ .Values.image }}:{{ .Values.imageTag }}"
Expand Down
4 changes: 4 additions & 0 deletions elasticsearch/tests/elasticsearch_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ def test_defaults():
'name': 'node.ingest',
'value': 'true'
},
{
'name': 'sysctlInitContainer.enabled',
'value': 'true'
},
]

c = r['statefulset'][uname]['spec']['template']['spec']['containers'][0]
Expand Down
3 changes: 3 additions & 0 deletions elasticsearch/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,6 @@ ingress:

nameOverride: ""
fullnameOverride: ""

sysctlInitContainer:
enabled: false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean to put false here? The default value that you added to the test is true so the template tests are going to fail.