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

[elasticsearch] Make persistent volumes optional #114

Merged
merged 1 commit into from
May 1, 2019
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
[elasticsearch] Make persistent volumes optional
Certain node roles do not require any persistent data. Setting
`persistence.enabled: false` will allow nodes to be created without
persistent volumes.

Fixes: #58
Fixes: #110
  • Loading branch information
Crazybus committed May 1, 2019
commit 66d6db986352422e79e9ea76046dffc35812154a
1 change: 1 addition & 0 deletions elasticsearch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ helm install --name elasticsearch elastic/elasticsearch --version 7.0.0-alpha1 -
| `networkHost` | Value for the [network.host Elasticsearch setting](https://www.elastic.co/guide/en/elasticsearch/reference/current/network.host.html) | `0.0.0.0` |
| `volumeClaimTemplate` | Configuration for the [volumeClaimTemplate for statefulsets](https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#stable-storage). You will want to adjust the storage (default `30Gi`) and the `storageClassName` if you are using a different storage class | `accessModes: [ "ReadWriteOnce" ]`<br>`resources.requests.storage: 30Gi` |
| `persistence.annotations` | Additional persistence annotations for the `volumeClaimTemplate` | `{}` |
| `persistence.enabled` | Enables a persistent volume for Elasticsearch data. Can be disabled for nodes that only have [roles](https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-node.html) which don't require persistent data. | `true` |
| `antiAffinityTopologyKey` | The [anti-affinity topology key](https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity). By default this will prevent multiple Elasticsearch nodes from running on the same Kubernetes node | `kubernetes.io/hostname` |
| `antiAffinity` | Setting this to hard enforces the [anti-affinity rules](https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity). If it is set to soft it will be done "best effort". Other values will be ignored. | `hard` |
| `nodeAffinity` | Value for the [node affinity settings](https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#node-affinity-beta-feature) | `{}` |
Expand Down
3 changes: 3 additions & 0 deletions elasticsearch/examples/migration/client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ volumeClaimTemplate:
resources:
requests:
storage: 1Gi # Currently needed till pvcs are made optional

persistence:
enabled: false
4 changes: 4 additions & 0 deletions elasticsearch/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ spec:
podManagementPolicy: {{ .Values.podManagementPolicy }}
updateStrategy:
type: {{ .Values.updateStrategy }}
{{- if .Values.persistence.enabled }}
volumeClaimTemplates:
- metadata:
name: {{ template "uname" . }}
Expand All @@ -26,6 +27,7 @@ spec:
{{- end }}
spec:
{{ toYaml .Values.volumeClaimTemplate | indent 6 }}
{{- end }}
template:
metadata:
name: "{{ template "uname" . }}"
Expand Down Expand Up @@ -195,8 +197,10 @@ spec:
{{ toYaml .Values.extraEnvs | indent 10 }}
{{- end }}
volumeMounts:
{{- if .Values.persistence.enabled }}
- name: "{{ template "uname" . }}"
mountPath: /usr/share/elasticsearch/data
{{- end }}
{{- range .Values.secretMounts }}
- name: {{ .name }}
mountPath: {{ .path }}
Expand Down
9 changes: 9 additions & 0 deletions elasticsearch/tests/elasticsearch_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,3 +544,12 @@ def test_adding_in_es_config():
assert {'mountPath': '/usr/share/elasticsearch/config/log4j2.properties', 'name': 'esconfig', 'subPath': 'log4j2.properties'} in s['containers'][0]['volumeMounts']

assert 'configchecksum' in r['statefulset'][uname]['spec']['template']['metadata']['annotations']

def test_dont_add_data_volume_when_persistance_is_disabled():
config = '''
persistence:
enabled: false
'''
r = helm_template(config)
assert 'volumeClaimTemplates' not in r['statefulset'][uname]['spec']
assert r['statefulset'][uname]['spec']['template']['spec']['containers'][0]['volumeMounts'] == None
1 change: 1 addition & 0 deletions elasticsearch/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ volumeClaimTemplate:
storage: 30Gi

persistence:
enabled: true
annotations: {}

extraVolumes: []
Expand Down