Move script to configmap

Signed-off-by: Carlos Rodriguez Hernandez <crhernandez@bitnami.com>
This commit is contained in:
Carlos Rodriguez Hernandez
2019-11-21 11:48:26 +00:00
parent 1aa6127648
commit 991591dfbe
5 changed files with 72 additions and 64 deletions
@@ -0,0 +1,28 @@
{{- if .Values.sysctlImage.enabled }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "elasticsearch.fullname" . }}-initcontainer
labels: {{- include "elasticsearch.labels" . | nindent 4 }}
data:
sysctl.sh: |-
#!/bin/bash
set -o errexit
set -o pipefail
set -o nounset
if ! [ -x "$(command -v sysctl)" ]; then
echo 'sysctl not installed. Installing it...'
distro=$(awk -F= '/^ID=/{print $2}' /etc/os-release | tr -d '"')
case $distro in
ol | centos)
yum install -y procps
rm -rf /var/cache/yum;;
ubuntu | debian)
apt-get update -qq && apt-get install -y --no-install-recommends procps
rm -rf /var/lib/apt/lists /var/cache/apt/archives;;
esac
fi
sysctl -w vm.max_map_count=262144 && sysctl -w fs.file-max=65536
{{- end }}
@@ -38,24 +38,13 @@ spec:
image: {{ include "elasticsearch.sysctl.image" . }}
imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
command:
- /bin/bash
- -ec
- |
if ! [ -x "$(command -v sysctl)" ]; then
echo 'sysctl not installed. Installing it...'
distro=$(awk -F= '/^ID=/{print $2}' /etc/os-release | tr -d '"')
case $distro in
ol | centos)
yum install -y procps
rm -rf /var/cache/yum;;
ubuntu | debian)
apt-get update -qq && apt-get install -y --no-install-recommends procps
rm -rf /var/lib/apt/lists /var/cache/apt/archives;;
esac
fi
sysctl -w vm.max_map_count=262144 && sysctl -w fs.file-max=65536
- /scripts/sysctl.sh
securityContext:
privileged: true
volumeMounts:
- name: initcontainer-script
mountPath: /scripts/sysctl.sh
subPath: sysctl.sh
{{- end }}
containers:
- name: elasticsearch
@@ -124,6 +113,12 @@ spec:
{{- toYaml .Values.extraVolumeMounts | nindent 12 }}
{{- end }}
volumes:
{{- if .Values.sysctlImage.enabled }}
- name: initcontainer-script
configMap:
name: {{ include "elasticsearch.fullname" . }}-initcontainer
defaultMode: 0755
{{- end }}
{{- if .Values.config }}
- name: config
configMap:
@@ -48,24 +48,13 @@ spec:
image: {{ include "elasticsearch.sysctl.image" . }}
imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
command:
- /bin/bash
- -ec
- |
if ! [ -x "$(command -v sysctl)" ]; then
echo 'sysctl not installed. Installing it...'
distro=$(awk -F= '/^ID=/{print $2}' /etc/os-release | tr -d '"')
case $distro in
ol | centos)
yum install -y procps
rm -rf /var/cache/yum;;
ubuntu | debian)
apt-get update -qq && apt-get install -y --no-install-recommends procps
rm -rf /var/lib/apt/lists /var/cache/apt/archives;;
esac
fi
sysctl -w vm.max_map_count=262144 && sysctl -w fs.file-max=65536
- /scripts/sysctl.sh
securityContext:
privileged: true
volumeMounts:
- name: initcontainer-script
mountPath: /scripts/sysctl.sh
subPath: sysctl.sh
{{- end }}
{{- if and .Values.volumePermissions.enabled .Values.data.persistence.enabled }}
- name: volume-permissions
@@ -151,6 +140,12 @@ spec:
{{- toYaml .Values.extraVolumeMounts | nindent 12 }}
{{- end }}
volumes:
{{- if .Values.sysctlImage.enabled }}
- name: initcontainer-script
configMap:
name: {{ include "elasticsearch.fullname" . }}-initcontainer
defaultMode: 0755
{{- end }}
{{- if .Values.config }}
- name: "config"
configMap:
@@ -39,24 +39,13 @@ spec:
image: {{ include "elasticsearch.sysctl.image" . }}
imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
command:
- /bin/bash
- -ec
- |
if ! [ -x "$(command -v sysctl)" ]; then
echo 'sysctl not installed. Installing it...'
distro=$(awk -F= '/^ID=/{print $2}' /etc/os-release | tr -d '"')
case $distro in
ol | centos)
yum install -y procps
rm -rf /var/cache/yum;;
ubuntu | debian)
apt-get update -qq && apt-get install -y --no-install-recommends procps
rm -rf /var/lib/apt/lists /var/cache/apt/archives;;
esac
fi
sysctl -w vm.max_map_count=262144 && sysctl -w fs.file-max=65536
- /scripts/sysctl.sh
securityContext:
privileged: true
volumeMounts:
- name: initcontainer-script
mountPath: /scripts/sysctl.sh
subPath: sysctl.sh
{{- end }}
containers:
- name: elasticsearch
@@ -125,6 +114,12 @@ spec:
{{- toYaml .Values.extraVolumeMounts | nindent 12 }}
{{- end }}
volumes:
{{- if .Values.sysctlImage.enabled }}
- name: initcontainer-script
configMap:
name: {{ include "elasticsearch.fullname" . }}-initcontainer
defaultMode: 0755
{{- end }}
{{- if .Values.config }}
- name: config
configMap:
@@ -40,24 +40,13 @@ spec:
image: {{ include "elasticsearch.sysctl.image" . }}
imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
command:
- /bin/bash
- -ec
- |
if ! [ -x "$(command -v sysctl)" ]; then
echo 'sysctl not installed. Installing it...'
distro=$(awk -F= '/^ID=/{print $2}' /etc/os-release | tr -d '"')
case $distro in
ol | centos)
yum install -y procps
rm -rf /var/cache/yum;;
ubuntu | debian)
apt-get update -qq && apt-get install -y --no-install-recommends procps
rm -rf /var/lib/apt/lists /var/cache/apt/archives;;
esac
fi
sysctl -w vm.max_map_count=262144 && sysctl -w fs.file-max=65536
- /scripts/sysctl.sh
securityContext:
privileged: true
volumeMounts:
- name: initcontainer-script
mountPath: /scripts/sysctl.sh
subPath: sysctl.sh
{{- end }}
{{- if and .Values.volumePermissions.enabled .Values.master.persistence.enabled }}
- name: volume-permissions
@@ -149,6 +138,12 @@ spec:
{{- toYaml .Values.extraVolumeMounts | nindent 12 }}
{{- end }}
volumes:
{{- if .Values.sysctlImage.enabled }}
- name: initcontainer-script
configMap:
name: {{ include "elasticsearch.fullname" . }}-initcontainer
defaultMode: 0755
{{- end }}
{{- if .Values.config }}
- name: config
configMap: