Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

Commit

Permalink
[FEATURE] add helmchart for deploying Kimai on Kubernetes (#198)
Browse files Browse the repository at this point in the history
* initial commit for Apache/MySQL/Prod

* add documentation, remove values which should not be accessible

* add paragraph about the Helm chart to the central README.md

* refactorings ftom code review

* changes from review
  • Loading branch information
stranljip authored Nov 19, 2020
1 parent e75f89e commit 24e27e0
Show file tree
Hide file tree
Showing 13 changed files with 399 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ This docker transient and will disappear when you stop the container.
## Documentation

[https://tobybatch.github.io/kimai2/](https://tobybatch.github.io/kimai2/)

## Kimai Helm chart

There is also a Helm chart for easy deployment of Kimai on Kubernetes. See the [README](docs/helm/README.md) for more information.
6 changes: 6 additions & 0 deletions docs/helm/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v2
name: kimai-helmchart
description: A Helm chart for Kubernetes
type: application
version: "0.1.0"
appVersion: "0.1.0"
42 changes: 42 additions & 0 deletions docs/helm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# kimai-helmchart

In order to allow an easy deployment on Kubernetes, we provide a Helm chart (https://helm.sh). The chart allows a parameterized deployment of Kimai on Kubernetes, using the Docker images also used for the standard docker deployment. This Helm chart only allows the deployment with Apache and MySQL.

# Chart Documentation

![Version: 0.1.0](https://img.shields.io/badge/Version-0.1.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.1.0](https://img.shields.io/badge/AppVersion-0.1.0-informational?style=flat-square)

A Helm chart for Kubernetes

## Values

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| default.storageClass | string | `nil` | Possibility to override the storage class. If left empty, your default storage class will be used |
| images.mysql.name | string | `"mysql"` | Image name for MySQL |
| images.mysql.tag | string | `"5.7"` | Image tag for MySQL |
| ingress.defaultDomain | string | `"local"` | Default domain for ingress definitions. Can be overridden by the component specific settings |
| ingress.kimai.domain | string | `nil` | Optional possibility to declare a specific domain for Kimai |
| ingress.kimai.hostName | string | `nil` | Host name for Kimai. Defaults to kimai |
| ingress.kimai.tlsSecret | string | `"add-you-own-here"` | Certificate for Kimai |
| kimai.database | object | `{"databaseName":"kimai","kimaiPassword":"kimai","kimaiUser":"kimai"}` | Configuration of the database for Kimai |
| kimai.database.databaseName | string | `"kimai"` | MySQL database name for Kimai |
| kimai.database.kimaiPassword | string | `"kimai"` | MySQL database password for Kimai |
| kimai.database.kimaiUser | string | `"kimai"` | MySQL database user for Kimai |
| kimai.initialization.admin.email | string | `"admin@kimai.local"` | Email for the superadmin account |
| kimai.initialization.admin.password | string | `"changemeplease"` | Password for the superadmin account |
| kimai.nameOverride | string | `nil` | Possibility to override the name of the Kimai component |
| kimai.pvc.var.size | string | `"4Gi"` | Size for the PVC var for Kimai |
| kimai.resources.limits.cpu | string | `"1000m"` | |
| kimai.resources.limits.memory | string | `"512Mi"` | |
| kimai.resources.requests.cpu | string | `"500m"` | |
| kimai.resources.requests.memory | string | `"256Mi"` | |
| kimai.version | string | `"master"` | Kimai version. This is used to determine which tag should be used for Kimai itself. If you change this, ensure, that the corresponding tag already exists at Docker Hub. The tag is formed following the pattern `apache-debian-<kimai.version>-prod`. |
| metadata.applicationName | string | `"kimai"` | Name for the whole application. Used at different places for labels and naming of components. |
| mysql.nameOverride | string | `nil` | Possibility to override the name of the Kimai components |
| mysql.pvc.data.size | string | `"4Gi"` | Size for the PVC data for MySQL |
| mysql.resources.limits.cpu | string | `"2000m"` | |
| mysql.resources.limits.memory | string | `"4096Mi"` | |
| mysql.resources.requests.cpu | string | `"1000m"` | |
| mysql.resources.requests.memory | string | `"512Mi"` | |
| mysql.rootPassword | string | `"changemeplease"` | Password for the MySQL root user |
21 changes: 21 additions & 0 deletions docs/helm/README.md.gotmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# kimai-helmchart

In order to allow an easy deployment on Kubernetes, we provide a Helm chart (https://helm.sh). The chart allows a parameterized deployment of Kimai on Kubernetes, using the Docker images also used for the standard docker deployment. This Helm chart only allows the deployment with Apache and MySQL.

# Chart Documentation

{{ template "chart.deprecationWarning" . }}

{{ template "chart.versionBadge" . }}{{ template "chart.typeBadge" . }}{{ template "chart.appVersionBadge" . }}

{{ template "chart.description" . }}

{{ template "chart.homepageLine" . }}

{{ template "chart.maintainersSection" . }}

{{ template "chart.sourcesSection" . }}

{{ template "chart.requirementsSection" . }}

{{ template "chart.valuesSection" . }}
36 changes: 36 additions & 0 deletions docs/helm/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{{/*
Expand the name of the Kimai component.
*/}}
{{- define "kimai.name" -}}
{{- default "kimai" .Values.kimai.nameOverride }}
{{- end }}

{{/*
Expand the name of the MySQL component.
*/}}
{{- define "mysql.name" -}}
{{- default "mysql" .Values.mysql.nameOverride }}
{{- end }}

{{/*
Create the database URL. For the time being, this supports only an integrated MySQL
*/}}
{{- define "application.databaseUrl" -}}
mysql://{{ .Values.kimai.database.kimaiUser }}:{{ .Values.kimai.database.kimaiPassword }}@additional-{{ include "mysql.name" . }}/{{ .Values.kimai.database.databaseName }}
{{- end }}

{{/*
Tag name for Kimai image
*/}}
{{- define "kimai.imageTag" -}}
apache-debian-{{ .Values.kimai.version }}-prod
{{- end }}


{{- define "kimai-helmchart.ingress.fqdn.kimai" -}}
{{- if .Values.ingress.kimai.domain -}}
{{ default "kimai" .Values.ingress.kimai.name }}.{{ .Values.ingress.kimai.domain }}
{{- else -}}
{{ default "kimai" .Values.ingress.kimai.name }}.{{ .Values.ingress.defaultDomain }}
{{- end -}}
{{- end }}
51 changes: 51 additions & 0 deletions docs/helm/templates/deploy-additional-mysql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: additional-{{ include "mysql.name" . }}
labels:
app.kubernetes.io/part-of: {{ .Values.metadata.applicationName }}
app.kubernetes.io/name: additional-{{ include "mysql.name" . }}
app.kubernetes.io/component: additional-{{ include "mysql.name" . }}
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/part-of: {{ .Values.metadata.applicationName }}
app.kubernetes.io/name: additional-{{ include "mysql.name" . }}
app.kubernetes.io/component: additional-{{ include "mysql.name" . }}
template:
metadata:
labels:
app.kubernetes.io/part-of: {{ .Values.metadata.applicationName }}
app.kubernetes.io/name: additional-{{ include "mysql.name" . }}
app.kubernetes.io/component: additional-{{ include "mysql.name" . }}
spec:
containers:
- env:
- name: MYSQL_DATABASE
value: {{ .Values.kimai.database.databaseName }}
- name: MYSQL_USER
value: {{ .Values.kimai.database.kimaiUser }}
- name: MYSQL_PASSWORD
value: {{ .Values.kimai.database.kimaiPassword }}
- name: MYSQL_ROOT_PASSWORD
value: {{ .Values.mysql.rootPassword }}{{ .Values.mysql.foo }}
image: {{ .Values.images.mysql.name }}:{{ .Values.images.mysql.tag }}
name: additional-{{ include "mysql.name" . }}
ports:
- containerPort: 3306
name: mysql
resources:
requests:
memory: {{ .Values.mysql.resources.requests.memory }}
cpu: {{ .Values.mysql.resources.requests.cpu }}
limits:
memory: {{ .Values.mysql.resources.limits.memory }}
cpu: {{ .Values.mysql.resources.limits.cpu }}
volumeMounts:
- mountPath: /var/lib/mysql
name: mysql-data
volumes:
- name: mysql-data
persistentVolumeClaim:
claimName: additional-{{ include "mysql.name" .}}-data
53 changes: 53 additions & 0 deletions docs/helm/templates/deploy-core-kimai.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: core-{{ include "kimai.name" . }}
labels:
app.kubernetes.io/part-of: {{ .Values.metadata.applicationName }}
app.kubernetes.io/name: core-{{ include "kimai.name" . }}
app.kubernetes.io/component: core-{{ include "kimai.name" . }}
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/part-of: {{ .Values.metadata.applicationName }}
app.kubernetes.io/name: core-{{ include "kimai.name" . }}
app.kubernetes.io/component: core-{{ include "kimai.name" . }}
template:
metadata:
labels:
app.kubernetes.io/part-of: {{ .Values.metadata.applicationName }}
app.kubernetes.io/name: core-{{ include "kimai.name" . }}
app.kubernetes.io/component: core-{{ include "kimai.name" . }}
spec:
containers:
- env:
- name: ADMINMAIL
value: {{ .Values.kimai.initialization.admin.email }}
- name: ADMINPASS
value: {{ .Values.kimai.initialization.admin.password }}
- name: APP_ENV
value: {{ .Values.kimai.environment }}
- name: DATABASE_URL
value: {{ include "application.databaseUrl" . }}
- name: TRUSTED_HOSTS
value: localhost,{{ include "kimai-helmchart.ingress.fqdn.kimai" . }}
image: kimai/kimai2:{{ include "kimai.imageTag" . }}
name: core-{{ include "kimai.name" . }}
ports:
- containerPort: 8001
name: kimai
resources:
requests:
memory: {{ .Values.kimai.resources.requests.memory }}
cpu: {{ .Values.kimai.resources.requests.cpu }}
limits:
memory: {{ .Values.kimai.resources.limits.memory }}
cpu: {{ .Values.kimai.resources.limits.cpu }}
volumeMounts:
- mountPath: /opt/kimai/var
name: kimai-var
volumes:
- name: kimai-var
persistentVolumeClaim:
claimName: core-{{ include "kimai.name" .}}-var
25 changes: 25 additions & 0 deletions docs/helm/templates/ing-core-kimai.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: core-{{ include "kimai.name" . }}
labels:
app.kubernetes.io/part-of: {{ .Values.metadata.applicationName }}
app.kubernetes.io/name: core-{{ include "kimai.name" . }}
spec:
{{ if .Values.ingress.kimai.tlsSecret }}
tls:
- hosts:
- {{ include "kimai-helmchart.ingress.fqdn.kimai" . }}
secretName: {{ .Values.ingress.kimai.tlsSecret }}
{{ end }}
rules:
- host: {{ include "kimai-helmchart.ingress.fqdn.kimai" . }}
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
service:
name: core-{{ include "kimai.name" . }}
port:
name: kimai-http
16 changes: 16 additions & 0 deletions docs/helm/templates/pvc-additional-mysql-data.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: additional-{{ include "mysql.name" .}}-data
labels:
app.kubernetes.io/part-of: {{ .Values.metadata.applicationName }}
app.kubernetes.io/name: additional-{{ include "mysql.name" .}}-data
spec:
accessModes:
- ReadWriteOnce
{{ if .Values.default.storageClass }}
storageClassName: {{ .Values.default.storageClass }}
{{ end }}
resources:
requests:
storage: {{ .Values.mysql.pvc.data.size }}
16 changes: 16 additions & 0 deletions docs/helm/templates/pvc-core-kimai-var.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: core-{{ include "kimai.name" .}}-var
labels:
app.kubernetes.io/part-of: {{ .Values.metadata.applicationName }}
app.kubernetes.io/name: core-{{ include "kimai.name" . }}-var
spec:
accessModes:
- ReadWriteOnce
{{ if .Values.default.storageClass }}
storageClassName: {{ .Values.default.storageClass }}
{{ end }}
resources:
requests:
storage: {{ .Values.kimai.pvc.var.size }}
19 changes: 19 additions & 0 deletions docs/helm/templates/svc-additional-mysql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: v1
kind: Service
metadata:
name: additional-{{ include "mysql.name" .}}
labels:
app.kubernetes.io/part-of: {{ .Values.metadata.applicationName }}
app.kubernetes.io/name: additional-{{ include "mysql.name" .}}
app.kubernetes.io/component: additional-{{ include "mysql.name" .}}
spec:
type: ClusterIP
ports:
- port: 3306
protocol: TCP
targetPort: mysql
name: mysql
selector:
app.kubernetes.io/part-of: {{ .Values.metadata.applicationName }}
app.kubernetes.io/name: additional-{{ include "mysql.name" .}}
app.kubernetes.io/component: additional-{{ include "mysql.name" .}}
19 changes: 19 additions & 0 deletions docs/helm/templates/svc-core-kimai.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: v1
kind: Service
metadata:
name: core-{{ include "kimai.name" .}}
labels:
app.kubernetes.io/part-of: {{ .Values.metadata.applicationName }}
app.kubernetes.io/name: core-{{ include "kimai.name" .}}
app.kubernetes.io/component: core-{{ include "kimai.name" .}}
spec:
type: ClusterIP
ports:
- port: 8001
protocol: TCP
targetPort: kimai-http
name: kimai-http
selector:
app.kubernetes.io/part-of: {{ .Values.metadata.applicationName }}
app.kubernetes.io/name: core-{{ include "kimai.name" .}}
app.kubernetes.io/component: core-{{ include "kimai.name" .}}
Loading

0 comments on commit 24e27e0

Please sign in to comment.