Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add InfluxDB2 Chart #35

Merged
merged 1 commit into from
Mar 19, 2020
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
21 changes: 21 additions & 0 deletions charts/influxdb2/.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
7 changes: 7 additions & 0 deletions charts/influxdb2/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v2
appVersion: 2.0.0-beta

name: influxdb
description: A Helm chart for InfluxDB v2
type: application
version: 1.0.0
56 changes: 56 additions & 0 deletions charts/influxdb2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# InfluxDB

**Warning**: This chart, as well as the software it deploys, is in a BETA phase.

If you're considering deploying this, please also consider using our [Slack channel](https://www.influxdata.com/slack) to get support when needed.

## An Open-Source Time Series Database

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

## QuickStart

```bash
helm repo add influxdata https://helm.influxdata.com/
helm upgrade --install influxdb influxdata/influxdb2 --namespace monitoring
```

> **Tip**: `helm upgrade --install [RELEASE] [CHART] [FLAGS]` can be shortened : `helm upgrade -i [RELEASE] [CHART] [FLAGS]`

## Introduction

This chart bootstraps an InfluxDB v2 statefulset and service on a Kubernetes cluster using the Helm Package manager.

## Prerequisites

- Kubernetes 1.4+
- PV provisioner support in the underlying infrastructure (optional)

## Installing the Chart

To install the chart with the release name `my-release`:

```bash
helm upgrade --install my-release influxdata/influxdb2
```

The command deploys InfluxDB on the Kubernetes cluster in the default configuration. The [configuration](#configuration) section lists the parameters that can be configured during installation.

> **Tip**: List all releases using `helm list`

## Uninstalling the Chart

To uninstall/delete the `my-release` deployment:

```bash
helm uninstall my-release
```

The command removes all the Kubernetes components associated with the chart and deletes the release.


## Persistence

The [InfluxDB](https://quay.io/influxdb/influxdb:2.0.0-beta) image stores data in the `/root/.influxdbv2` directory in the container.

If persistence is enabled, a [Persistent Volume](http://kubernetes.io/docs/user-guide/persistent-volumes/) associated with Statefulset will be provisioned. The volume is created using dynamic volume provisioning. In case of a disruption e.g. a node drain, kubernetes ensures that the same volume will be reatached to the Pod, preventing any data loss. Althought, when persistence is not enabled, InfluxDB data will be stored in an empty directory thus, in a Pod restart, data will be lost.
5 changes: 5 additions & 0 deletions charts/influxdb2/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
InfluxDB 2 is deployed as a StatefulSet on your cluster.

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

Admin password and token are available in the secret: {{ template "influxdb.fullname" . }}-auth
53 changes: 53 additions & 0 deletions charts/influxdb2/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{{/* 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" . }}
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 }}
{{- end -}}

{{/*
Selector labels
*/}}
{{- define "influxdb.selectorLabels" -}}
app.kubernetes.io/name: {{ include "influxdb.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end -}}
44 changes: 44 additions & 0 deletions charts/influxdb2/templates/job-setup-admin.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
apiVersion: batch/v1
kind: Job
metadata:
labels:
{{- include "influxdb.labels" . | nindent 4 }}
name: {{ template "influxdb.fullname" . }}-create-admin-user
annotations:
"helm.sh/hook": post-install
"helm.sh/hook-delete-policy": hook-succeeded
"helm.sh/hook-delete-policy": "before-hook-creation"
spec:
activeDeadlineSeconds: 90
template:
metadata:
labels:
{{- include "influxdb.labels" . | nindent 8 }}
spec:
containers:
- name: {{ template "influxdb.fullname" . }}-create-admin-user
image: "{{ .Values.image.repository }}:{{ .Chart.AppVersion }}"
env:
- name: INFLUXDB_PASSWORD
valueFrom:
secretKeyRef:
name: {{ template "influxdb.fullname" . }}-auth
key: admin-password
- name: INFLUXDB_TOKEN
valueFrom:
secretKeyRef:
name: {{ template "influxdb.fullname" . }}-auth
key: admin-token
command:
- bash
args:
- -c
- |
influx setup -f \
--host http://{{ template "influxdb.fullname" . }} \
-o {{ .Values.adminUser.organization }} \
-b {{ .Values.adminUser.bucket }} \
-u {{ .Values.adminUser.user }} \
-p ${INFLUXDB_PASSWORD} \
-t ${INFLUXDB_TOKEN}
restartPolicy: OnFailure
21 changes: 21 additions & 0 deletions charts/influxdb2/templates/persistent-volume-claim.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{{- 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 }}
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 }}
9 changes: 9 additions & 0 deletions charts/influxdb2/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v1
kind: Secret
metadata:
labels:
{{- include "influxdb.labels" . | nindent 4 }}
name: {{ template "influxdb.fullname" . }}-auth
data:
admin-password: {{ randAlphaNum 32 | b64enc | quote }}
admin-token: {{ randAlphaNum 32 | b64enc | quote }}
16 changes: 16 additions & 0 deletions charts/influxdb2/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: v1
kind: Service
metadata:
name: {{ template "influxdb.fullname" . }}
labels:
{{- include "influxdb.labels" . | nindent 4 }}
app.kubernetes.io/component: backup
spec:
type: ClusterIP
ports:
- port: 80
targetPort: 9999
protocol: TCP
name: http
selector:
{{- include "influxdb.selectorLabels" . | nindent 4 }}
66 changes: 66 additions & 0 deletions charts/influxdb2/templates/statefulset.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ template "influxdb.fullname" . }}
labels:
{{ include "influxdb.labels" . | nindent 4 }}
spec:
replicas: 1
selector:
matchLabels:
{{- include "influxdb.selectorLabels" . | nindent 6 }}
serviceName: "{{ include "influxdb.fullname" . }}"
template:
metadata:
labels:
{{- include "influxdb.selectorLabels" . | nindent 8 }}
spec:
volumes:
- name: data
{{- if .Values.persistence.enabled }}
{{- if not (empty .Values.persistence.name) }}
persistentVolumeClaim:
claimName: {{ .Values.persistence.name }}
{{- else }}
persistentVolumeClaim:
claimName: {{ template "influxdb.fullname" . }}
{{- end }}
{{- else }}
emptyDir: {}
{{- end }}
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: 9999
protocol: TCP
livenessProbe:
httpGet:
path: /health
port: http
readinessProbe:
httpGet:
path: /health
port: http
volumeMounts:
- name: data
mountPath: /root/.influxdbv2
resources:
{{ toYaml .Values.resources | indent 12 }}

{{- with .Values.nodeSelector }}
nodeSelector:
{{ toYaml . | indent 8 }}
{{- end }}

{{- with .Values.affinity }}
affinity:
{{ toYaml . | indent 8 }}
{{- end }}

{{- with .Values.tolerations }}
tolerations:
{{ toYaml . | indent 8 }}
{{- end }}
51 changes: 51 additions & 0 deletions charts/influxdb2/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
image:
repository: quay.io/influxdb/influxdb
pullPolicy: IfNotPresent

nameOverride: ""
fullnameOverride: ""

resources: {}
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi

nodeSelector: {}

tolerations: []

affinity: {}

## Create default user through Kubernetes job
## Defaults indicated below
##
adminUser:
organization: "influxdata"
bucket: "default"
user: "admin"

## Persist data to a persistent volume
##
persistence:
enabled: true
## If true will use an existing PVC instead of creating one
# useExisting: false
## Name of existing PVC to be used in the influx deployment
# name:
## influxdb data Persistent Volume Storage Class
## If defined, storageClassName: <storageClass>
## If set to "-", storageClassName: "", which disables dynamic provisioning
## If undefined (the default) or set to null, no storageClassName spec is
## set, choosing the default provisioner. (gp2 on AWS, standard on
## GKE, AWS & OpenStack)
##
# storageClass: "-"
accessMode: ReadWriteOnce
size: 50Gi