Introduces the teslamate chart (#106)

* Introduces the teslamate chart

Fixes #101

Signed-off-by: Jeff Billimek <jeff@billimek.com>

* get on the startupprobe bandwagon
This commit is contained in:
Jeff Billimek 2019-12-22 00:19:10 -05:00 committed by GitHub
parent 190225e7af
commit b332249e9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 481 additions and 0 deletions

24
teslamate/.helmignore Normal file
View File

@ -0,0 +1,24 @@
# 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
.vscode/
# OWNERS file for Kubernetes
OWNERS

15
teslamate/Chart.yaml Normal file
View File

@ -0,0 +1,15 @@
apiVersion: v1
appVersion: "v1.13.2"
description: A self-hosted data logger for your Tesla 🚘
name: teslamate
version: 1.0.0
keywords:
- teslamate
- tesla
home: https://github.com/billimek/billimek-charts/tree/master/teslamate
icon: https://upload.wikimedia.org/wikipedia/commons/thumb/b/bd/Tesla_Motors.svg/793px-Tesla_Motors.svg.png
sources:
- https://github.com/adriankumpf/teslamate
maintainers:
- name: billimek
email: jeff@billimek.com

4
teslamate/OWNERS Normal file
View File

@ -0,0 +1,4 @@
approvers:
- billimek
reviewers:
- billimek

48
teslamate/README.md Normal file
View File

@ -0,0 +1,48 @@
# A self-hosted data logger for your Tesla 🚘
This is an opinionated helm chart for [Teslamate](https://github.com/adriankumpf/teslamate) installed with a standalone postgresql database.
The default values and container images used in this chart will allow for running in a multi-arch cluster (amd64, arm, arm64)
## TL;DR;
```shell
$ helm repo add billimek https://billimek.com/billimek-charts/
$ helm install billimek/teslamate
```
## Installing the Chart
To install the chart with the release name `my-release`:
```console
helm install --name teslamate billimek/teslamate
```
## Uninstalling the Chart
To uninstall/delete the `teslamate` deployment:
```console
helm delete teslamate --purge
```
The command removes all the Kubernetes components associated with the chart and deletes the release.
## Configuration
Read through the [values.yaml](https://github.com/billimek/billimek-charts/blob/master/teslamate/values.yaml) file. It has several commented out suggested values.
Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example,
```console
helm install --name teslamate \
--set timeZone="America/New York" \
billimek/teslamate
```
Alternatively, a YAML file that specifies the values for the above parameters can be provided while installing the chart. For example,
```console
helm install --name teslamate -f values.yaml stable/teslamate
```

View File

@ -0,0 +1,6 @@
dependencies:
- name: postgresql
repository: https://kubernetes-charts.storage.googleapis.com/
version: 8.1.0
digest: sha256:45a6e2b72556d60b954a11ef8de75a48678c6117c2e78a33619b277c3d893fd0
generated: 2019-12-22T03:34:50.317972Z

View File

@ -0,0 +1,5 @@
dependencies:
- name: postgresql
version: 8.1.0
repository: https://kubernetes-charts.storage.googleapis.com/
condition: postgresql.enabled

View File

@ -0,0 +1,21 @@
1. Get the application URL by running these commands:
{{- if .Values.ingress.enabled }}
{{- range $host := .Values.ingress.hosts }}
{{- range $.Values.ingress.paths }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host }}{{ . }}
{{- end }}
{{- end }}
{{- else if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "teslamate.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get svc -w {{ include "teslamate.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "teslamate.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
echo http://$SERVICE_IP:{{ .Values.service.port }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "teslamate.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl port-forward $POD_NAME 8080:80
{{- end }}

View File

@ -0,0 +1,41 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "teslamate.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 "teslamate.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 a default fully qualified postgresql name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "teslamate.postgresql.fullname" -}}
{{- $name := default "postgresql" .Values.postgresql.nameOverride -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "teslamate.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

View File

@ -0,0 +1,108 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "teslamate.fullname" . }}
labels:
app.kubernetes.io/name: {{ include "teslamate.name" . }}
helm.sh/chart: {{ include "teslamate.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app.kubernetes.io/name: {{ include "teslamate.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
template:
metadata:
labels:
app.kubernetes.io/name: {{ include "teslamate.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
spec:
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
{{- if .Values.postgresql.postgresqlUsername }}
- name: DATABASE_USER
value: {{ .Values.postgresql.postgresqlUsername | quote }}
{{- end }}
{{- if .Values.postgresql.postgresqlPassword }}
- name: DATABASE_PASS
value: {{ .Values.postgresql.postgresqlPassword | quote }}
{{- end }}
{{- if .Values.postgresql.postgresqlDatabase }}
- name: DATABASE_NAME
value: {{ .Values.postgresql.postgresqlDatabase | quote }}
{{- end }}
- name: DATABASE_HOST
value: {{ template "teslamate.postgresql.fullname" . }}
{{- if .Values.mqtt.enabled }}
- name: MQTT_HOST
value: {{ .Values.mqtt.host | quote }}
- name: MQTT_USERNAME
value: {{ .Values.mqtt.username | quote }}
- name: MQTT_PASSWORD
value: {{ .Values.mqtt.password | quote }}
- name: MQTT_TLS
value: {{ .Values.mqtt.tls | quote }}
- name: MQTT_TLS_ACCEPT_INVALID_CERTS
value: {{ .Values.mqtt.tlsAcceptInvalid | quote }}
{{- else }}
- name: DISABLE_MQTT
value: "true"
{{- end }}
{{- if .Values.timeZone }}
- name: TZ
value: {{ .Values.timeZone | quote }}
{{- end }}
{{- if .Values.checkOrigin }}
- name: CHECK_ORIGIN
value: {{ .Values.checkOrigin | quote }}
{{- end }}
{{- if .Values.virtualHost }}
- name: VIRTUAL_HOST
value: {{ .Values.virtualHost | quote }}
{{- end }}
{{- if .Values.locale }}
- name: LOCALE
value: {{ .Values.locale | quote }}
{{- end }}
ports:
- name: http
containerPort: 4000
protocol: TCP
livenessProbe:
httpGet:
path: /
port: http
failureThreshold: {{ .Values.probes.liveness.failureThreshold }}
periodSeconds: {{ .Values.probes.liveness.periodSeconds }}
readinessProbe:
httpGet:
path: /
port: http
failureThreshold: {{ .Values.probes.readiness.failureThreshold }}
periodSeconds: {{ .Values.probes.readiness.periodSeconds }}
startupProbe:
httpGet:
path: /
port: http
initialDelaySeconds: {{ .Values.probes.startup.initialDelaySeconds }}
failureThreshold: {{ .Values.probes.startup.failureThreshold }}
periodSeconds: {{ .Values.probes.startup.periodSeconds }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}

View File

@ -0,0 +1,38 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "teslamate.fullname" . -}}
{{- $ingressPath := .Values.ingress.path -}}
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: {{ $fullName }}
labels:
app.kubernetes.io/name: {{ include "teslamate.name" . }}
helm.sh/chart: {{ include "teslamate.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
- host: {{ . | quote }}
http:
paths:
- path: {{ $ingressPath }}
backend:
serviceName: {{ $fullName }}
servicePort: http
{{- end }}
{{- end }}

View File

@ -0,0 +1,19 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "teslamate.fullname" . }}
labels:
app.kubernetes.io/name: {{ include "teslamate.name" . }}
helm.sh/chart: {{ include "teslamate.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
app.kubernetes.io/name: {{ include "teslamate.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}

View File

@ -0,0 +1,18 @@
apiVersion: v1
kind: Pod
metadata:
name: "{{ include "teslamate.fullname" . }}-test-connection"
labels:
app.kubernetes.io/name: {{ include "teslamate.name" . }}
helm.sh/chart: {{ include "teslamate.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
annotations:
"helm.sh/hook": test-success
spec:
containers:
- name: wget
image: busybox
command: ['wget']
args: ['{{ include "teslamate.fullname" . }}:{{ .Values.service.port }}']
restartPolicy: Never

134
teslamate/values.yaml Normal file
View File

@ -0,0 +1,134 @@
replicaCount: 1
image:
repository: teslamate/teslamate
tag: 1.13.2
pullPolicy: IfNotPresent
nameOverride: ""
fullnameOverride: ""
timeZone: UTC
mqtt:
enabled: false
# mqtt broker hostname - REQUIRED if mqtt is enabled
host:
username:
password:
# Enables TLS if true
tls:
# Accepts invalid certificates if true
tlsAcceptInvalid:
# Configures whether to check the origin header or not.
checkOrigin: false
# Host part used for generating URLs throughout the app
virtualHost:
# valid values are 'en' or 'de'
locale: en
# Probes configuration
probes:
liveness:
failureThreshold: 5
periodSeconds: 10
readiness:
failureThreshold: 5
periodSeconds: 10
startup:
initialDelaySeconds: 5
failureThreshold: 30
periodSeconds: 10
service:
type: ClusterIP
port: 4000
ingress:
enabled: false
annotations: {}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
path: /
hosts:
- chart-example.local
tls: []
# - secretName: chart-example-tls
# hosts:
# - chart-example.local
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: {}
## Configuration values for the postgresql dependency.
## Ref: https://github.com/helm/charts/blob/master/stable/postgresql/README.md
postgresql:
image:
repository: postgres
tag: 12.1
postgresqlDataDir: "/data/pgdata"
### PostgreSQL User to create.
##
postgresqlUsername: teslamate
## PostgreSQL Password for the new user.
## If not set, a random 10 characters password will be used.
##
postgresqlPassword: teslamate
## PostgreSQL Database to create.
##
postgresqlDatabase: teslamate
## Persistent Volume Storage configuration for PostgreSQL.
##
## Ref: https://kubernetes.io/docs/user-guide/persistent-volumes
##
persistence:
## Enable PostgreSQL persistence using Persistent Volume Claims.
##
enabled: true
## Persistent Volume Storage Class to be used by PersistentVolumes created
## for PostgreSQL.
##
## 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:
## Persistent Volume Access Mode.
##
accessModes:
- ReadWriteOnce
## Persistent Volume Storage Size.
##
size: 8Gi
mountPath: "/data/"