commit fd88e264626c962013297ff437b3a152f409af65 Author: Konstantin Grachev Date: Tue Nov 15 21:04:45 2022 +0300 init diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..d243b55 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,50 @@ +--- +kind: pipeline +type: docker +name: default + +trigger: + event: + - push + - tag + +steps: + - name: lint + image: cr.grachevko.ru/docker.io/alpine/helm:latest + pull: always + commands: + - helm lint . + + - name: version + image: cr.grachevko.ru/docker.io/mikefarah/yq:latest + pull: always + user: root + commands: + - yq -i '.version = "'$DRONE_TAG'"' Chart.yaml + - cat Chart.yaml + depends_on: + - lint + when: + event: + - tag + + - name: release + image: cr.grachevko.ru/docker.io/alpine/helm:latest + pull: always + commands: + - helm dependency build + - helm plugin install https://github.com/chartmuseum/helm-push + - helm repo add $HELM_REPO_NAME $HELM_REPO_REGISTRY/$HELM_REPO_NAME --username $HELM_REPO_USERNAME --password $HELM_REPO_PASSWORD + - helm cm-push . $HELM_REPO_REGISTRY/$HELM_REPO_NAME + environment: + HELM_REPO_NAME: n8n + HELM_REPO_REGISTRY: https://harbor.grachevko.ru/chartrepo + HELM_REPO_USERNAME: + from_secret: HELM_REPO_USERNAME + HELM_REPO_PASSWORD: + from_secret: HELM_REPO_PASSWORD + depends_on: + - version + when: + event: + - tag diff --git a/.helmignore b/.helmignore new file mode 100644 index 0000000..0cfe4ae --- /dev/null +++ b/.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/ +*.tgz diff --git a/Chart.yaml b/Chart.yaml new file mode 100644 index 0000000..684cc3f --- /dev/null +++ b/Chart.yaml @@ -0,0 +1,7 @@ +apiVersion: v2 +name: n8n +description: A Helm chart for Kubernetes +type: application +version: 0.0.1 +appVersion: v0.202.1 +icon: https://github.com/n8n-io/n8n/raw/master/assets/n8n-logo.png diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..99e41dc --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2022 Konstantin Grachev + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..7214cc0 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# n8n-chart diff --git a/templates/NOTES.txt b/templates/NOTES.txt new file mode 100644 index 0000000..796df08 --- /dev/null +++ b/templates/NOTES.txt @@ -0,0 +1,22 @@ +1. Get the application URL by running these commands: +{{- if .Values.n8n.ingress.enabled }} +{{- range $host := .Values.n8n.ingress.hosts }} + {{- range .paths }} + http{{ if $.Values.n8n.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.n8n.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "n8n.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.n8n.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 --namespace {{ .Release.Namespace }} svc -w {{ include "n8n.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "n8n.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.n8n.service.port }} +{{- else if contains "ClusterIP" .Values.n8n.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "n8n.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT +{{- end }} diff --git a/templates/_helpers.tpl b/templates/_helpers.tpl new file mode 100644 index 0000000..00a6963 --- /dev/null +++ b/templates/_helpers.tpl @@ -0,0 +1,51 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "n8n.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.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.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "n8n.labels" -}} +helm.sh/chart: {{ include "n8n.chart" . }} +{{ include "n8n.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "n8n.selectorLabels" -}} +app.kubernetes.io/name: {{ include "n8n.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} diff --git a/templates/config.yaml b/templates/config.yaml new file mode 100644 index 0000000..0462f51 --- /dev/null +++ b/templates/config.yaml @@ -0,0 +1,19 @@ +{{- if not .Values.existingSecret }} +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "n8n.fullname" . }} + labels: + {{- include "n8n.labels" . | nindent 4 }} +type: Opaque +data: + NODE_ENV: {{ .Values.config.node_env | quote }} + WEBHOOK_URL: {{ .Values.config.webhook_url | quote }} + EXECUTIONS_PROCESS: {{ .Values.config.executions.process | quote }} + GENERIC_TIMEZONE: {{ .Values.config.timezone | quote }} + EXECUTIONS_DATA_PRUNE: {{ .Values.config.executions.data.prune | quote }} + EXECUTIONS_DATA_MAX_AGE: {{ .Values.config.executions.data.max_age | quote }} + N8N_DIAGNOSTICS_ENABLED: {{ .Values.config.executions.data.max_age | quote }} + NODE_FUNCTION_ALLOW_BUILTIN: {{ .Values.config.node.function.allow.builtin | quote }} + NODE_FUNCTION_ALLOW_EXTERNAL: {{ .Values.config.node.function.allow.external | quote }} +{{- end }} diff --git a/templates/n8n-deployment.yaml b/templates/n8n-deployment.yaml new file mode 100644 index 0000000..6374e3b --- /dev/null +++ b/templates/n8n-deployment.yaml @@ -0,0 +1,66 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "n8n.fullname" . }} + labels: + {{- include "n8n.labels" . | nindent 4 }} +spec: + replicas: 1 + selector: + matchLabels: + {{- include "n8n.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.n8n.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "n8n.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.n8n.image.pullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + securityContext: + {{- toYaml .Values.n8n.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.n8n.securityContext | nindent 12 }} + image: "{{ .Values.n8n.image.registry }}/{{ .Values.n8n.image.repository }}:{{ .Values.n8n.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.n8n.image.pullPolicy }} + envFrom: + - configMapRef: + - name: {{ include "n8n.fullname" . }} + envFrom: + {{- if .Values.n8n.extraEnvVarsSecret }} + - secretRef: + name: {{ .Values.n8n.extraEnvVarsSecret }} + {{- end }} + ports: + - name: http + containerPort: 5678 + protocol: TCP + livenessProbe: + httpGet: + path: /healthz + port: http + readinessProbe: + httpGet: + path: /healthz + port: http + resources: + {{- toYaml .Values.n8n.resources | nindent 12 }} + {{- with .Values.n8n.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.n8n.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.n8n.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/templates/n8n-ingress.yaml b/templates/n8n-ingress.yaml new file mode 100644 index 0000000..5330c0a --- /dev/null +++ b/templates/n8n-ingress.yaml @@ -0,0 +1,59 @@ +{{- if .Values.n8n.ingress.enabled -}} +{{- $fullName := include "n8n.fullname" . -}} +{{- $svcPort := .Values.n8n.service.port -}} +{{- if and .Values.n8n.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.n8n.ingress.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.n8n.ingress.annotations "kubernetes.io/ingress.class" .Values.n8n.ingress.className}} + {{- end }} +{{- end }} +{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1 +{{- else 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 "n8n.labels" . | nindent 4 }} + {{- with .Values.n8n.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if and .Values.n8n.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.n8n.ingress.className }} + {{- end }} + {{- if .Values.n8n.ingress.tls }} + tls: + {{- range .Values.n8n.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.n8n.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + pathType: {{ default "ImplementationSpecific" .pathType }} + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{- else }} + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- end }} +{{- end }} diff --git a/templates/n8n-service.yaml b/templates/n8n-service.yaml new file mode 100644 index 0000000..9e67696 --- /dev/null +++ b/templates/n8n-service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "n8n.fullname" . }} + labels: + {{- include "n8n.labels" . | nindent 4 }} +spec: + type: {{ .Values.n8n.service.type }} + ports: + - port: {{ .Values.n8n.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "n8n.selectorLabels" . | nindent 4 }} diff --git a/templates/secrets.yaml b/templates/secrets.yaml new file mode 100644 index 0000000..7a31e53 --- /dev/null +++ b/templates/secrets.yaml @@ -0,0 +1,37 @@ +{{- if not .Values.existingSecret }} +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "n8n.fullname" . }} + labels: + {{- include "n8n.labels" . | nindent 4 }} +type: Opaque +data: + {{- if .Values.config.encryption_key }} + N8N_ENCRYPTION_KEY: {{ default "" .Values.config.encryption_key | b64enc | quote }} + {{- else }} + N8N_ENCRYPTION_KEY: {{ randAlphaNum 10 | b64enc | quote }} + {{- end }} + + {{- if .Values.config.db_type }} + DB_TYPE: {{ .Values.config.db_type | b64enc | quote }} + {{- end }} + {{- if .Values.config.postgres.database }} + DB_POSTGRESDB_DATABASE: {{ .Values.config.postgres.database | b64enc | quote }} + {{- end }} + {{- if .Values.config.postgres.host }} + DB_POSTGRESDB_HOST: {{ .Values.config.postgres.host | b64enc | quote }} + {{- end }} + {{- if .Values.config.postgres.port }} + DB_POSTGRESDB_PORT: {{ .Values.config.postgres.port | b64enc | quote }} + {{- end }} + {{- if .Values.config.postgres.user }} + DB_POSTGRESDB_USER: {{ .Values.config.postgres.user | b64enc | quote }} + {{- end }} + {{- if .Values.config.postgres.schema }} + DB_POSTGRESDB_SCHEMA: {{ .Values.config.postgres.schema | b64enc | quote }} + {{- end }} + {{- if .Values.config.postgres.password }} + DB_POSTGRESDB_PASSWORD: {{ .Values.config.postgres.password | b64enc | quote }} + {{- end }} +{{- end }} diff --git a/templates/tests/test-connection.yaml b/templates/tests/test-connection.yaml new file mode 100644 index 0000000..ff63ddb --- /dev/null +++ b/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "n8n.fullname" . }}-test-connection" + labels: + {{- include "n8n.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: [ 'wget' ] + args: [ '{{ include "n8n.fullname" . }}:{{ .Values.n8n.service.port }}' ] + restartPolicy: Never diff --git a/templates/webhook-deployment.yaml b/templates/webhook-deployment.yaml new file mode 100644 index 0000000..bb2bfdd --- /dev/null +++ b/templates/webhook-deployment.yaml @@ -0,0 +1,68 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "n8n.fullname" . }}-webhook + labels: + {{- include "n8n.labels" . | nindent 4 }} +spec: + {{- if not .Values.webhook.autoscaling.enabled }} + replicas: {{ .Values.webhook.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "n8n.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.webhook.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "n8n.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.webhook.image.pullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + securityContext: + {{- toYaml .Values.webhook.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.webhook.securityContext | nindent 12 }} + image: "{{ .Values.webhook.image.registry }}/{{ .Values.webhook.image.repository }}:{{ .Values.webhook.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.webhook.image.pullPolicy }} + envFrom: + - configMapRef: + - name: {{ include "n8n.fullname" . }} + envFrom: + {{- if .Values.webhook.extraEnvVarsSecret }} + - secretRef: + name: {{ .Values.webhook.extraEnvVarsSecret }} + {{- end }} + ports: + - name: http + containerPort: 5678 + protocol: TCP + livenessProbe: + httpGet: + path: /healthz + port: http + readinessProbe: + httpGet: + path: /healthz + port: http + resources: + {{- toYaml .Values.webhook.resources | nindent 12 }} + {{- with .Values.webhook.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.webhook.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.webhook.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/templates/webhook-ingress.yaml b/templates/webhook-ingress.yaml new file mode 100644 index 0000000..61c9af9 --- /dev/null +++ b/templates/webhook-ingress.yaml @@ -0,0 +1,59 @@ +{{- if .Values.webhook.ingress.enabled -}} +{{- $fullName := include "n8n.fullname" . -}} +{{- $svcPort := .Values.webhook.service.port -}} +{{- if and .Values.webhook.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.webhook.ingress.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.webhook.ingress.annotations "kubernetes.io/ingress.class" .Values.webhook.ingress.className}} + {{- end }} +{{- end }} +{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1 +{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }}-webhook + labels: + {{- include "n8n.labels" . | nindent 4 }} + {{- with .Values.webhook.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if and .Values.webhook.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.webhook.ingress.className }} + {{- end }} + {{- if .Values.webhook.ingress.tls }} + tls: + {{- range .Values.webhook.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.webhook.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + pathType: {{ default "ImplementationSpecific" .pathType }} + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{- else }} + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- end }} +{{- end }} diff --git a/templates/webhook-service.yaml b/templates/webhook-service.yaml new file mode 100644 index 0000000..35142dc --- /dev/null +++ b/templates/webhook-service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "n8n.fullname" . }}-webhook + labels: + {{- include "n8n.labels" . | nindent 4 }} +spec: + type: {{ .Values.webhook.service.type }} + ports: + - port: {{ .Values.webhook.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "n8n.selectorLabels" . | nindent 4 }} diff --git a/templates/worker-deployment.yaml b/templates/worker-deployment.yaml new file mode 100644 index 0000000..0318781 --- /dev/null +++ b/templates/worker-deployment.yaml @@ -0,0 +1,56 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "n8n.fullname" . }}-worker + labels: + {{- include "n8n.labels" . | nindent 4 }} +spec: + {{- if not .Values.worker.autoscaling.enabled }} + replicas: {{ .Values.worker.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "n8n.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.worker.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "n8n.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.worker.image.pullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + securityContext: + {{- toYaml .Values.worker.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.worker.securityContext | nindent 12 }} + image: "{{ .Values.worker.image.registry }}/{{ .Values.worker.image.repository }}:{{ .Values.worker.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.worker.image.pullPolicy }} + envFrom: + - configMapRef: + - name: {{ include "n8n.fullname" . }} + envFrom: + {{- if .Values.worker.extraEnvVarsSecret }} + - secretRef: + name: {{ .Values.worker.extraEnvVarsSecret }} + {{- end }} + resources: + {{- toYaml .Values.worker.resources | nindent 12 }} + {{- with .Values.worker.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.worker.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.worker.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/templates/worker-hpa.yaml b/templates/worker-hpa.yaml new file mode 100644 index 0000000..570040b --- /dev/null +++ b/templates/worker-hpa.yaml @@ -0,0 +1,28 @@ +{{- if .Values.worker.autoscaling.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "n8n.fullname" . }}-worker + labels: + {{- include "n8n.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "n8n.fullname" . }} + minReplicas: {{ .Values.worker.autoscaling.minReplicas }} + maxReplicas: {{ .Values.worker.autoscaling.maxReplicas }} + metrics: + {{- if .Values.worker.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.worker.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.worker.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.worker.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/values.yaml b/values.yaml new file mode 100644 index 0000000..abd2c83 --- /dev/null +++ b/values.yaml @@ -0,0 +1,261 @@ +config: + db_type: postgresdb + postgres: + database: n8n + host: postgres + port: "5432" + user: "" + schema: public + password: "" + encryption_key: "" + timezone: Europe/Moscow + webhook_url: "" + node_env: production + executions: + process: main + data: + prune: 'true' + max_age: 8760 + diagnostics: + enabled: 'false' + node: + function: + allow: + builtin: '*' + external: '*' + +existingSecret: "" + +nameOverride: "" +fullnameOverride: "" + +n8n: + image: + registry: ®istry docker.io + repository: &repository n8nio/n8n + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + pullSecrets: [ ] + + extraEnvVarsSecret: "" + + serviceAccount: + # Specifies whether a service account should be created + create: false + # Annotations to add to the service account + annotations: { } + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + + podAnnotations: { } + + podSecurityContext: { } + # fsGroup: 2000 + + securityContext: { } + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + + service: + type: ClusterIP + port: 80 + + ingress: + enabled: false + className: "" + annotations: { } + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: + - path: / + pathType: ImplementationSpecific + tls: [ ] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + + 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: { } + +webhook: + replicaCount: 1 + + image: + registry: *registry + repository: *repository + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + pullSecrets: [ ] + + extraEnvVarsSecret: "" + + serviceAccount: + # Specifies whether a service account should be created + create: false + # Annotations to add to the service account + annotations: { } + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + + podAnnotations: { } + + podSecurityContext: { } + # fsGroup: 2000 + + securityContext: { } + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + + service: + type: ClusterIP + port: 80 + + ingress: + enabled: false + className: "" + annotations: { } + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: + - path: / + pathType: ImplementationSpecific + tls: [ ] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + + 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 + + autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + + nodeSelector: { } + + tolerations: [ ] + + affinity: { } + +worker: + replicaCount: 1 + + image: + registry: *registry + repository: *repository + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + pullSecrets: [ ] + + extraEnvVarsSecret: "" + + serviceAccount: + # Specifies whether a service account should be created + create: false + # Annotations to add to the service account + annotations: { } + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + + podAnnotations: { } + + podSecurityContext: { } + # fsGroup: 2000 + + securityContext: { } + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + + service: + type: ClusterIP + port: 80 + + ingress: + enabled: false + className: "" + annotations: { } + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: + - path: / + pathType: ImplementationSpecific + tls: [ ] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + + 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 + + autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 2 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + + nodeSelector: { } + + tolerations: [ ] + + affinity: { }