Unverified Commit 838956b0 authored by alespour's avatar alespour Committed by GitHub

[influxdb2] add init scripts support (#456)

* add init scripts support * add test values files * prettify templates output * bump version Co-authored-by: 's avatarPavel Závora <pavel.zavora@bonitoo.io> * update script execution info in comment Co-authored-by: 's avatarPavel Závora <pavel.zavora@bonitoo.io> * fix trailing spaces * fix default init script to run non-interactively
parent bae0041c
......@@ -4,7 +4,7 @@ name: influxdb2
description: A Helm chart for InfluxDB v2
home: https://www.influxdata.com/products/influxdb/
type: application
version: 2.0.12
version: 2.1.0
maintainers:
- name: rawkode
email: rawkode@influxdata.com
......
# Default values only, no overrides
initScripts:
enabled: true
persistence:
enabled: false
......@@ -36,12 +36,12 @@ Common labels
*/}}
{{- define "influxdb.labels" -}}
app.kubernetes.io/name: {{ include "influxdb.name" . }}
helm.sh/chart: {{ include "influxdb.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
helm.sh/chart: {{ include "influxdb.chart" . }}
{{- end -}}
{{/*
......
{{- if .Values.initScripts.enabled -}}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "influxdb.fullname" . }}-init
labels:
{{- include "influxdb.labels" . | nindent 4 }}
data:
{{ toYaml .Values.initScripts.scripts | indent 2 }}
{{- end -}}
......@@ -30,10 +30,11 @@ spec:
port: {{ .Values.service.port }}
protocol: TCP
targetPort: {{ .Values.service.targetPort }}
{{ if (and (eq .Values.service.type "NodePort") (not (empty .Values.service.nodePort))) }}
nodePort: {{.Values.service.nodePort}}
{{ end }}
{{- if (and (eq .Values.service.type "NodePort") (not (empty .Values.service.nodePort))) }}
nodePort: {{ .Values.service.nodePort }}
{{- end }}
{{- if .Values.extraExposePorts }}
{{- tpl (toYaml .Values.extraExposePorts) . | indent 4 }}
{{- end }}
selector: {{- include "influxdb.selectorLabels" . | nindent 4 }}
selector:
{{- include "influxdb.selectorLabels" . | nindent 4 }}
......@@ -3,7 +3,7 @@ kind: StatefulSet
metadata:
name: {{ template "influxdb.fullname" . }}
labels:
{{ include "influxdb.labels" . | nindent 4 }}
{{- include "influxdb.labels" . | nindent 4 }}
spec:
replicas: 1
selector:
......@@ -14,8 +14,13 @@ spec:
metadata:
labels:
{{- include "influxdb.selectorLabels" . | nindent 8 }}
{{- if .Values.podLabels }}
{{ toYaml .Values.podLabels | indent 8 }}
{{- end }}
{{- if .Values.podAnnotations }}
annotations:
{{- toYaml .Values.podAnnotations | nindent 8 }}
{{ toYaml .Values.podAnnotations | indent 8 }}
{{- end }}
spec:
volumes:
- name: data
......@@ -30,6 +35,15 @@ spec:
{{- else }}
emptyDir: {}
{{- end }}
{{- if .Values.initScripts.enabled }}
- name: init
configMap:
name: {{ include "influxdb.fullname" . }}-init
defaultMode: 0744
{{- end }}
{{- if .Values.volumes }}
{{- toYaml .Values.volumes | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "influxdb.serviceAccountName" . }}
containers:
- name: {{ .Chart.Name }}
......@@ -76,22 +90,19 @@ spec:
name: {{ template "influxdb.fullname" . }}-auth
{{- end }}
key: admin-token
# Path to the BoltDB database.
- name: INFLUXD_BOLT_PATH
value: {{ .Values.persistence.mountPath }}/influxd.bolt
# Path to persistent storage engine files where InfluxDB stores all Time-Structure Merge Tree (TSM) data on disk.
- name: INFLUXD_ENGINE_PATH
value: {{ .Values.persistence.mountPath }}
# Extra environment variables from .Values.env
{{- with .Values.env }}
# Extra environment variables from .Values.env
{{- toYaml . | nindent 12 }}
{{- end }}
{{- if .Values.securityContext }}
securityContext:
{{ toYaml .Values.securityContext | nindent 12 }}
{{- toYaml .Values.securityContext | nindent 12 }}
{{- end }}
livenessProbe:
httpGet:
......@@ -127,6 +138,13 @@ spec:
- name: data
mountPath: {{ .Values.persistence.mountPath }}
subPath: {{ .Values.persistence.subPath }}
{{- if .Values.initScripts.enabled }}
- name: init
mountPath: /docker-entrypoint-initdb.d
{{- end }}
{{- if .Values.mountPoints }}
{{- toYaml .Values.mountPoints | nindent 10 }}
{{- end }}
resources:
{{ .Values.resources | toYaml | nindent 12 | trim }}
......
......@@ -3,8 +3,14 @@ image:
tag: 2.2.0-alpine
pullPolicy: IfNotPresent
## Annotations to be added to InfluxDB pods
##
podAnnotations: {}
## Labels to be added to InfluxDB pods
##
podLabels: {}
nameOverride: ""
fullnameOverride: ""
......@@ -120,6 +126,30 @@ persistence:
mountPath: /var/lib/influxdb2
subPath: ""
## Add custom volume and volumeMounts
##
# volumes:
# - name: influxdb2-templates
# hostPath:
# path: /data/influxdb2-templates
# type: Directory
# mountPoints:
# - name: influxdb2-templates
# mountPath: /influxdb2-templates
# readOnly: true
## Allow executing custom init scripts
## If the container finds any files with the .sh extension inside of the
## /docker-entrypoint-initdb.d folder, it will execute them.
## When multiple scripts are present, they will be executed in lexical sort order by name.
## For more details see Custom Initialization Scripts in https://hub.docker.com/_/influxdb
initScripts:
enabled: false
scripts:
init.sh: |+
#!/bin/bash
influx apply --force yes -u https://raw.githubusercontent.com/influxdata/community-templates/master/influxdb2_operational_monitoring/influxdb2_operational_monitoring.yml
## Specify a service type
## ref: http://kubernetes.io/docs/user-guide/services/
##
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment