From e7a90d9a7ce15d9405f5d750593715306a542c83 Mon Sep 17 00:00:00 2001 From: Stephen Randall Date: Mon, 4 Mar 2019 15:55:20 +0000 Subject: Added helm chart v1 --- helm/wekan/.helmignore | 22 +++++ helm/wekan/Chart.yaml | 13 +++ helm/wekan/OWNERS | 4 + helm/wekan/README.md | 1 + helm/wekan/charts/mongodb-replicaset-3.6.4.tgz | Bin 0 -> 14728 bytes helm/wekan/requirements.lock | 6 ++ helm/wekan/requirements.yaml | 5 + helm/wekan/templates/NOTES.txt | 19 ++++ helm/wekan/templates/_helpers.tpl | 82 ++++++++++++++++ helm/wekan/templates/deployment.yaml | 58 ++++++++++++ helm/wekan/templates/hpa.yaml | 18 ++++ helm/wekan/templates/ingress.yaml | 40 ++++++++ helm/wekan/templates/secrets.yaml | 14 +++ helm/wekan/templates/service.yaml | 25 +++++ helm/wekan/templates/serviceaccount.yaml | 12 +++ helm/wekan/templates/tests/test-cloudserver.yaml | 27 ++++++ helm/wekan/values.yaml | 114 +++++++++++++++++++++++ 17 files changed, 460 insertions(+) create mode 100644 helm/wekan/.helmignore create mode 100644 helm/wekan/Chart.yaml create mode 100644 helm/wekan/OWNERS create mode 100644 helm/wekan/README.md create mode 100644 helm/wekan/charts/mongodb-replicaset-3.6.4.tgz create mode 100644 helm/wekan/requirements.lock create mode 100644 helm/wekan/requirements.yaml create mode 100644 helm/wekan/templates/NOTES.txt create mode 100644 helm/wekan/templates/_helpers.tpl create mode 100644 helm/wekan/templates/deployment.yaml create mode 100644 helm/wekan/templates/hpa.yaml create mode 100644 helm/wekan/templates/ingress.yaml create mode 100644 helm/wekan/templates/secrets.yaml create mode 100644 helm/wekan/templates/service.yaml create mode 100644 helm/wekan/templates/serviceaccount.yaml create mode 100644 helm/wekan/templates/tests/test-cloudserver.yaml create mode 100644 helm/wekan/values.yaml diff --git a/helm/wekan/.helmignore b/helm/wekan/.helmignore new file mode 100644 index 00000000..7c04072e --- /dev/null +++ b/helm/wekan/.helmignore @@ -0,0 +1,22 @@ +# 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 +OWNERS diff --git a/helm/wekan/Chart.yaml b/helm/wekan/Chart.yaml new file mode 100644 index 00000000..ffd164bf --- /dev/null +++ b/helm/wekan/Chart.yaml @@ -0,0 +1,13 @@ +name: wekan +version: 1.0.0 +appVersion: 2.x.x +kubeVersion: "^1.8.0-0" +description: Open Source kanban +home: https://wekan.github.io/ +icon: https://wekan.github.io/wekan-logo.svg +sources: + - https://github.com/wekan/wekan +maintainers: + - name: technotaff + email: github@randall.cc +engine: gotpl diff --git a/helm/wekan/OWNERS b/helm/wekan/OWNERS new file mode 100644 index 00000000..08f7d5dd --- /dev/null +++ b/helm/wekan/OWNERS @@ -0,0 +1,4 @@ +approvers: +- technotaff +reviewers: +- technotaff diff --git a/helm/wekan/README.md b/helm/wekan/README.md new file mode 100644 index 00000000..52da2380 --- /dev/null +++ b/helm/wekan/README.md @@ -0,0 +1 @@ +# README \ No newline at end of file diff --git a/helm/wekan/charts/mongodb-replicaset-3.6.4.tgz b/helm/wekan/charts/mongodb-replicaset-3.6.4.tgz new file mode 100644 index 00000000..3055b15d Binary files /dev/null and b/helm/wekan/charts/mongodb-replicaset-3.6.4.tgz differ diff --git a/helm/wekan/requirements.lock b/helm/wekan/requirements.lock new file mode 100644 index 00000000..38dd70f4 --- /dev/null +++ b/helm/wekan/requirements.lock @@ -0,0 +1,6 @@ +dependencies: +- name: mongodb-replicaset + repository: https://kubernetes-charts.storage.googleapis.com/ + version: 3.6.4 +digest: sha256:915036b66ee65022e4c4f5a088ee52eb1edcf9651adb8013105380eaf754abf5 +generated: 2019-03-04T10:59:06.655216577Z diff --git a/helm/wekan/requirements.yaml b/helm/wekan/requirements.yaml new file mode 100644 index 00000000..e2492a91 --- /dev/null +++ b/helm/wekan/requirements.yaml @@ -0,0 +1,5 @@ +dependencies: +- name: mongodb-replicaset + version: 3.6.x + repository: "https://kubernetes-charts.storage.googleapis.com/" + condition: mongodb-replicaset.enabled diff --git a/helm/wekan/templates/NOTES.txt b/helm/wekan/templates/NOTES.txt new file mode 100644 index 00000000..f2a92d61 --- /dev/null +++ b/helm/wekan/templates/NOTES.txt @@ -0,0 +1,19 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range .Values.ingress.hosts }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "wekan.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 {{ template "wekan.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "wekan.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={{ template "wekan.name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + echo "Visit http://127.0.0.1:8000 to use your application" + kubectl port-forward $POD_NAME 8000:8000 +{{- end }} diff --git a/helm/wekan/templates/_helpers.tpl b/helm/wekan/templates/_helpers.tpl new file mode 100644 index 00000000..68f71ef7 --- /dev/null +++ b/helm/wekan/templates/_helpers.tpl @@ -0,0 +1,82 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "wekan.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 "wekan.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 name for the wekan data app. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +*/}} +{{- define "wekan.localdata.fullname" -}} +{{- if .Values.localdata.fullnameOverride -}} +{{- .Values.localdata.fullnameOverride | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- if contains $name .Release.Name -}} +{{- printf "%s-localdata" .Release.Name | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- printf "%s-%s-localdata" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} +{{- end -}} +{{- end -}} +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "wekan.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create the name of the service account to use for the api component +*/}} +{{- define "wekan.serviceAccountName" -}} +{{- if .Values.serviceAccounts.create -}} + {{ default (include "wekan.fullname" .) .Values.serviceAccounts.name }} +{{- else -}} + {{ default "default" .Values.serviceAccounts.name }} +{{- end -}} +{{- end -}} + +{{/* +Create a default fully qualified mongodb-replicaset name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +*/}} +{{- define "wekan.mongodb-replicaset.fullname" -}} +{{- $name := default "mongodb-replicaset" (index .Values "mongodb-replicaset" "nameOverride") -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create the MongoDB URL. If MongoDB is installed as part of this chart, use k8s service discovery, +else use user-provided URL. +*/}} +{{- define "mongodb-replicaset.url" -}} +{{- if (index .Values "mongodb-replicaset" "enabled") -}} +{{- $count := (int (index .Values "mongodb-replicaset" "replicas")) -}} +{{- $release := .Release.Name -}} +mongodb://{{- range $v := until $count }}{{ $release }}-mongodb-replicaset-{{ $v }}.{{ $release }}-mongodb-replicaset:27017{{ if ne $v (sub $count 1) }},{{- end -}}{{- end -}}?replicaSet={{ index .Values "mongodb-replicaset" "replicaSetName" }} +{{- else -}} +{{- index .Values "mongodb-replicaset" "url" -}} +{{- end -}} +{{- end -}} diff --git a/helm/wekan/templates/deployment.yaml b/helm/wekan/templates/deployment.yaml new file mode 100644 index 00000000..e5bf2018 --- /dev/null +++ b/helm/wekan/templates/deployment.yaml @@ -0,0 +1,58 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ template "wekan.fullname" . }} + labels: + app: {{ template "wekan.name" . }} + chart: {{ template "wekan.chart" . }} + component: wekan + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app: {{ template "wekan.name" . }} + component: wekan + release: {{ .Release.Name }} + template: + metadata: + annotations: + labels: + app: {{ template "wekan.name" . }} + component: wekan + release: {{ .Release.Name }} + spec: + serviceAccountName: {{ template "wekan.serviceAccountName" . }} + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + terminationMessagePolicy: FallbackToLogsOnError + ports: + - name: http + containerPort: 8080 + env: + - name: ROOT_URL + value: {{ .Values.root_url | default "https://wekan.local" | quote }} + - name: MONGO_URL + value: "{{ template "mongodb-replicaset.url" . }}" + livenessProbe: + httpGet: + path: / + port: 8080 + initialDelaySeconds: 60 + resources: +{{ toYaml .Values.resources | indent 12 }} + {{- with .Values.nodeSelector }} + nodeSelector: +{{ toYaml . | indent 8 }} + {{- end }} +{{- if .Values.affinity }} + affinity: +{{ toYaml .Values.affinity | indent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: +{{ toYaml . | indent 8 }} + {{- end }} diff --git a/helm/wekan/templates/hpa.yaml b/helm/wekan/templates/hpa.yaml new file mode 100644 index 00000000..5c8017c3 --- /dev/null +++ b/helm/wekan/templates/hpa.yaml @@ -0,0 +1,18 @@ +{{- if .Values.autoscaling.enabled -}} +apiVersion: autoscaling/v1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ template "wekan.fullname" . }} + labels: + app: {{ template "wekan.name" . }} + chart: {{ template "wekan.chart" . }} + component: wekan + heritage: {{ .Release.Service }} + release: {{ .Release.Name }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ template "wekan.fullname" . }} +{{ toYaml .Values.autoscaling.config | indent 2 }} +{{- end -}} diff --git a/helm/wekan/templates/ingress.yaml b/helm/wekan/templates/ingress.yaml new file mode 100644 index 00000000..d63c21c3 --- /dev/null +++ b/helm/wekan/templates/ingress.yaml @@ -0,0 +1,40 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "wekan.fullname" . -}} +{{- $servicePort := .Values.service.port -}} +{{- $ingressPath := .Values.ingress.path -}} +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + app: {{ template "wekan.name" . }} + chart: {{ template "wekan.chart" . }} + component: wekan + heritage: {{ .Release.Service }} + release: {{ .Release.Name }} +{{- with .Values.ingress.annotations }} + annotations: +{{ toYaml . | indent 4 }} +{{- end }} +spec: +{{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} +{{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ . }} + http: + paths: + - path: {{ $ingressPath }} + backend: + serviceName: {{ $fullName }} + servicePort: http + {{- end }} +{{- end }} diff --git a/helm/wekan/templates/secrets.yaml b/helm/wekan/templates/secrets.yaml new file mode 100644 index 00000000..79ae3d48 --- /dev/null +++ b/helm/wekan/templates/secrets.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Secret +metadata: + name: {{ template "wekan.fullname" . }} + labels: + app: {{ template "wekan.name" . }} + chart: {{ template "wekan.chart" . }} + component: wekan + heritage: {{ .Release.Service }} + release: {{ .Release.Name }} +type: Opaque +data: + accessKey: {{ .Values.credentials.accessKey | b64enc }} + secretKey: {{ .Values.credentials.secretKey | b64enc }} diff --git a/helm/wekan/templates/service.yaml b/helm/wekan/templates/service.yaml new file mode 100644 index 00000000..6099faec --- /dev/null +++ b/helm/wekan/templates/service.yaml @@ -0,0 +1,25 @@ +apiVersion: v1 +kind: Service +metadata: + {{- if .Values.service.annotations }} + annotations: +{{ toYaml .Values.service.annotations | indent 4 }} + {{- end }} + name: {{ template "wekan.fullname" . }} + labels: + app: {{ template "wekan.name" . }} + chart: {{ template "wekan.chart" . }} + component: wekan + heritage: {{ .Release.Service }} + release: {{ .Release.Name }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + app: {{ template "wekan.name" . }} + component: wekan + release: {{ .Release.Name }} diff --git a/helm/wekan/templates/serviceaccount.yaml b/helm/wekan/templates/serviceaccount.yaml new file mode 100644 index 00000000..58696cb6 --- /dev/null +++ b/helm/wekan/templates/serviceaccount.yaml @@ -0,0 +1,12 @@ +{{- if .Values.serviceAccounts.create }} +apiVersion: v1 +kind: ServiceAccount +metadata: + labels: + app: {{ template "wekan.name" . }} + chart: {{ template "wekan.chart" . }} + component: wekan + heritage: {{ .Release.Service }} + release: {{ .Release.Name }} + name: {{ template "wekan.serviceAccountName" . }} +{{- end }} diff --git a/helm/wekan/templates/tests/test-cloudserver.yaml b/helm/wekan/templates/tests/test-cloudserver.yaml new file mode 100644 index 00000000..a1db7289 --- /dev/null +++ b/helm/wekan/templates/tests/test-cloudserver.yaml @@ -0,0 +1,27 @@ +apiVersion: v1 +kind: Pod +metadata: + name: {{ template "wekan.fullname" . }}-test + annotations: + "helm.sh/hook": test-success +spec: + containers: + - name: {{ template "wekan.fullname" . }}-test + imagePullPolicy: IfNotPresent + image: "docker.io/mesosphere/aws-cli:1.14.5" + command: + - sh + - -c + - aws s3 --endpoint-url=http://{{ include "wekan.fullname" . }} --region=us-east-1 ls + env: + - name: AWS_ACCESS_KEY_ID + valueFrom: + secretKeyRef: + name: {{ template "wekan.fullname" . }} + key: accessKey + - name: AWS_SECRET_ACCESS_KEY + valueFrom: + secretKeyRef: + name: {{ template "wekan.fullname" . }} + key: secretKey + restartPolicy: Never diff --git a/helm/wekan/values.yaml b/helm/wekan/values.yaml new file mode 100644 index 00000000..b97b0a5f --- /dev/null +++ b/helm/wekan/values.yaml @@ -0,0 +1,114 @@ +# ------------------------------------------------------------------------------ +# Wekan: +# ------------------------------------------------------------------------------ + +## Define serviceAccount names to create or use. Defaults to component's fully +## qualified name. +## +serviceAccounts: + create: true + name: "" + +## Wekan image configuration +## +image: + repository: quay.io/wekan/wekan + tag: latest + pullPolicy: IfNotPresent + +## Configuration for wekan component +## + +replicaCount: 1 + +## Specify wekan credentials +## +credentials: + accessKey: access-key + secretKey: secret-key + +## Specify log level (info, debug or trace) +## +logLevel: info + +## Specify additional environmental variables for the Deployment +## +env: {} + +service: + type: NodePort + port: 80 + annotations: {} + # prometheus.io/scrape: "true" + # prometheus.io/port: "8000" + # prometheus.io/path: "/_/monitoring/metrics" + +## Comma-separated string of allowed virtual hosts for external access. +## This should match the ingress hosts +## +endpoint: wekan.local + +ingress: + enabled: true + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + path: /* + # This must match 'endpoint', unless your client supports different + # hostnames. + hosts: [ wekan.local ] + # - wekan.local + tls: [] + # - secretName: wekan-example-tls + # hosts: + # - wekan-example.local + +resources: + requests: + memory: 128Mi + cpu: 300m + limits: + memory: 1Gi + cpu: 500m + +## Node labels for pod assignment +## ref: https://kubernetes.io/docs/user-guide/node-selection/ +## +nodeSelector: {} + +## Tolerations for pod assignment +## ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/ +## +tolerations: [] + +## Affinity for pod assignment +## ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity +## +affinity: {} + +## Configure an horizontal pod autoscaler +## +autoscaling: + enabled: true + config: + minReplicas: 1 + maxReplicas: 16 + ## Note: when setting this, a `resources.request.cpu` is required. You + ## likely want to set it to `1` or some lower value. + ## + targetCPUUtilizationPercentage: 80 + +# ------------------------------------------------------------------------------ +# MongoDB: +# ------------------------------------------------------------------------------ + +mongodb-replicaset: + enabled: true + replicas: 3 + replicaSetName: rs0 + securityContext: + runAsUser: 1000 + fsGroup: 1000 + runAsNonRoot: true + #image: + # tag: 3.2.21 -- cgit v1.2.3-1-g7c22