Skip to content

Commit

Permalink
Merge pull request #105 from observIQ/chart/influxdb
Browse files Browse the repository at this point in the history
Chart: InfluxDB
  • Loading branch information
algchoo authored Nov 8, 2023
2 parents fc161de + dd4fe04 commit da5aba3
Show file tree
Hide file tree
Showing 15 changed files with 666 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ jobs:
- "aerospike"
- "apache-activemq"
- "presto"
- "influxdb"

runs-on: ubuntu-latest
steps:
Expand Down
21 changes: 21 additions & 0 deletions charts/influxdb/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*~
# Various IDEs
.project
.idea/
*.tmproj
6 changes: 6 additions & 0 deletions charts/influxdb/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v2
appVersion: 2.3.0
name: influxdb2
description: A customized InfluxDB v2 chart for development
type: application
version: 1.0.0
9 changes: 9 additions & 0 deletions charts/influxdb/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# InfluxDB v2 Helm chart

[InfluxDB](https://github.com/influxdata/influxdb) is an open source time series
database with no external dependencies. It's useful for recording metrics,
events, and performing analytics.

This is a copy of the v2 chart for InfluxDB that's slightly customized for development use.

Persistence is disabled. Password and token are set to fixed values.
17 changes: 17 additions & 0 deletions charts/influxdb/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
InfluxDB 2 is deployed as a StatefulSet on your cluster.

You can access it by using the service name: {{ template "influxdb.fullname" . }}

To retrieve the password for the '{{ .Values.adminUser.user}}' user:

{{- if .Values.adminUser.existingSecret }}

echo $(kubectl get secret {{ .Values.adminUser.existingSecret }} -o "jsonpath={.data['admin-password']}" --namespace {{ .Release.Namespace }} | base64 --decode)

{{- else }}

echo $(kubectl get secret {{ include "influxdb.fullname" . }}-auth -o "jsonpath={.data['admin-password']}" --namespace {{ .Release.Namespace }} | base64 --decode)

{{- end }}

Note: with enabled persistence, admin password is only set once during the initial deployment. The password is not changed when InfluxDB 2 is re-deployed with different password.
64 changes: 64 additions & 0 deletions charts/influxdb/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "influxdb.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "influxdb.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "influxdb.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Common labels
*/}}
{{- define "influxdb.labels" -}}
app.kubernetes.io/name: {{ include "influxdb.name" . }}
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 -}}

