diff --git a/README.md b/README.md index 16deb72..41c9ba3 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,27 @@ # charts Helm charts maintained by Improwised Technologies +## Usage + +Add helm repo + +```bash +helm repo add improwised https://improwised.github.io/charts/ +``` + +## Add charts + +1. Package the chart, this will create `chartname-semver.tgz` file. + + ```bash + helm package + ``` + +2. Checkout `gh-pages` branch of this repo and move `chart-name-semver.tgz` to `charts` directory. + +3. Index added chart + + ```bash + helm repo index --url https://improwised.github.io/charts . + ``` + +4. Add appropriate commit message and push it diff --git a/erpnext/.helmignore b/charts/erpnext/.helmignore similarity index 100% rename from erpnext/.helmignore rename to charts/erpnext/.helmignore diff --git a/erpnext/Chart.yaml b/charts/erpnext/Chart.yaml similarity index 100% rename from erpnext/Chart.yaml rename to charts/erpnext/Chart.yaml diff --git a/erpnext/README.md b/charts/erpnext/README.md similarity index 100% rename from erpnext/README.md rename to charts/erpnext/README.md diff --git a/erpnext/templates/NOTES.txt b/charts/erpnext/templates/NOTES.txt similarity index 100% rename from erpnext/templates/NOTES.txt rename to charts/erpnext/templates/NOTES.txt diff --git a/erpnext/templates/_helpers.tpl b/charts/erpnext/templates/_helpers.tpl similarity index 100% rename from erpnext/templates/_helpers.tpl rename to charts/erpnext/templates/_helpers.tpl diff --git a/erpnext/templates/deployment-erpnext.yaml b/charts/erpnext/templates/deployment-erpnext.yaml similarity index 100% rename from erpnext/templates/deployment-erpnext.yaml rename to charts/erpnext/templates/deployment-erpnext.yaml diff --git a/erpnext/templates/deployment-redis-cache.yaml b/charts/erpnext/templates/deployment-redis-cache.yaml similarity index 100% rename from erpnext/templates/deployment-redis-cache.yaml rename to charts/erpnext/templates/deployment-redis-cache.yaml diff --git a/erpnext/templates/deployment-redis-queue.yaml b/charts/erpnext/templates/deployment-redis-queue.yaml similarity index 100% rename from erpnext/templates/deployment-redis-queue.yaml rename to charts/erpnext/templates/deployment-redis-queue.yaml diff --git a/erpnext/templates/deployment-redis-socketio.yaml b/charts/erpnext/templates/deployment-redis-socketio.yaml similarity index 100% rename from erpnext/templates/deployment-redis-socketio.yaml rename to charts/erpnext/templates/deployment-redis-socketio.yaml diff --git a/erpnext/templates/deployment-scheduler.yaml b/charts/erpnext/templates/deployment-scheduler.yaml similarity index 100% rename from erpnext/templates/deployment-scheduler.yaml rename to charts/erpnext/templates/deployment-scheduler.yaml diff --git a/erpnext/templates/deployment-socketio.yaml b/charts/erpnext/templates/deployment-socketio.yaml similarity index 100% rename from erpnext/templates/deployment-socketio.yaml rename to charts/erpnext/templates/deployment-socketio.yaml diff --git a/erpnext/templates/deployment-worker-default.yaml b/charts/erpnext/templates/deployment-worker-default.yaml similarity index 100% rename from erpnext/templates/deployment-worker-default.yaml rename to charts/erpnext/templates/deployment-worker-default.yaml diff --git a/erpnext/templates/deployment-worker-long.yaml b/charts/erpnext/templates/deployment-worker-long.yaml similarity index 100% rename from erpnext/templates/deployment-worker-long.yaml rename to charts/erpnext/templates/deployment-worker-long.yaml diff --git a/erpnext/templates/deployment-worker-short.yaml b/charts/erpnext/templates/deployment-worker-short.yaml similarity index 100% rename from erpnext/templates/deployment-worker-short.yaml rename to charts/erpnext/templates/deployment-worker-short.yaml diff --git a/erpnext/templates/job-migrate-sites.yaml b/charts/erpnext/templates/job-migrate-sites.yaml similarity index 100% rename from erpnext/templates/job-migrate-sites.yaml rename to charts/erpnext/templates/job-migrate-sites.yaml diff --git a/erpnext/templates/pvc.yaml b/charts/erpnext/templates/pvc.yaml similarity index 100% rename from erpnext/templates/pvc.yaml rename to charts/erpnext/templates/pvc.yaml diff --git a/erpnext/templates/pvc_logs.yaml b/charts/erpnext/templates/pvc_logs.yaml similarity index 100% rename from erpnext/templates/pvc_logs.yaml rename to charts/erpnext/templates/pvc_logs.yaml diff --git a/erpnext/templates/redis-cache-service.yaml b/charts/erpnext/templates/redis-cache-service.yaml similarity index 100% rename from erpnext/templates/redis-cache-service.yaml rename to charts/erpnext/templates/redis-cache-service.yaml diff --git a/erpnext/templates/redis-queue-service.yaml b/charts/erpnext/templates/redis-queue-service.yaml similarity index 100% rename from erpnext/templates/redis-queue-service.yaml rename to charts/erpnext/templates/redis-queue-service.yaml diff --git a/erpnext/templates/redis-socketio-service.yaml b/charts/erpnext/templates/redis-socketio-service.yaml similarity index 100% rename from erpnext/templates/redis-socketio-service.yaml rename to charts/erpnext/templates/redis-socketio-service.yaml diff --git a/erpnext/templates/service.yaml b/charts/erpnext/templates/service.yaml similarity index 100% rename from erpnext/templates/service.yaml rename to charts/erpnext/templates/service.yaml diff --git a/erpnext/templates/serviceaccount.yaml b/charts/erpnext/templates/serviceaccount.yaml similarity index 100% rename from erpnext/templates/serviceaccount.yaml rename to charts/erpnext/templates/serviceaccount.yaml diff --git a/erpnext/templates/socketio-service.yaml b/charts/erpnext/templates/socketio-service.yaml similarity index 100% rename from erpnext/templates/socketio-service.yaml rename to charts/erpnext/templates/socketio-service.yaml diff --git a/erpnext/templates/tests/test-connection.yaml b/charts/erpnext/templates/tests/test-connection.yaml similarity index 100% rename from erpnext/templates/tests/test-connection.yaml rename to charts/erpnext/templates/tests/test-connection.yaml diff --git a/erpnext/values.yaml b/charts/erpnext/values.yaml similarity index 100% rename from erpnext/values.yaml rename to charts/erpnext/values.yaml diff --git a/freeipa/.helmignore b/charts/freeipa/.helmignore similarity index 100% rename from freeipa/.helmignore rename to charts/freeipa/.helmignore diff --git a/freeipa/Chart.yaml b/charts/freeipa/Chart.yaml similarity index 100% rename from freeipa/Chart.yaml rename to charts/freeipa/Chart.yaml diff --git a/freeipa/templates/NOTES.txt b/charts/freeipa/templates/NOTES.txt similarity index 100% rename from freeipa/templates/NOTES.txt rename to charts/freeipa/templates/NOTES.txt diff --git a/freeipa/templates/_helpers.tpl b/charts/freeipa/templates/_helpers.tpl similarity index 100% rename from freeipa/templates/_helpers.tpl rename to charts/freeipa/templates/_helpers.tpl diff --git a/freeipa/templates/deployment.yaml b/charts/freeipa/templates/deployment.yaml similarity index 100% rename from freeipa/templates/deployment.yaml rename to charts/freeipa/templates/deployment.yaml diff --git a/freeipa/templates/hpa.yaml b/charts/freeipa/templates/hpa.yaml similarity index 100% rename from freeipa/templates/hpa.yaml rename to charts/freeipa/templates/hpa.yaml diff --git a/freeipa/templates/ingress.yaml b/charts/freeipa/templates/ingress.yaml similarity index 100% rename from freeipa/templates/ingress.yaml rename to charts/freeipa/templates/ingress.yaml diff --git a/freeipa/templates/pvc.yaml b/charts/freeipa/templates/pvc.yaml similarity index 100% rename from freeipa/templates/pvc.yaml rename to charts/freeipa/templates/pvc.yaml diff --git a/freeipa/templates/service.yaml b/charts/freeipa/templates/service.yaml similarity index 100% rename from freeipa/templates/service.yaml rename to charts/freeipa/templates/service.yaml diff --git a/freeipa/templates/serviceaccount.yaml b/charts/freeipa/templates/serviceaccount.yaml similarity index 100% rename from freeipa/templates/serviceaccount.yaml rename to charts/freeipa/templates/serviceaccount.yaml diff --git a/freeipa/templates/tests/test-connection.yaml b/charts/freeipa/templates/tests/test-connection.yaml similarity index 100% rename from freeipa/templates/tests/test-connection.yaml rename to charts/freeipa/templates/tests/test-connection.yaml diff --git a/freeipa/values.yaml b/charts/freeipa/values.yaml similarity index 100% rename from freeipa/values.yaml rename to charts/freeipa/values.yaml diff --git a/healthchecks/.helmignore b/charts/healthchecks/.helmignore similarity index 100% rename from healthchecks/.helmignore rename to charts/healthchecks/.helmignore diff --git a/healthchecks/Chart.yaml b/charts/healthchecks/Chart.yaml similarity index 100% rename from healthchecks/Chart.yaml rename to charts/healthchecks/Chart.yaml diff --git a/healthchecks/templates/NOTES.txt b/charts/healthchecks/templates/NOTES.txt similarity index 100% rename from healthchecks/templates/NOTES.txt rename to charts/healthchecks/templates/NOTES.txt diff --git a/healthchecks/templates/_helpers.tpl b/charts/healthchecks/templates/_helpers.tpl similarity index 100% rename from healthchecks/templates/_helpers.tpl rename to charts/healthchecks/templates/_helpers.tpl diff --git a/healthchecks/templates/configmap.yaml b/charts/healthchecks/templates/configmap.yaml similarity index 100% rename from healthchecks/templates/configmap.yaml rename to charts/healthchecks/templates/configmap.yaml diff --git a/healthchecks/templates/deployment.yaml b/charts/healthchecks/templates/deployment.yaml similarity index 100% rename from healthchecks/templates/deployment.yaml rename to charts/healthchecks/templates/deployment.yaml diff --git a/healthchecks/templates/hpa.yaml b/charts/healthchecks/templates/hpa.yaml similarity index 100% rename from healthchecks/templates/hpa.yaml rename to charts/healthchecks/templates/hpa.yaml diff --git a/healthchecks/templates/ingress.yaml b/charts/healthchecks/templates/ingress.yaml similarity index 100% rename from healthchecks/templates/ingress.yaml rename to charts/healthchecks/templates/ingress.yaml diff --git a/healthchecks/templates/service.yaml b/charts/healthchecks/templates/service.yaml similarity index 100% rename from healthchecks/templates/service.yaml rename to charts/healthchecks/templates/service.yaml diff --git a/healthchecks/templates/tests/test-connection.yaml b/charts/healthchecks/templates/tests/test-connection.yaml similarity index 100% rename from healthchecks/templates/tests/test-connection.yaml rename to charts/healthchecks/templates/tests/test-connection.yaml diff --git a/healthchecks/values.yaml b/charts/healthchecks/values.yaml similarity index 100% rename from healthchecks/values.yaml rename to charts/healthchecks/values.yaml diff --git a/charts/n8n-helm/.helmignore b/charts/n8n-helm/.helmignore new file mode 100644 index 0000000..73df330 --- /dev/null +++ b/charts/n8n-helm/.helmignore @@ -0,0 +1,24 @@ +# 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/ +./ \ No newline at end of file diff --git a/charts/n8n-helm/Chart.yaml b/charts/n8n-helm/Chart.yaml new file mode 100644 index 0000000..f8de27b --- /dev/null +++ b/charts/n8n-helm/Chart.yaml @@ -0,0 +1,32 @@ +apiVersion: v2 +name: n8n-helm +description: A Helm chart for n8n on Kubernetes +type: application +metadata: + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.1.3 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +appVersion: 0.18.0 +icon: https://n8n.io/n8n-logo.png +keywords: +- n8n +- automation +- nodemation +- workflow-automatio +maintainers: +- email: pratik@improwised.com + name: pratik-{{ .Release.Name }} +sources: +- https://github.com/n8n-io/n8n +- https://hub.docker.com/_/postgres +dependencies: +- condition: postgres.enabled + name: postgresql + repository: "@bitnami" + version: 9.1.1 diff --git a/charts/n8n-helm/README.md b/charts/n8n-helm/README.md new file mode 100644 index 0000000..4f00cc8 --- /dev/null +++ b/charts/n8n-helm/README.md @@ -0,0 +1,111 @@ +# n8n-helm chart:chart_with_upwards_trend: +---- + +![n8n.io - Workflow Automation](https://raw.githubusercontent.com/n8n-io/n8n/master/assets/n8n-logo.png) + +[n8n](https://n8n.io/) is an extendable workflow automation tool. With a fair-code distribution model, n8n will always have visible source code, be available to self-host, and allow you to add your own custom functions, logic and apps. n8n's node-based approach makes it highly versatile, enabling you to connect anything to everything. this is unofficial helm chart of n8n + +---- +## Prerequisites +- Kubernetes 1.12+ +- Helm 3.0+ +- PV provisioner support in the underlying infrastructure +- ---- +## Installing the Chart + +To install the chart with the release name `myn8n`: +```sh +$ git clone https://github.com/n8n-helm/n8n-helm.git +$ helm install myn8n ./n8n-helm +# to test chart +$ helm test myn8n +``` + +These commands deploy n8n on the Kubernetes cluster in the default configuration. + +> **Tip**: List all releases using `helm list` +---- +## Uninstalling the Chart + +To uninstall/delete the `myn8n` deployment: + +```bash +$ helm delete myn8n +``` + +The command removes all the Kubernetes components associated with the chart and deletes the release. + +> **note**: Deleting the release will delete attached PVC containing n8n encryption key. Please be cautious before doing it. + +---- +## Parameters + +The following tables lists the configurable parameters of the NGINX Open Source chart and their default values. + +| Parameter| Description| Default| +|--------------------------------------------|----------------------------------------------------------------------------------------------|-----------------------------------------------------------| +| `global.imageRegistry` | Global Docker image registry | haha | +| `image.repository` | n8n Image | `n8nio/n8n` | +| `image.restartPolicy` | n8n Image restart policy | `Always` | +| `image.pullPolicy` | n8n Image pull policy | `IfNotPresent` | +| `image.tag` | tag of Image | `latest` | +| `nameOverride` | String to partially override n8n.fullname template with a string (will prepend the release name) | `nil` | +| `fullnameOverride` | String to fully override postgresql.fullname template with a string | `nil` | +| `commonannotations` | Annotations that will added to all the Kubernetes objects | `{}`(evaluated as a template) | +| `atuh.enabled` | Enbale basic authentication | `false` | +| `atuh.n8nAuthUsername`| Basuc Auth username | `nil` | +| `atuh.n8nAuthPass`| Basuc Auth password | `nil` | +| `existingSecret`| Name of an existing secrets | `nil` | +| `networkPolicy.enabled`| creation of NetworkPolicy | `false` | +| `networkPolicy.explicitNamespacesSelector`| Explicitly Namespaces for Network policy | `{}`(evaluated as a template) | +| `service.type` | Kubernetes Service type | `ClusterIP` | +| `service.port` | n8n port | `5678` | +| `service.annotations` | Annotations for n8n service | `{}`(evaluated as a template) | +| `testFramework.enabled` | enable n8n connection test | `true` | +| `persistence.enabled` | Enable persistence using PVC | `true` | +| `persistence.mountPath` | Path to mount the volume at | `/mnt/n8n/.n8n` | +| `persistence.accessModes` | PVC Access Mode for n8n volume | `[ReadWriteOnce]` | +| `persistence.size` | PVC Storage Request for n8n volume | `2Gi` | +| `ingress.enabled` | Switch to create ingress for n8n deployment | `true` | +| `ingress.hostname` | hostname for ingress | `nil` | +| `ingress.tls` | TLS for ingress | `[]`(evaluated as a template) | +| `ingress.tls.hosts[]` | Array of TLS hosts for ingress record | `[]` | +| `ingress.tls.secretName` | TLS secret name | `n8n.local-tls` | +| `ingress.annotations` | Ingress annotations | `{}`(evaluated as a template) | +| `ingress.certManager` | Annotations for cert-manager | `true` | +| `ingress.secrets[]` | Provide own certificates | `nil` | +| `ingress.secrets[].name` | TLS Secret Name | `nil` | +| `ingress.secrets[].key` | TLS Secret Key | `nil` | +| `ingress.secrets[].certificate` | TLS Secret Name Certificate | `nil` | +| `resources` | 'CPU/Memory resource requests/limits' | Memory: `500Mi`, CPU: `500Mi`(evaluated as a template) | +| `schedulerName` | Name of the k8s scheduler (other than default) | `nil` | +| `nodeSelector` | Node labels for pod assignment for n8n deployment | `{}`(evaluated as a template) | +| `affinity` | Affinity labels for pod assignment for n8n deployment | `{}`(evaluated as a template) | +| `tolerations` | Toleration labels for pod assignment for n8n deployment | `[]` (evaluated as a template) | +| `livenessProbe` | livenessProbe for n8n deployment | `{}`(evaluated as a template) | +| `readinessProbe` | readinessProbe for n8n deployment | `{}`(evaluated as a template) | +| `postgresql.testFramework.enabled` | enable postgres connection test | `true` | +| `postgresql.enabled` | (override) enable or disable postgress | `true` | +| `postgresql.postgresqlUsername` | (override) Postgresql default username | `nodemation` | +| `postgresql.postgresqlDatabase` | (override) Postgresql default database | `nodemation` | +| `postgresql.postgresqlPassword` | (override) Postgresql default password for username | `nodemation` | + + +Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example, + +```bash +$ helm install myn8n \ + --set imagePullPolicy=Always \ + ./n8n-helm +``` + +The above command sets the `imagePullPolicy` to `Always`. + +Alternatively, a YAML file that specifies the values for the parameters can be provided while installing the chart. For example, + +```bash +$ helm install myn8n -f values.yaml ./n8n-helm +``` + +> **Tip**: You can use the default [values.yaml](values.yaml) or override your own values.yaml +---- \ No newline at end of file diff --git a/charts/n8n-helm/templates/NOTES.txt b/charts/n8n-helm/templates/NOTES.txt new file mode 100644 index 0000000..ff7016c --- /dev/null +++ b/charts/n8n-helm/templates/NOTES.txt @@ -0,0 +1,4 @@ + +1. Wait for 5 second in order to n8n discover and connect to postgress + +2. n8n dashboard URL is http://localhost:5678 diff --git a/charts/n8n-helm/templates/_helpers.tpl b/charts/n8n-helm/templates/_helpers.tpl new file mode 100644 index 0000000..348c058 --- /dev/null +++ b/charts/n8n-helm/templates/_helpers.tpl @@ -0,0 +1,115 @@ +{{- define "n8n-helm.common.labels.standard" -}} +app.kubernetes.io/name: {{ default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +helm.sh/chart: {{ printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +app.kubernetes.io/instance: {{ .Release.Name }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +{{- end -}} + +{{/* +Labels to use on deploy.spec.selector.matchLabels and svc.spec.selector +*/}} +{{- define "n8n-helm.common.labels.matchLabels" -}} +app.kubernetes.io/name: {{ default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end -}} + + +{{/* +Expand the name of the chart. +*/}} +{{- define "n8n-helm.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 "n8n-helm.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 "n8n-helm.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + + +{{/* +Namespace +*/}} +{{- define "n8n-helm.namespace" -}} +{{- default "default" .Values.namespace }} +{{- end }} + + +{{/* +DB Hostname +*/}} +{{- define "n8n-helm.dbhost" -}} +{{ .Release.Name }}-postgresql.{{ .Release.Namespace }}.svc.cluster.local +{{- end }} + + +{{/* +Return the proper Storage Class +*/}} +{{- define "n8n-helm.storageClass" -}} +{{- if .Values.persistence.storageClass -}} + {{- if (eq "-" .Values.persistence.storageClass) -}} +{{- printf "storageClassName: \"\"" -}} + {{- else }} +{{- printf "storageClassName: %s" .Values.persistence.storageClass -}} + {{- end -}} +{{- end -}} +{{- end -}} + +{{/* +Get the password secret. +*/}} +{{- define "n8n-helm.secretName" -}} +{{- if .Values.existingSecret }} +{{- printf "%s" (tpl .Values.existingSecret $) -}} +{{- else -}} +{{- printf "%s-secrets" (include "n8n-helm.fullname" .) -}} +{{- end -}} +{{- end -}} + +{{/* +Renders a value that contains template. +Usage: +{{ include "n8n-hem.tplValue" (dict "value" .Values.path.to.the.Value "context" $) }} +*/}} +{{- define "n8n-hem.tplValue" -}} + {{- if typeIs "string" .value }} + {{- tpl .value .context }} + {{- else }} + {{- tpl (.value | toYaml) .context }} + {{- end }} +{{- end -}} + +{{/* +Return the appropriate apiVersion for networkpolicy. +*/}} +{{- define "n8n-helm.networkPolicy.apiVersion" -}} +{{- if semverCompare ">=1.4-0, <1.7-0" .Capabilities.KubeVersion.GitVersion -}} +"extensions/v1beta1" +{{- else if semverCompare "^1.7-0" .Capabilities.KubeVersion.GitVersion -}} +"networking.k8s.io/v1" +{{- end -}} +{{- end -}} \ No newline at end of file diff --git a/charts/n8n-helm/templates/configs.yaml b/charts/n8n-helm/templates/configs.yaml new file mode 100644 index 0000000..213e4fa --- /dev/null +++ b/charts/n8n-helm/templates/configs.yaml @@ -0,0 +1,17 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ template "n8n-helm.fullname" . }}-config + labels: + {{- include "n8n-helm.common.labels.standard" . | nindent 4 }} + app: {{ template "n8n-helm.fullname" . }} +data: + DB_TYPE: postgresdb + DB_POSTGRESDB_DATABASE: {{ default "postgres" .Values.postgresql.postgresqlDatabase | quote }} + DB_POSTGRESDB_HOST: {{ template "n8n-helm.dbhost" . }} + DB_POSTGRESDB_PORT: {{ .Values.postgresql.service.port | quote }} + DB_POSTGRESDB_USER: {{ default "postgres" .Values.postgresql.postgresqlUsername | quote }} + {{- if .Values.auth.enable }} + N8N_BASIC_AUTH_ACTIVE: "true" + N8N_BASIC_AUTH_USER: {{ default "nodemation" .Values.auth.n8nAuthUsername | quote }} + {{- end }} \ No newline at end of file diff --git a/charts/n8n-helm/templates/deployment.yaml b/charts/n8n-helm/templates/deployment.yaml new file mode 100644 index 0000000..034ca91 --- /dev/null +++ b/charts/n8n-helm/templates/deployment.yaml @@ -0,0 +1,87 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ template "n8n-helm.fullname" . }}-deployment + labels: + {{- include "n8n-helm.common.labels.standard" . | nindent 4 }} + app: {{ template "n8n-helm.fullname" . }} +spec: + replicas: {{ default "1" .Values.replicaCount }} + selector: + matchLabels: {{- include "n8n-helm.common.labels.matchLabels" . | nindent 6 }} + app: {{ template "n8n-helm.fullname" . }} + template: + metadata: + labels: + {{- include "n8n-helm.common.labels.standard" . | nindent 8 }} + app: {{ template "n8n-helm.fullname" . }} + annotations: + {{- if .Values.commonannotations }} + {{- range $key, $value := .Values.commonannotations }} + {{ $key }}: {{ $value | quote }} + {{- end }} + {{- end }} + spec: + {{- if .Values.schedulerName }} + schedulerName: "{{ .Values.schedulerName }}" + {{- end }} + {{- if .Values.nodeSelector }} + nodeSelector: {{- toYaml .Values.nodeSelector | nindent 8 }} + {{- end }} + {{- if .Values.affinity }} + affinity: {{- toYaml .Values.affinity | nindent 8 }} + {{- end }} + {{- if .Values.tolerations }} + tolerations: {{- toYaml .Values.tolerations | nindent 8 }} + {{- end }} + restartPolicy: {{ .Values.image.restartPolicy }} + containers: + - name: {{ template "n8n-helm.fullname" . }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + {{- if .Values.resources }} + resources: {{- toYaml .Values.resources | nindent 12 }} + {{- end }} + {{- if or .Values.livenessProbe .Values.readinessProbe }} + ports: + - name: http + containerPort: 5678 + {{- end }} + {{- if .Values.livenessProbe }} + livenessProbe: {{- toYaml .Values.livenessProbe | nindent 12 }} + {{- end }} + {{- if .Values.readinessProbe }} + readinessProbe: {{- toYaml .Values.readinessProbe | nindent 12 }} + {{- end }} + command: ["/bin/sh"] + args: ["-c", "sleep 20; n8n start"] + env: + {{- if .Values.auth.enable }} + - name: N8N_BASIC_AUTH_PASSWORD + valueFrom: + secretKeyRef: + name: {{ template "n8n-helm.secretName" . }} + key: n8nAuthPass + {{- end }} + {{- if .Values.postgresql.enabled }} + - name: DB_POSTGRESDB_PASSWORD + valueFrom: + secretKeyRef: + name: {{ template "n8n-helm.secretName" . }} + key: postgresqlDbPass + {{- end }} + envFrom: + - configMapRef: + name: {{ template "n8n-helm.fullname" . }}-config + ports: + - name: {{ template "n8n-helm.fullname" . }} + containerPort: {{ .Values.service.port }} +{{- if .Values.persistence.enabled }} + volumeMounts: + - name: {{ include "n8n-helm.fullname" . }}-data + mountPath: /root/.n8n + volumes: + - name: {{ include "n8n-helm.fullname" . }}-data + persistentVolumeClaim: + claimName: {{ include "n8n-helm.fullname" . }}-data +{{- end }} \ No newline at end of file diff --git a/charts/n8n-helm/templates/ingress.yaml b/charts/n8n-helm/templates/ingress.yaml new file mode 100644 index 0000000..f9aa260 --- /dev/null +++ b/charts/n8n-helm/templates/ingress.yaml @@ -0,0 +1,54 @@ +{{- if .Values.ingress.enabled }} +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: {{ template "n8n-helm.fullname" . }}-ingress + labels: + {{- include "n8n-helm.common.labels.standard" . | nindent 4 }} + annotations: + {{- if .Values.ingress.tls }} + ingress.kubernetes.io/secure-backends: "true" + {{- if .Values.ingress.certManager }} + kubernetes.io/tls-acme: "true" + {{- end }} + {{- end }} + {{- range $key, $value := .Values.ingress.annotations }} + {{ $key }}: {{ $value | quote }} + {{- end }} + {{- if .Values.commonannotations }} + {{- range $key, $value := .Values.commonannotations }} + {{ $key }}: {{ $value | quote }} + {{- end }} + {{- end }} +spec: + rules: + {{- if .Values.ingress.hostname }} + - host: {{ .Values.ingress.hostname }} + http: + paths: + - path: / + backend: + serviceName: "{{ template "n8n-helm.fullname" . }}-service" + servicePort: {{ .Values.service.port }} + {{- else }} + - http: + paths: + - path: / + backend: + serviceName: "{{ template "n8n-helm.fullname" . }}-service" + servicePort: {{ .Values.service.port }} + {{- end }} + {{- range .Values.ingress.hosts }} + - host: {{ .name }} + http: + paths: + - path: {{ default "/" .path }} + backend: + serviceName: "{{ template "n8n-helm.fullname" . }}-service" + servicePort: {{ $.Values.service.port }} + {{- end }} + {{- if .Values.ingress.tls }} + tls: +{{ toYaml .Values.ingress.tls | indent 4 }} + {{- end }} +{{- end }} \ No newline at end of file diff --git a/charts/n8n-helm/templates/networkpolicy.yaml b/charts/n8n-helm/templates/networkpolicy.yaml new file mode 100644 index 0000000..8b85eee --- /dev/null +++ b/charts/n8n-helm/templates/networkpolicy.yaml @@ -0,0 +1,44 @@ +{{- if .Values.networkPolicy.enabled }} +kind: NetworkPolicy +apiVersion: {{ template "n8n-helm.networkPolicy.apiVersion" . }} +metadata: + name: {{ template "n8n-helm.fullname" . }} + labels: + {{- include "n8n-helm.common.labels.standard" . | nindent 4 }} + annotations: + {{- if .Values.commonannotations }} + {{- range $key, $value := .Values.commonannotations }} + {{ $key }}: {{ $value | quote }} + {{- end }} + {{- end }} +spec: + podSelector: + matchLabels: + {{- include "n8n-helm.common.labels.matchLabels" . | nindent 6 }} + ingress: + - ports: + - port: 5678 + {{- if not .Values.networkPolicy.allowExternal }} + from: + - podSelector: + matchLabels: + {{- include "n8n-helm.common.labels.matchLabels" . | nindent 12 }} + {{- if .Values.networkPolicy.explicitNamespacesSelector }} + namespaceSelector: +{{ toYaml .Values.networkPolicy.explicitNamespacesSelector | indent 12 }} + {{- end }} + {{- end }} + egress: + - ports: + - port: 5678 + {{- if not .Values.networkPolicy.allowExternal }} + to: + - podSelector: + matchLabels: + {{- include "n8n-helm.common.labels.matchLabels" . | nindent 12 }} + {{- if .Values.networkPolicy.explicitNamespacesSelector }} + namespaceSelector: +{{ toYaml .Values.networkPolicy.explicitNamespacesSelector | indent 12 }} + {{- end }} + {{- end }} +{{- end }} \ No newline at end of file diff --git a/charts/n8n-helm/templates/pvc.yaml b/charts/n8n-helm/templates/pvc.yaml new file mode 100644 index 0000000..1d3374d --- /dev/null +++ b/charts/n8n-helm/templates/pvc.yaml @@ -0,0 +1,17 @@ +{{- if .Values.persistence.enabled }} +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: {{ include "n8n-helm.fullname" . }}-data + labels: + {{- include "n8n-helm.common.labels.standard" . | nindent 4 }} +spec: + {{ include "n8n-helm.storageClass" . }} + accessModes: + {{- range .Values.persistence.accessModes }} + - {{ . | quote }} + {{- end }} + resources: + requests: + storage: {{ .Values.persistence.size | quote }} +{{- end }} \ No newline at end of file diff --git a/charts/n8n-helm/templates/secrets.yaml b/charts/n8n-helm/templates/secrets.yaml new file mode 100644 index 0000000..6e5e928 --- /dev/null +++ b/charts/n8n-helm/templates/secrets.yaml @@ -0,0 +1,18 @@ +{{- if not .Values.existingSecret }} +apiVersion: v1 +kind: Secret +metadata: + name: {{ template "n8n-helm.fullname" . }}-secrets + labels: + {{- include "n8n-helm.common.labels.standard" . | nindent 4 }} + app: {{ template "n8n-helm.fullname" . }} +type: Opaque +data: + #DB_POSTGRESDB_PASSWORD + postgresqlDbPass: {{ .Values.postgresql.postgresqlPassword | b64enc | quote }} + + {{- if .Values.auth.enabled }} + #N8N_BASIC_AUTH_PASSWORD + n8nAuthPass: {{ default "nodemation" .Values.auth.n8nAuthPass | b64enc | quote }} + {{- end -}} +{{- end }} \ No newline at end of file diff --git a/charts/n8n-helm/templates/service.yaml b/charts/n8n-helm/templates/service.yaml new file mode 100644 index 0000000..023878f --- /dev/null +++ b/charts/n8n-helm/templates/service.yaml @@ -0,0 +1,23 @@ +kind: Service +apiVersion: v1 +metadata: + name: {{ template "n8n-helm.fullname" . }}-service + labels: + {{- include "n8n-helm.common.labels.standard" . | nindent 4 }} + app: {{ template "n8n-helm.fullname" . }} + annotations: + {{- if .Values.service.annotations }} + {{- include "n8n-hem.tplValue" ( dict "value" .Values.service.annotations "context" $) | nindent 4 }} + {{- end }} + {{- if .Values.commonannotations }} + {{- range $key, $value := .Values.commonannotations }} + {{ $key }}: {{ $value | quote }} + {{- end }} + {{- end }} +spec: + selector: {{- include "n8n-helm.common.labels.matchLabels" . | nindent 4 }} + app: {{ template "n8n-helm.fullname" . }} + ports: + - name: {{ template "n8n-helm.fullname" . }} + port: {{ default "5678" .Values.service.port }} + targetPort: {{ default "5678" .Values.service.port }} \ No newline at end of file diff --git a/charts/n8n-helm/templates/tests/test-n8n.yaml b/charts/n8n-helm/templates/tests/test-n8n.yaml new file mode 100644 index 0000000..7d69fcd --- /dev/null +++ b/charts/n8n-helm/templates/tests/test-n8n.yaml @@ -0,0 +1,21 @@ +{{- if .Values.testFramework.enabled }} +apiVersion: v1 +kind: Pod +metadata: + name: n8n-working-test + annotations: + "helm.sh/hook": test-success +spec: + containers: + - name: n8n-working-test + image: "alpine" + imagePullPolicy: {{ .Values.image.pullPolicy }} + env: + - name: N8N_HOST + value: {{ template "n8n-helm.fullname" . }}-service.default.svc.cluster.local:{{ .Values.service.port }} + command: + - /bin/sh + - -ec + - sleep 10; apk update; apk add curl; curl -m 10 -s -o /dev/null -I -w "%{http_code}" $N8N_HOST + restartPolicy: Never +{{- end }} \ No newline at end of file diff --git a/charts/n8n-helm/templates/tests/test-postgres-connection.yaml b/charts/n8n-helm/templates/tests/test-postgres-connection.yaml new file mode 100644 index 0000000..dee278d --- /dev/null +++ b/charts/n8n-helm/templates/tests/test-postgres-connection.yaml @@ -0,0 +1,29 @@ +{{- if .Values.postgresql.testFramework.enabled }} +apiVersion: v1 +kind: Pod +metadata: + name: {{ template "postgresql.fullname" . }}-connection-test + annotations: + "helm.sh/hook": test-success +spec: + containers: + - name: {{ template "postgresql.fullname" . }}-connection-test + image: "{{ .Values.postgresql.image.repository }}:{{ .Values.postgresql.image.tag }}" + imagePullPolicy: {{ .Values.postgresql.image.pullPolicy }} + env: + - name: POSTGRES_DB + value: {{ .Values.postgresql.postgresqlDatabase | quote }} + - name: POSTGRES_USER + value: {{ .Values.postgresql.postgresqlUsername | quote }} + - name: POSTGRES_PASS + value: {{ .Values.postgresql.postgresqlPassword | quote }} + - name: POSTGRES_PORT + value: {{ .Values.postgresql.service.port | quote }} + - name: POSTGRES_HOST + value: {{ template "n8n-helm.dbhost" . }} + command: + - /bin/bash + - -ec + - PGPASSWORD=$POSTGRES_PASS psql -h $POSTGRES_HOST -p $POSTGRES_PORT -U $POSTGRES_USER -d $POSTGRES_DB + restartPolicy: Never +{{- end }} diff --git a/charts/n8n-helm/templates/tls-secrets.yaml b/charts/n8n-helm/templates/tls-secrets.yaml new file mode 100644 index 0000000..24617b2 --- /dev/null +++ b/charts/n8n-helm/templates/tls-secrets.yaml @@ -0,0 +1,15 @@ +{{- if .Values.ingress.enabled }} +{{- range .Values.ingress.secrets }} +apiVersion: v1 +kind: Secret +metadata: + name: {{ .name }} + labels: + {{- include "n8n-helm.common.labels.standard" . | nindent 4 }} +type: kubernetes.io/tls +data: + tls.crt: {{ .certificate | b64enc }} + tls.key: {{ .key | b64enc }} +--- +{{- end }} +{{- end }} diff --git a/charts/n8n-helm/values.yaml b/charts/n8n-helm/values.yaml new file mode 100644 index 0000000..6eec94a --- /dev/null +++ b/charts/n8n-helm/values.yaml @@ -0,0 +1,193 @@ +# Default values for n8n-helm. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +## String to partially override n8n-helm.fullname template (will maintain the release name) +## +nameOverride: "" + +## common annotations +commonannotations: {} + +## String to fully override n8n-helm.fullname template +## +fullnameOverride: "" + +image: + repository: n8nio/n8n + restartPolicy: Always + tag: "latest" + ## Specify a imagePullPolicy + ## Defaults set to 'IfNotPresent' + ## ref: http://kubernetes.io/docs/user-guide/images/#pre-pulling-images + ## + pullPolicy: IfNotPresent + + +auth: + # enable the n8n basic auth + enabled: false + + ## Basic Auth username + ## Defaults to 'nodemation' if not set + #n8nAuthUsername: nodemation + + ## Basic Auth password + ## Defaults to 'nodemation' if not set + #n8nAuthPass: nodemation + +## n8n password using existing secret. which includes n8nAuthPass and +## postgresqlDbPass as key for the respective value +#existingSecret: myn8n-secrets + +networkPolicy: + ## Enable creation of NetworkPolicy resources. Only Ingress traffic is filtered for now. + ## + enabled: false + + ## if explicitNamespacesSelector is missing or set to {}, only client Pods that are in the networkPolicy's namespace + ## and that match other criteria, the ones that have the good label, can reach the DB. + ## But sometimes, we want the DB to be accessible to clients from other namespaces, in this case, we can use this + ## LabelSelector to select these namespaces, note that the networkPolicy's namespace should also be explicitly added. + ## + ## Example: + ## explicitNamespacesSelector: + ## matchLabels: + ## role: frontend + ## matchExpressions: + ## - {key: role, operator: In, values: [frontend]} + explicitNamespacesSelector: {} + +service: + ## Kubernetes service type + type: ClusterIP + ## n8n port + port: 5678 + ## add extra annotation for service + annotations: {} + +testFramework: + ## Set to true to enable testing of n8n + enabled: true + +persistence: + enabled: true + ## A manually managed Persistent Volume and Claim + ## The path the volume will be mounted at, useful when using different + ## + mountPath: /mnt/n8n/.n8n + + ##Storage class as per your provider + #storageClass: "-" + accessModes: + - ReadWriteOnce + size: 2Gi + + +ingress: + ## Set to true to enable ingress + enabled: true + + ## When the ingress is enabled, a host pointing to this will be created if hostname is set. Default it will point to localhost:80 + #hostname: n8n.local.com + + # If tls is set, annotation ingress.kubernetes.io/secure-backends: "true" will automatically be set + ## The tls configuration for the ingress + ## see: https://kubernetes.io/docs/concepts/services-networking/ingress/#tls + ## Uncomment below to enable tls / https for let's encrypt / cert-manager + ## Set this to true in order to enable TLS on the ingress record + ## A side effect of this will be that the backend n8n service will be connected at port 443 + #tls: + #- hosts: + # - n8n.local + # secretName: n8n.local-tls + + ## Ingress annotations done as key:value pairs + ## For a full list of possible ingress annotations, please see + ## ref: https://github.com/kubernetes/ingress-nginx/blob/master/docs/user-guide/nginx-configuration/annotations.md + + annotations: {} + + ## Set this to true in order to add the corresponding annotations for cert-manager. validate that tls is set + #certManager: true + + secrets: + ## If you're providing your own certificates, please use this to add the certificates as secrets + ## key and certificate should start with -----BEGIN CERTIFICATE----- or + ## -----BEGIN RSA PRIVATE KEY----- + ## + ## name should line up with a tlsSecret set further up + ## If you're using cert-manager, this is unneeded, as it will create the secret for you if it is not set + ## + ## It is also possible to create and manage the certificates outside of this helm chart + ## Please see README.md for more information + # - name: n8n.local-tls + # key: + # certificate: + +## Configure resource requests and limits +## ref: http://kubernetes.io/docs/user-guide/compute-resources/ +## +resources: + requests: + memory: "500Mi" + cpu: "500m" + limits: + memory: "500Mi" + cpu: "500m" + +## Use an alternate scheduler, e.g. "stork". +## ref: https://kubernetes.io/docs/tasks/administer-cluster/configure-multiple-schedulers/ +## +# schedulerName: +## +## n8n parameters +## +## Node, affinity, tolerations, and priorityclass settings for pod assignment +## ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#nodeselector +## ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity +## ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#taints-and-tolerations-beta-feature +## ref: https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption +nodeSelector: {} +affinity: {} +tolerations: [] + +## Configure extra options for liveness and readiness probes +## This is http get liveness and readiness probes +## ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/#configure-probes) + +#livenessProbe: +# httpGet: +# path: / +# port: 5678 +# initialDelaySeconds: 20 +# timeoutSeconds: 10 +# periodSeconds: 5 +# failureThreshold: 2 +# +#readinessProbe: +# httpGet: +# path: / +# port: 5678 +# initialDelaySeconds: 20 +# timeoutSeconds: 10 +# periodSeconds: 5 +# failureThreshold: 2 + +postgresql: + ## enable for testing postgresql connection + testFramework: + enabled: true + ## by default postgress is enable, Whether to deploy a postgress server to use database to store workflows set enables as per your requirements. + enabled: true + #Below are overriden values for postgres db + ## PostgreSQL admin password (used when `postgresqlUsername` is not `postgres`) + #postgresqlPostgresPassword: nodemation + #n8n will connect to postgres using below username if not set then default 'postgres' + postgresqlUsername: postgres + #n8n will connect to below postgres databse if not set then default 'postgres' + postgresqlDatabase: nodemation + #n8n will connect to postgres using below password if not set then default 'postgres' + postgresqlPassword: nodemation \ No newline at end of file