From d7f1b2c25b3ddbb3b2b9f353a8131ffe42a5929f Mon Sep 17 00:00:00 2001 From: mike hepburn Date: Fri, 24 Apr 2020 20:48:22 +1000 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=81=20Feature/etherpad=20=F0=9F=A7=81?= =?UTF-8?q?=20(#31)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 🥝 add etherpad chart 🥝 * 🥝 linting 🥝 --- charts/etherpad/.helmignore | 23 ++++++++ charts/etherpad/Chart.yaml | 9 +++ charts/etherpad/templates/_helpers.tpl | 52 +++++++++++++++++ charts/etherpad/templates/deployment.yaml | 70 +++++++++++++++++++++++ charts/etherpad/templates/ingress.yaml | 41 +++++++++++++ charts/etherpad/templates/pvc.yaml | 27 +++++++++ charts/etherpad/templates/route.yaml | 29 ++++++++++ charts/etherpad/templates/service.yaml | 15 +++++ charts/etherpad/values.yaml | 57 ++++++++++++++++++ 9 files changed, 323 insertions(+) create mode 100644 charts/etherpad/.helmignore create mode 100644 charts/etherpad/Chart.yaml create mode 100644 charts/etherpad/templates/_helpers.tpl create mode 100644 charts/etherpad/templates/deployment.yaml create mode 100644 charts/etherpad/templates/ingress.yaml create mode 100644 charts/etherpad/templates/pvc.yaml create mode 100644 charts/etherpad/templates/route.yaml create mode 100644 charts/etherpad/templates/service.yaml create mode 100644 charts/etherpad/values.yaml diff --git a/charts/etherpad/.helmignore b/charts/etherpad/.helmignore new file mode 100644 index 00000000..0e8a0eb3 --- /dev/null +++ b/charts/etherpad/.helmignore @@ -0,0 +1,23 @@ +# 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 +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/charts/etherpad/Chart.yaml b/charts/etherpad/Chart.yaml new file mode 100644 index 00000000..365e2d6d --- /dev/null +++ b/charts/etherpad/Chart.yaml @@ -0,0 +1,9 @@ +apiVersion: v2 +name: etherpad +description: A Helm chart for etherpad lite +type: application +version: 0.0.1 +appVersion: latest +home: https://github.com/rht-labs/helm-charts +maintainers: + - name: eformat diff --git a/charts/etherpad/templates/_helpers.tpl b/charts/etherpad/templates/_helpers.tpl new file mode 100644 index 00000000..7cf59c2c --- /dev/null +++ b/charts/etherpad/templates/_helpers.tpl @@ -0,0 +1,52 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "etherpad.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 "etherpad.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 "etherpad.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Common labels +*/}} +{{- define "etherpad.labels" -}} +helm.sh/chart: {{ include "etherpad.chart" . }} +{{ include "etherpad.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end -}} + +{{/* +Selector labels +*/}} +{{- define "etherpad.selectorLabels" -}} +app.kubernetes.io/name: {{ include "etherpad.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end -}} diff --git a/charts/etherpad/templates/deployment.yaml b/charts/etherpad/templates/deployment.yaml new file mode 100644 index 00000000..629e1882 --- /dev/null +++ b/charts/etherpad/templates/deployment.yaml @@ -0,0 +1,70 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "etherpad.fullname" . }} + labels: + {{- include "etherpad.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + {{- include "etherpad.selectorLabels" . | nindent 6 }} + template: + metadata: + labels: + {{- include "etherpad.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - env: + - name: TITLE + value: {{ .Values.defaultTitle }} + - name: DEFAULT_PAD_TEXT + value: {{ .Values.defaultText }} + name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}/{{ .Chart.Name }}:{{ .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: http + containerPort: 9001 + protocol: TCP + livenessProbe: + httpGet: + path: / + port: http + readinessProbe: + httpGet: + path: / + port: http + resources: + {{- toYaml .Values.resources | nindent 12 }} + volumeMounts: + - name: etherpad-data + mountPath: {{ .Values.persistence.mountPath }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} + volumes: + - name: etherpad-data + {{- if .Values.persistence.enabled }} + persistentVolumeClaim: + claimName: {{ .Values.persistence.existingClaim | default (printf "%s" (include "etherpad.fullname" .)) }} + {{- else }} + emptyDir: {} + {{- end }} diff --git a/charts/etherpad/templates/ingress.yaml b/charts/etherpad/templates/ingress.yaml new file mode 100644 index 00000000..5e6499d8 --- /dev/null +++ b/charts/etherpad/templates/ingress.yaml @@ -0,0 +1,41 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "etherpad.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "etherpad.labels" . | nindent 4 }} + {{- 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: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ . }} + backend: + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} +{{- end }} diff --git a/charts/etherpad/templates/pvc.yaml b/charts/etherpad/templates/pvc.yaml new file mode 100644 index 00000000..d7fb1b12 --- /dev/null +++ b/charts/etherpad/templates/pvc.yaml @@ -0,0 +1,27 @@ +{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) }} +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: {{ include "etherpad.fullname" . }} + labels: + {{- include "etherpad.labels" . | nindent 4 }} +{{ if .Values.persistence.annotations}} + annotations: + {{- range $key, $value := .Values.persistence.annotations }} + {{ $key }}: {{ $value | quote }} + {{- end }} +{{- end }} +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 }} diff --git a/charts/etherpad/templates/route.yaml b/charts/etherpad/templates/route.yaml new file mode 100644 index 00000000..c00069e4 --- /dev/null +++ b/charts/etherpad/templates/route.yaml @@ -0,0 +1,29 @@ +{{- if .Values.route.enabled -}} +{{- $fullName := include "etherpad.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +--- +apiVersion: route.openshift.io/v1 +kind: Route +metadata: + annotations: + openshift.io/host.generated: "true" + name: {{ $fullName }} + labels: + {{- include "etherpad.labels" . | nindent 4 }} +spec: + host: {{ .Values.route.host | quote }} + port: + targetPort: {{ .Values.route.targetPort | default "8080-tcp" }} + to: + kind: Service + name: {{ $fullName }} + weight: 100 + tls: + insecureEdgeTerminationPolicy: Redirect + termination: edge +status: + ingress: + - conditions: + - status: 'True' + type: Admitted +{{ end }} \ No newline at end of file diff --git a/charts/etherpad/templates/service.yaml b/charts/etherpad/templates/service.yaml new file mode 100644 index 00000000..5ce5c434 --- /dev/null +++ b/charts/etherpad/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "etherpad.fullname" . }} + labels: + {{- include "etherpad.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "etherpad.selectorLabels" . | nindent 4 }} diff --git a/charts/etherpad/values.yaml b/charts/etherpad/values.yaml new file mode 100644 index 00000000..fbcf5dcd --- /dev/null +++ b/charts/etherpad/values.yaml @@ -0,0 +1,57 @@ +# Default values for etherpad. +replicaCount: 1 + +defaultTitle: "Labs Etherpad" +defaultText: "✍️ Assign yourself a user and share your ideas! ✍️" + +image: + repository: etherpad + pullPolicy: IfNotPresent + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +podSecurityContext: {} +securityContext: {} + +service: + type: ClusterIP + port: 9001 + +ingress: + enabled: false + hosts: + - name: etherpad.organization.com + annotations: {} + +route: + enabled: true + host: null + targetPort: http + +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: {} + +persistence: + enabled: true + annotations: {} + storageClass: + accessMode: ReadWriteOnce + size: 1Gi + mountPath: /opt/etherpad-lite/var