diff --git a/README.md b/README.md index 6f97fea..4480f30 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/docs/helm/Chart.yaml b/docs/helm/Chart.yaml new file mode 100644 index 0000000..d39d6df --- /dev/null +++ b/docs/helm/Chart.yaml @@ -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" diff --git a/docs/helm/README.md b/docs/helm/README.md new file mode 100644 index 0000000..266e466 --- /dev/null +++ b/docs/helm/README.md @@ -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--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 | diff --git a/docs/helm/README.md.gotmpl b/docs/helm/README.md.gotmpl new file mode 100644 index 0000000..2a66d79 --- /dev/null +++ b/docs/helm/README.md.gotmpl @@ -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" . }} diff --git a/docs/helm/templates/_helpers.tpl b/docs/helm/templates/_helpers.tpl new file mode 100644 index 0000000..998ffa4 --- /dev/null +++ b/docs/helm/templates/_helpers.tpl @@ -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 }} diff --git a/docs/helm/templates/deploy-additional-mysql.yml b/docs/helm/templates/deploy-additional-mysql.yml new file mode 100644 index 0000000..75672cc --- /dev/null +++ b/docs/helm/templates/deploy-additional-mysql.yml @@ -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 diff --git a/docs/helm/templates/deploy-core-kimai.yml b/docs/helm/templates/deploy-core-kimai.yml new file mode 100644 index 0000000..8ad07c0 --- /dev/null +++ b/docs/helm/templates/deploy-core-kimai.yml @@ -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 diff --git a/docs/helm/templates/ing-core-kimai.yml b/docs/helm/templates/ing-core-kimai.yml new file mode 100644 index 0000000..791c358 --- /dev/null +++ b/docs/helm/templates/ing-core-kimai.yml @@ -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 diff --git a/docs/helm/templates/pvc-additional-mysql-data.yml b/docs/helm/templates/pvc-additional-mysql-data.yml new file mode 100644 index 0000000..f0c3bcd --- /dev/null +++ b/docs/helm/templates/pvc-additional-mysql-data.yml @@ -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 }} diff --git a/docs/helm/templates/pvc-core-kimai-var.yml b/docs/helm/templates/pvc-core-kimai-var.yml new file mode 100644 index 0000000..3c8cbcd --- /dev/null +++ b/docs/helm/templates/pvc-core-kimai-var.yml @@ -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 }} diff --git a/docs/helm/templates/svc-additional-mysql.yml b/docs/helm/templates/svc-additional-mysql.yml new file mode 100644 index 0000000..83a7e68 --- /dev/null +++ b/docs/helm/templates/svc-additional-mysql.yml @@ -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" .}} diff --git a/docs/helm/templates/svc-core-kimai.yml b/docs/helm/templates/svc-core-kimai.yml new file mode 100644 index 0000000..49f56f1 --- /dev/null +++ b/docs/helm/templates/svc-core-kimai.yml @@ -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" .}} diff --git a/docs/helm/values.yaml b/docs/helm/values.yaml new file mode 100644 index 0000000..9ce601a --- /dev/null +++ b/docs/helm/values.yaml @@ -0,0 +1,91 @@ +# Values for the Helm chart for Kimai + +# General metadata +metadata: + # -- Name for the whole application. Used at different places for labels and naming of + # components. + applicationName: kimai + +# Default values application wide +default: + # -- Possibility to override the storage class. If left empty, your default storage class will be used + storageClass: + +# Images used for the deployment of the application +images: + mysql: + # -- Image name for MySQL + name: mysql + # -- Image tag for MySQL + tag: "5.7" + +kimai: + # -- 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--prod`. + version: master + # -- Possibility to override the name of the Kimai component + nameOverride: + # -- Configuration of the database for Kimai + database: + # -- MySQL database name for Kimai + databaseName: kimai + # -- MySQL database user for Kimai + kimaiUser: kimai + # -- MySQL database password for Kimai + kimaiPassword: kimai + # Values for Kimai initialization + initialization: + # Superadmin account (`superadmin`) + admin: + # -- Email for the superadmin account + email: admin@kimai.local + # -- Password for the superadmin account + password: changemeplease + # PVC configuration + pvc: + # PVC var for Kimai + var: + # -- Size for the PVC var for Kimai + size: 4Gi + # Resources + resources: + requests: + memory: 256Mi + cpu: 500m + limits: + memory: 512Mi + cpu: 1000m + +mysql: + # -- Possibility to override the name of the Kimai components + nameOverride: + # -- Password for the MySQL root user + rootPassword: changemeplease + # PVC configuration + pvc: + # PVC data for MySQL + data: + # -- Size for the PVC data for MySQL + size: 4Gi + # Resources + resources: + requests: + memory: 512Mi + cpu: 1000m + limits: + memory: 4096Mi + cpu: 2000m + + +# Ingress definitions +ingress: + # -- Default domain for ingress definitions. Can be overridden by the component specific settings + defaultDomain: local + # Ingress definition for Kimai + kimai: + # -- Host name for Kimai. Defaults to kimai + hostName: + # -- Optional possibility to declare a specific domain for Kimai + domain: + # -- Certificate for Kimai + tlsSecret: add-you-own-here