{{/*
Selector labels
*/}}
{{- define "influxdb.selectorLabels" -}}
app.kubernetes.io/name: {{ include "influxdb.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end -}}

{{/*
Create the name of the service account to use
*/}}
{{- define "influxdb.serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}}
{{ default (include "influxdb.fullname" .) .Values.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- end -}}
44 changes: 44 additions & 0 deletions charts/influxdb/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{{- if .Values.ingress.enabled -}}
{{- if .Capabilities.APIVersions.Has "networking.k8s.io/v1/Ingress" }}
apiVersion: networking.k8s.io/v1
{{- else }}
apiVersion: networking.k8s.io/v1beta1
{{- end }}
kind: Ingress
metadata:
name: {{ include "influxdb.fullname" . }}
labels:
{{- include "influxdb.labels" . | nindent 4 }}
annotations:
{{ toYaml .Values.ingress.annotations | indent 4 }}
spec:
{{- if .Values.ingress.tls }}
tls:
- hosts:
- {{ .Values.ingress.hostname | quote }}
{{- if .Values.ingress.secretName }}
secretName: {{ .Values.ingress.secretName }}
{{- end -}}
{{- end }}
{{- if .Values.ingress.className }}
ingressClassName: {{ .Values.ingress.className }}
{{- end }}
rules:
- host: {{ .Values.ingress.hostname }}
http:
paths:
- path: {{ .Values.ingress.path }}
{{- if .Capabilities.APIVersions.Has "networking.k8s.io/v1/Ingress" }}
pathType: Prefix
{{- end }}
backend:
{{- if .Capabilities.APIVersions.Has "networking.k8s.io/v1/Ingress" }}
service:
name: {{ include "influxdb.fullname" . }}
port:
name: {{ .Values.service.portName }}
{{- else }}
serviceName: {{ include "influxdb.fullname" . }}
servicePort: {{ .Values.service.portName }}
{{- end }}
{{- end -}}
10 changes: 10 additions & 0 deletions charts/influxdb/templates/init-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{{- 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 -}}
22 changes: 22 additions & 0 deletions charts/influxdb/templates/pdb.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{{- if .Values.pdb.create }}
{{- if .Capabilities.APIVersions.Has "policy/v1" }}
apiVersion: policy/v1
{{- else }}
apiVersion: policy/v1beta1
{{- end }}
kind: PodDisruptionBudget
metadata:
name: {{ template "influxdb.fullname" . }}
labels:
{{- include "influxdb.labels" . | nindent 4 }}
spec:
{{- if .Values.pdb.minAvailable }}
minAvailable: {{ .Values.pdb.minAvailable }}
{{- end }}
{{- if .Values.pdb.maxUnavailable }}
maxUnavailable: {{ .Values.pdb.maxUnavailable }}
{{- end }}
selector:
matchLabels:
{{- include "influxdb.selectorLabels" . | nindent 6 }}
{{- end }}
23 changes: 23 additions & 0 deletions charts/influxdb/templates/persistent-volume-claim.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{{- if and (.Values.persistence.enabled) (not .Values.persistence.useExisting) }}
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: "{{- if not (empty .Values.persistence.name) }}{{ .Values.persistence.name }}{{- else }}{{ template "influxdb.fullname" . }}{{- end }}"
labels:
{{- include "influxdb.labels" . | nindent 4 }}
annotations:
helm.sh/resource-policy: "keep"
spec:
accessModes:
- {{ .Values.persistence.accessMode | quote }}
resources:
requests:
storage: {{ .Values.persistence.size | quote }}
{{- if .Values.persistence.storageClass }}
{{- if (eq "-" .Values.persistence.storageClass) }}
storageClassName: ""
{{- else }}
storageClassName: "{{ .Values.persistence.storageClass }}"
{{- end }}
{{- end }}
{{- end }}
27 changes: 27 additions & 0 deletions charts/influxdb/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{{- if not (.Values.adminUser.existingSecret) -}}
apiVersion: v1
kind: Secret
metadata:
labels:
{{- include "influxdb.labels" . | nindent 4 }}
{{- $name := printf "%s-auth" (include "influxdb.fullname" .) }}
name: {{ $name }}
data:
{{- $previous := lookup "v1" "Secret" .Release.Namespace $name }}

{{- if $previous }}
admin-token: {{ index $previous.data "admin-token" }}
{{- else if .Values.adminUser.token }}
admin-token: {{ .Values.adminUser.token | b64enc | quote }}
{{- else }}
admin-token: {{ randAlphaNum 32 | b64enc | quote }}
{{- end }}

{{- if $previous }}
admin-password: {{ index $previous.data "admin-password" }}
{{- else if .Values.adminUser.password }}
admin-password: {{ .Values.adminUser.password | b64enc | quote }}
{{- else }}
admin-password: {{ randAlphaNum 32 | b64enc | quote }}
{{- end }}
{{- end -}}
40 changes: 40 additions & 0 deletions charts/influxdb/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
apiVersion: v1
kind: Service
metadata:
name: {{ template "influxdb.fullname" . }}
labels: {{- include "influxdb.labels" . | nindent 4 }}
{{- with .Values.service.annotations }}
annotations:
{{ toYaml . | indent 4 }}
{{- end }}
spec:
{{- if (or (eq .Values.service.type "ClusterIP") (empty .Values.service.type)) }}
type: ClusterIP
{{- if .Values.service.clusterIP }}
clusterIP: {{ .Values.service.clusterIP }}
{{end}}
{{- else if eq .Values.service.type "LoadBalancer" }}
type: {{ .Values.service.type }}
{{- if .Values.service.loadBalancerIP }}
loadBalancerIP: {{ .Values.service.loadBalancerIP }}
{{- end }}
{{- if .Values.service.loadBalancerSourceRanges }}
loadBalancerSourceRanges:
{{ toYaml .Values.service.loadBalancerSourceRanges | indent 4 }}
{{- end -}}
{{- else }}
type: {{ .Values.service.type }}
{{- end }}
ports:
- name: {{ .Values.service.portName }}
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 .Values.extraExposePorts }}
{{- tpl (toYaml .Values.extraExposePorts) . | indent 4 }}
{{- end }}
selector:
{{- include "influxdb.selectorLabels" . | nindent 4 }}
12 changes: 12 additions & 0 deletions charts/influxdb/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "influxdb.serviceAccountName" . }}
labels:
{{- include "influxdb.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end -}}
Loading

0 comments on commit da5aba3

Please sign in to comment.