From 2ba100402457bba91b3844356eaf801717a5c985 Mon Sep 17 00:00:00 2001 From: Nick Date: Fri, 3 May 2019 23:45:54 -0400 Subject: [PATCH] feat: helm chart (wip) --- dev/helm/Chart.yaml | 21 +++++++++++++++++ dev/helm/README.md | 2 ++ dev/helm/requirements.yaml | 5 ++++ dev/helm/templates/ingress.yaml | 39 +++++++++++++++++++++++++++++++ dev/helm/templates/secrets.yaml | 13 +++++++++++ dev/helm/templates/service.yaml | 32 +++++++++++++++++++++++++ dev/helm/values.yaml | 41 +++++++++++++++++++++++++++++++++ 7 files changed, 153 insertions(+) create mode 100644 dev/helm/Chart.yaml create mode 100644 dev/helm/README.md create mode 100644 dev/helm/requirements.yaml create mode 100644 dev/helm/templates/ingress.yaml create mode 100644 dev/helm/templates/secrets.yaml create mode 100644 dev/helm/templates/service.yaml create mode 100644 dev/helm/values.yaml diff --git a/dev/helm/Chart.yaml b/dev/helm/Chart.yaml new file mode 100644 index 00000000..597579af --- /dev/null +++ b/dev/helm/Chart.yaml @@ -0,0 +1,21 @@ +apiVersion: v1 +name: Wiki.js +version: 2.0.0 +appVersion: 2.0.0 +description: The most powerful and extensible open source Wiki software. +keywords: + - wiki + - documentation + - knowledge base + - docs + - reference + - editor +home: https://wiki.js.org +icon: https://github.com/Requarks/wiki/raw/master/client/static/favicons/android-icon-192x192.png +sources: + - https://github.com/Requarks/wiki +maintainers: + - name: Nicolas Giard + email: github@ngpixel.com + url: https://github.com/NGPixel +engine: gotpl diff --git a/dev/helm/README.md b/dev/helm/README.md new file mode 100644 index 00000000..b3c43d86 --- /dev/null +++ b/dev/helm/README.md @@ -0,0 +1,2 @@ +# Work in progress +##### Do not use! diff --git a/dev/helm/requirements.yaml b/dev/helm/requirements.yaml new file mode 100644 index 00000000..16900131 --- /dev/null +++ b/dev/helm/requirements.yaml @@ -0,0 +1,5 @@ +dependencies: + - name: postgresql + version: 3.18.4 + repository: https://kubernetes-charts.storage.googleapis.com/ + condition: postgresql.enabled diff --git a/dev/helm/templates/ingress.yaml b/dev/helm/templates/ingress.yaml new file mode 100644 index 00000000..01d60ffb --- /dev/null +++ b/dev/helm/templates/ingress.yaml @@ -0,0 +1,39 @@ +{{- if .Values.ingress.enabled }} +{{- range .Values.ingress.hosts }} +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: {{ template "wiki.fullname" $ }} + labels: + app: {{ template "wiki.name" $ }} + chart: {{ template "wiki.chart" $ }} + release: {{ $.Release.Name | quote }} + heritage: {{ $.Release.Service | quote }} + annotations: + {{- if .tls }} + ingress.kubernetes.io/secure-backends: "true" + {{- end }} + {{- if .certManager }} + kubernetes.io/tls-acme: "true" + {{- end }} + {{- range $key, $value := .annotations }} + {{ $key }}: {{ $value | quote }} + {{- end }} +spec: + rules: + - host: {{ .name }} + http: + paths: + - path: {{ default "/" .path }} + backend: + serviceName: {{ template "wiki.fullname" $ }} + servicePort: 80 +{{- if .tls }} + tls: + - hosts: + - {{ .name }} + secretName: {{ .tlsSecret }} +{{- end }} +--- +{{- end }} +{{- end }} diff --git a/dev/helm/templates/secrets.yaml b/dev/helm/templates/secrets.yaml new file mode 100644 index 00000000..66241deb --- /dev/null +++ b/dev/helm/templates/secrets.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: Secret +metadata: + name: {{ template "wiki.fullname" . }} + labels: + app: {{ template "wiki.fullname" . }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + release: "{{ .Release.Name }}" + heritage: "{{ .Release.Service }}" +type: Opaque +data: + db-user: {{ .Values.postgresql.postgresUser | b64enc | quote }} + db-password: {{ .Values.postgresql.postgresPassword | b64enc | quote }} diff --git a/dev/helm/templates/service.yaml b/dev/helm/templates/service.yaml new file mode 100644 index 00000000..1bf029bb --- /dev/null +++ b/dev/helm/templates/service.yaml @@ -0,0 +1,32 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ template "wiki.fullname" . }} + labels: + app: {{ template "wiki.name" . }} + chart: {{ template "wiki.chart" . }} + release: {{ .Release.Name | quote }} + heritage: {{ .Release.Service | quote }} +spec: + type: {{ .Values.service.type }} + {{- if .Values.service.loadBalancerIP }} + loadBalancerIP: {{ .Values.service.loadBalancerIP }} + {{- end }} + {{- if (or (eq .Values.service.type "LoadBalancer") (eq .Values.service.type "NodePort")) }} + externalTrafficPolicy: {{ .Values.service.externalTrafficPolicy | quote }} + {{- end }} + ports: + - name: http + port: {{ .Values.service.port }} + targetPort: http + {{- if (and (eq .Values.service.type "NodePort") (not (empty .Values.service.nodePorts.http)))}} + nodePort: {{ .Values.service.nodePorts.http }} + {{- end }} + - name: https + port: {{ .Values.service.httpsPort }} + targetPort: https + {{- if (and (eq .Values.service.type "NodePort") (not (empty .Values.service.nodePorts.https)))}} + nodePort: {{ .Values.service.nodePorts.https }} + {{- end }} + selector: + app: {{ template "wiki.name" . }} diff --git a/dev/helm/values.yaml b/dev/helm/values.yaml new file mode 100644 index 00000000..2a5ec42c --- /dev/null +++ b/dev/helm/values.yaml @@ -0,0 +1,41 @@ +## +## Configuration values for the postgresql dependency. +## ref: https://github.com/kubernetes/charts/blob/master/stable/postgresql/README.md +postgresql: + ## + ## Use the PostgreSQL chart dependency. + ## Set to false if bringing your own PostgreSQL. + enabled: true + ## + ## If you are bringing your own PostgreSQL, you should set postgresHost and + ## also probably service.port, postgresUser, postgresPassword, and postgresDatabase + ## postgresHost: + ## + ## PostgreSQL port + service: + port: 5432 + ## PostgreSQL User to create. + postgresUser: wiki + ## + ## PostgreSQL Password for the new user. + ## If not set, a random 10 characters password will be used. + postgresPassword: wikijsrocks + ## + ## PostgreSQL Database to create. + postgresDatabase: wiki + ## + ## Persistent Volume Storage configuration. + ## ref: https://kubernetes.io/docs/user-guide/persistent-volumes + persistence: + ## + ## Enable PostgreSQL persistence using Persistent Volume Claims. + enabled: true + ## + ## Persistant class + # storageClass: classname + ## + ## Access mode: + accessMode: ReadWriteOnce + ## + ## Requested size: + size: 10Gi