From f886624ce617084dccf29f3607af7e5dd84c3dc0 Mon Sep 17 00:00:00 2001 From: Tobias McNulty Date: Thu, 11 Jan 2024 12:10:58 -0500 Subject: [PATCH] Add Helm chart for ODK Central (#1) --- .gitignore | 3 + charts/odk-central/.helmignore | 23 ++++ charts/odk-central/Chart.lock | 21 ++++ charts/odk-central/Chart.yaml | 52 ++++++++ charts/odk-central/charts/backend/.helmignore | 23 ++++ charts/odk-central/charts/backend/Chart.yaml | 24 ++++ .../charts/backend/templates/NOTES.txt | 22 ++++ .../charts/backend/templates/_helpers.tpl | 62 ++++++++++ .../charts/backend/templates/deployment.yaml | 96 ++++++++++++++ .../charts/backend/templates/hpa.yaml | 32 +++++ .../charts/backend/templates/ingress.yaml | 61 +++++++++ .../charts/backend/templates/secret.yaml | 11 ++ .../charts/backend/templates/service.yaml | 15 +++ .../backend/templates/serviceaccount.yaml | 13 ++ .../templates/tests/test-connection.yaml | 15 +++ charts/odk-central/charts/backend/values.yaml | 103 +++++++++++++++ charts/odk-central/charts/enketo/.helmignore | 23 ++++ charts/odk-central/charts/enketo/Chart.yaml | 24 ++++ .../charts/enketo/templates/NOTES.txt | 22 ++++ .../charts/enketo/templates/_helpers.tpl | 62 ++++++++++ .../charts/enketo/templates/deployment.yaml | 98 +++++++++++++++ .../charts/enketo/templates/hpa.yaml | 32 +++++ .../charts/enketo/templates/ingress.yaml | 61 +++++++++ .../charts/enketo/templates/service.yaml | 15 +++ .../enketo/templates/serviceaccount.yaml | 13 ++ .../templates/tests/test-connection.yaml | 15 +++ charts/odk-central/charts/enketo/values.yaml | 117 ++++++++++++++++++ .../odk-central/charts/frontend/.helmignore | 23 ++++ charts/odk-central/charts/frontend/Chart.yaml | 24 ++++ .../charts/frontend/templates/NOTES.txt | 22 ++++ .../charts/frontend/templates/_helpers.tpl | 62 ++++++++++ .../charts/frontend/templates/deployment.yaml | 80 ++++++++++++ .../charts/frontend/templates/hpa.yaml | 32 +++++ .../charts/frontend/templates/ingress.yaml | 61 +++++++++ .../charts/frontend/templates/secret.yaml | 11 ++ .../charts/frontend/templates/service.yaml | 15 +++ .../frontend/templates/serviceaccount.yaml | 13 ++ .../templates/tests/test-connection.yaml | 15 +++ .../odk-central/charts/frontend/values.yaml | 102 +++++++++++++++ charts/odk-central/charts/pyxform/.helmignore | 23 ++++ charts/odk-central/charts/pyxform/Chart.yaml | 24 ++++ .../charts/pyxform/templates/NOTES.txt | 22 ++++ .../charts/pyxform/templates/_helpers.tpl | 62 ++++++++++ .../charts/pyxform/templates/deployment.yaml | 72 +++++++++++ .../charts/pyxform/templates/hpa.yaml | 32 +++++ .../charts/pyxform/templates/ingress.yaml | 61 +++++++++ .../charts/pyxform/templates/service.yaml | 15 +++ .../pyxform/templates/serviceaccount.yaml | 13 ++ .../templates/tests/test-connection.yaml | 15 +++ charts/odk-central/charts/pyxform/values.yaml | 98 +++++++++++++++ charts/odk-central/templates/NOTES.txt | 22 ++++ charts/odk-central/templates/_helpers.tpl | 62 ++++++++++ charts/odk-central/templates/deployment.yaml | 72 +++++++++++ charts/odk-central/templates/hpa.yaml | 32 +++++ charts/odk-central/templates/ingress.yaml | 61 +++++++++ charts/odk-central/templates/secret.yaml | 10 ++ charts/odk-central/templates/service.yaml | 15 +++ .../odk-central/templates/serviceaccount.yaml | 13 ++ .../templates/tests/test-connection.yaml | 15 +++ charts/odk-central/values.yaml | 81 ++++++++++++ 60 files changed, 2338 insertions(+) create mode 100644 .gitignore create mode 100644 charts/odk-central/.helmignore create mode 100644 charts/odk-central/Chart.lock create mode 100644 charts/odk-central/Chart.yaml create mode 100644 charts/odk-central/charts/backend/.helmignore create mode 100644 charts/odk-central/charts/backend/Chart.yaml create mode 100644 charts/odk-central/charts/backend/templates/NOTES.txt create mode 100644 charts/odk-central/charts/backend/templates/_helpers.tpl create mode 100644 charts/odk-central/charts/backend/templates/deployment.yaml create mode 100644 charts/odk-central/charts/backend/templates/hpa.yaml create mode 100644 charts/odk-central/charts/backend/templates/ingress.yaml create mode 100644 charts/odk-central/charts/backend/templates/secret.yaml create mode 100644 charts/odk-central/charts/backend/templates/service.yaml create mode 100644 charts/odk-central/charts/backend/templates/serviceaccount.yaml create mode 100644 charts/odk-central/charts/backend/templates/tests/test-connection.yaml create mode 100644 charts/odk-central/charts/backend/values.yaml create mode 100644 charts/odk-central/charts/enketo/.helmignore create mode 100644 charts/odk-central/charts/enketo/Chart.yaml create mode 100644 charts/odk-central/charts/enketo/templates/NOTES.txt create mode 100644 charts/odk-central/charts/enketo/templates/_helpers.tpl create mode 100644 charts/odk-central/charts/enketo/templates/deployment.yaml create mode 100644 charts/odk-central/charts/enketo/templates/hpa.yaml create mode 100644 charts/odk-central/charts/enketo/templates/ingress.yaml create mode 100644 charts/odk-central/charts/enketo/templates/service.yaml create mode 100644 charts/odk-central/charts/enketo/templates/serviceaccount.yaml create mode 100644 charts/odk-central/charts/enketo/templates/tests/test-connection.yaml create mode 100644 charts/odk-central/charts/enketo/values.yaml create mode 100644 charts/odk-central/charts/frontend/.helmignore create mode 100644 charts/odk-central/charts/frontend/Chart.yaml create mode 100644 charts/odk-central/charts/frontend/templates/NOTES.txt create mode 100644 charts/odk-central/charts/frontend/templates/_helpers.tpl create mode 100644 charts/odk-central/charts/frontend/templates/deployment.yaml create mode 100644 charts/odk-central/charts/frontend/templates/hpa.yaml create mode 100644 charts/odk-central/charts/frontend/templates/ingress.yaml create mode 100644 charts/odk-central/charts/frontend/templates/secret.yaml create mode 100644 charts/odk-central/charts/frontend/templates/service.yaml create mode 100644 charts/odk-central/charts/frontend/templates/serviceaccount.yaml create mode 100644 charts/odk-central/charts/frontend/templates/tests/test-connection.yaml create mode 100644 charts/odk-central/charts/frontend/values.yaml create mode 100644 charts/odk-central/charts/pyxform/.helmignore create mode 100644 charts/odk-central/charts/pyxform/Chart.yaml create mode 100644 charts/odk-central/charts/pyxform/templates/NOTES.txt create mode 100644 charts/odk-central/charts/pyxform/templates/_helpers.tpl create mode 100644 charts/odk-central/charts/pyxform/templates/deployment.yaml create mode 100644 charts/odk-central/charts/pyxform/templates/hpa.yaml create mode 100644 charts/odk-central/charts/pyxform/templates/ingress.yaml create mode 100644 charts/odk-central/charts/pyxform/templates/service.yaml create mode 100644 charts/odk-central/charts/pyxform/templates/serviceaccount.yaml create mode 100644 charts/odk-central/charts/pyxform/templates/tests/test-connection.yaml create mode 100644 charts/odk-central/charts/pyxform/values.yaml create mode 100644 charts/odk-central/templates/NOTES.txt create mode 100644 charts/odk-central/templates/_helpers.tpl create mode 100644 charts/odk-central/templates/deployment.yaml create mode 100644 charts/odk-central/templates/hpa.yaml create mode 100644 charts/odk-central/templates/ingress.yaml create mode 100644 charts/odk-central/templates/secret.yaml create mode 100644 charts/odk-central/templates/service.yaml create mode 100644 charts/odk-central/templates/serviceaccount.yaml create mode 100644 charts/odk-central/templates/tests/test-connection.yaml create mode 100644 charts/odk-central/values.yaml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..220f13c --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +bin/ +.envrc +charts/*/charts/*.tgz diff --git a/charts/odk-central/.helmignore b/charts/odk-central/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/odk-central/.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/odk-central/Chart.lock b/charts/odk-central/Chart.lock new file mode 100644 index 0000000..9e1d4f2 --- /dev/null +++ b/charts/odk-central/Chart.lock @@ -0,0 +1,21 @@ +dependencies: +- name: redis-ha + repository: https://dandydeveloper.github.io/charts + version: 4.23.0 +- name: redis-ha + repository: https://dandydeveloper.github.io/charts + version: 4.23.0 +- name: enketo + repository: file://charts/enketo + version: 0.1.0 +- name: backend + repository: file://charts/backend + version: 0.1.0 +- name: frontend + repository: file://charts/frontend + version: 0.1.0 +- name: pyxform + repository: file://charts/pyxform + version: 0.1.0 +digest: sha256:49d8d9b862ffb1acf517a7ef65fc87f10fbc8948606761364eda4f692a3dd71c +generated: "2024-01-09T13:52:08.550274-05:00" diff --git a/charts/odk-central/Chart.yaml b/charts/odk-central/Chart.yaml new file mode 100644 index 0000000..66047ee --- /dev/null +++ b/charts/odk-central/Chart.yaml @@ -0,0 +1,52 @@ +apiVersion: v2 +name: odk-central +description: A Helm chart for ODK Central + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# 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.0 + +# 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. +# It is recommended to use it with quotes. +appVersion: "1.16.0" + +dependencies: + - name: redis-ha + repository: https://dandydeveloper.github.io/charts + version: 4.23.0 + alias: enketo-redis-main + condition: enketo-redis-main.enabled + - name: redis-ha + repository: https://dandydeveloper.github.io/charts + version: 4.23.0 + alias: enketo-redis-cache + condition: enketo-redis-cache.enabled + - name: enketo + repository: file://charts/enketo + version: 0.1.0 + condition: enketo.enabled + - name: backend + repository: file://charts/backend + version: 0.1.0 + condition: backend.enabled + - name: frontend + repository: file://charts/frontend + version: 0.1.0 + condition: frontend.enabled + - name: pyxform + repository: file://charts/pyxform + version: 0.1.0 + condition: pyxform.enabled diff --git a/charts/odk-central/charts/backend/.helmignore b/charts/odk-central/charts/backend/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/odk-central/charts/backend/.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/odk-central/charts/backend/Chart.yaml b/charts/odk-central/charts/backend/Chart.yaml new file mode 100644 index 0000000..c700e89 --- /dev/null +++ b/charts/odk-central/charts/backend/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: backend +description: A Helm chart for Kubernetes + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# 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.0 + +# 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. +# It is recommended to use it with quotes. +appVersion: "1.16.0" diff --git a/charts/odk-central/charts/backend/templates/NOTES.txt b/charts/odk-central/charts/backend/templates/NOTES.txt new file mode 100644 index 0000000..2d64531 --- /dev/null +++ b/charts/odk-central/charts/backend/templates/NOTES.txt @@ -0,0 +1,22 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range .paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "backend.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 --namespace {{ .Release.Namespace }} svc -w {{ include "backend.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "backend.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + 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.kubernetes.io/name={{ include "backend.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/charts/odk-central/charts/backend/templates/_helpers.tpl b/charts/odk-central/charts/backend/templates/_helpers.tpl new file mode 100644 index 0000000..471310f --- /dev/null +++ b/charts/odk-central/charts/backend/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "backend.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 "backend.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 "backend.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "backend.labels" -}} +helm.sh/chart: {{ include "backend.chart" . }} +{{ include "backend.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "backend.selectorLabels" -}} +app.kubernetes.io/name: {{ include "backend.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "backend.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "backend.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/charts/odk-central/charts/backend/templates/deployment.yaml b/charts/odk-central/charts/backend/templates/deployment.yaml new file mode 100644 index 0000000..1be9c6c --- /dev/null +++ b/charts/odk-central/charts/backend/templates/deployment.yaml @@ -0,0 +1,96 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "backend.fullname" . }} + labels: + {{- include "backend.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "backend.selectorLabels" . | nindent 6 }} + template: + metadata: + annotations: + checksum/config-enketo: {{ toYaml .Values.global.enketoSecrets | sha256sum }} + checksum/config-service: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }} + {{- with .Values.podAnnotations }} + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "backend.labels" . | nindent 8 }} + {{- with .Values.podLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "backend.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + command: ["wait-for-it"] + args: [ "{{ .Values.environmentVariables.DB_HOST }}:5432", "--", "./start-odk.sh" ] + ports: + - name: http + containerPort: {{ .Values.service.port }} + protocol: TCP + livenessProbe: + exec: + command: + - bash + - -c + - 'STATUS=$(curl --silent --include --request POST --header "Content-Type: application/json" --data-binary "{\"email\": \"email\",\"password\": \"password\"}" --write-out "%{http_code}" --output /dev/null http://localhost:8383/v1/sessions); if [[ "$STATUS" == "401" ]]; then exit 0; else exit 1; fi' + readinessProbe: + exec: + command: + - bash + - -c + - 'STATUS=$(curl --silent --include --request POST --header "Content-Type: application/json" --data-binary "{\"email\": \"email\",\"password\": \"password\"}" --write-out "%{http_code}" --output /dev/null http://localhost:8383/v1/sessions); if [[ "$STATUS" == "401" ]]; then exit 0; else exit 1; fi' + resources: + {{- toYaml .Values.resources | nindent 12 }} + env: + - name: ENKETO_URL + value: '{{ .Values.config.enketoUrl | default (printf "http://%s-enketo:8005" .Release.Name) }}' + - name: PYXFORM_HOST + value: '{{ .Values.config.pyxformHost | default (printf "%s-pyxform" .Release.Name) }}' + - name: PYXFORM_PORT + value: '{{ .Values.config.pyxformPort | default 80 }}' + envFrom: + - secretRef: + name: {{ include "backend.fullname" . }} + volumeMounts: + - name: secret-volume + readOnly: true + mountPath: "/etc/secrets" + {{- with .Values.volumeMounts }} + {{- toYaml . | nindent 12 }} + {{- end }} + volumes: + - name: secret-volume + secret: + secretName: {{ .Values.global.enketoSecretName }} + {{- with .Values.volumes }} + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/charts/odk-central/charts/backend/templates/hpa.yaml b/charts/odk-central/charts/backend/templates/hpa.yaml new file mode 100644 index 0000000..c32d92b --- /dev/null +++ b/charts/odk-central/charts/backend/templates/hpa.yaml @@ -0,0 +1,32 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "backend.fullname" . }} + labels: + {{- include "backend.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "backend.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/charts/odk-central/charts/backend/templates/ingress.yaml b/charts/odk-central/charts/backend/templates/ingress.yaml new file mode 100644 index 0000000..c2a08c2 --- /dev/null +++ b/charts/odk-central/charts/backend/templates/ingress.yaml @@ -0,0 +1,61 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "backend.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.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 "backend.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.ingress.className }} + {{- end }} + {{- 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: {{ .path }} + {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + pathType: {{ .pathType }} + {{- end }} + 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/charts/odk-central/charts/backend/templates/secret.yaml b/charts/odk-central/charts/backend/templates/secret.yaml new file mode 100644 index 0000000..7123dfc --- /dev/null +++ b/charts/odk-central/charts/backend/templates/secret.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "backend.fullname" . }} + labels: + {{- include "backend.labels" . | nindent 4 }} +{{- with .Values.environmentVariables }} +stringData: + {{- toYaml . | nindent 2 }} +{{- end }} +type: Opaque diff --git a/charts/odk-central/charts/backend/templates/service.yaml b/charts/odk-central/charts/backend/templates/service.yaml new file mode 100644 index 0000000..4fb4186 --- /dev/null +++ b/charts/odk-central/charts/backend/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "backend.fullname" . }} + labels: + {{- include "backend.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "backend.selectorLabels" . | nindent 4 }} diff --git a/charts/odk-central/charts/backend/templates/serviceaccount.yaml b/charts/odk-central/charts/backend/templates/serviceaccount.yaml new file mode 100644 index 0000000..0977e16 --- /dev/null +++ b/charts/odk-central/charts/backend/templates/serviceaccount.yaml @@ -0,0 +1,13 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "backend.serviceAccountName" . }} + labels: + {{- include "backend.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +automountServiceAccountToken: {{ .Values.serviceAccount.automount }} +{{- end }} diff --git a/charts/odk-central/charts/backend/templates/tests/test-connection.yaml b/charts/odk-central/charts/backend/templates/tests/test-connection.yaml new file mode 100644 index 0000000..bdbe4eb --- /dev/null +++ b/charts/odk-central/charts/backend/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "backend.fullname" . }}-test-connection" + labels: + {{- include "backend.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "backend.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/charts/odk-central/charts/backend/values.yaml b/charts/odk-central/charts/backend/values.yaml new file mode 100644 index 0000000..711b225 --- /dev/null +++ b/charts/odk-central/charts/backend/values.yaml @@ -0,0 +1,103 @@ +# Default values for backend. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: ghcr.io/caktus/central-service + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: latest + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +config: {} + # enketoUrl: + # pyxformHost: + # pyxformPort: + +serviceAccount: + # Specifies whether a service account should be created + create: true + # Automatically mount a ServiceAccount's API credentials? + automount: true + # 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: {} +podLabels: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: ClusterIP + port: 8383 + +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 + +# Additional volumes on the output Deployment definition. +volumes: [] +# - name: foo +# secret: +# secretName: mysecret +# optional: false + +# Additional volumeMounts on the output Deployment definition. +volumeMounts: [] +# - name: foo +# mountPath: "/etc/foo" +# readOnly: true + +nodeSelector: {} + +tolerations: [] + +affinity: {} diff --git a/charts/odk-central/charts/enketo/.helmignore b/charts/odk-central/charts/enketo/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/odk-central/charts/enketo/.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/odk-central/charts/enketo/Chart.yaml b/charts/odk-central/charts/enketo/Chart.yaml new file mode 100644 index 0000000..3707eb0 --- /dev/null +++ b/charts/odk-central/charts/enketo/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: enketo +description: A Helm chart for Kubernetes + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# 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.0 + +# 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. +# It is recommended to use it with quotes. +appVersion: "1.16.0" diff --git a/charts/odk-central/charts/enketo/templates/NOTES.txt b/charts/odk-central/charts/enketo/templates/NOTES.txt new file mode 100644 index 0000000..4724ec3 --- /dev/null +++ b/charts/odk-central/charts/enketo/templates/NOTES.txt @@ -0,0 +1,22 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range .paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "enketo.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 --namespace {{ .Release.Namespace }} svc -w {{ include "enketo.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "enketo.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + 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.kubernetes.io/name={{ include "enketo.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/charts/odk-central/charts/enketo/templates/_helpers.tpl b/charts/odk-central/charts/enketo/templates/_helpers.tpl new file mode 100644 index 0000000..f4b6fa8 --- /dev/null +++ b/charts/odk-central/charts/enketo/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "enketo.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 "enketo.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 "enketo.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "enketo.labels" -}} +helm.sh/chart: {{ include "enketo.chart" . }} +{{ include "enketo.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "enketo.selectorLabels" -}} +app.kubernetes.io/name: {{ include "enketo.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "enketo.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "enketo.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/charts/odk-central/charts/enketo/templates/deployment.yaml b/charts/odk-central/charts/enketo/templates/deployment.yaml new file mode 100644 index 0000000..0f6816d --- /dev/null +++ b/charts/odk-central/charts/enketo/templates/deployment.yaml @@ -0,0 +1,98 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "enketo.fullname" . }} + labels: + {{- include "enketo.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "enketo.selectorLabels" . | nindent 6 }} + template: + metadata: + annotations: + checksum/config: {{ toYaml .Values.global.enketoSecrets | sha256sum }} + {{- with .Values.podAnnotations }} + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "enketo.labels" . | nindent 8 }} + {{- with .Values.podLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "enketo.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: http + containerPort: {{ .Values.service.port }} + protocol: TCP + livenessProbe: + httpGet: + path: /-/ + port: http + readinessProbe: + httpGet: + path: /-/ + port: http + resources: + {{- toYaml .Values.resources | nindent 12 }} + env: + - name: DOMAIN + value: "{{ .Values.config.centralDomain }}" + - name: SUPPORT_EMAIL + value: "{{ .Values.config.supportEmail }}" + - name: HTTPS_PORT + value: "{{ .Values.config.httpsPort }}" + - name: REDIS_MAIN_HOST + value: '{{ .Values.config.redisMainHost | default (printf "%s-enketo-redis-main" .Release.Name) }}' + - name: REDIS_MAIN_PORT + value: "{{ .Values.config.redisMainPort }}" + - name: REDIS_CACHE_HOST + value: '{{ .Values.config.redisCacheHost | default (printf "%s-enketo-redis-cache" .Release.Name) }}' + - name: REDIS_CACHE_PORT + value: "{{ .Values.config.redisCachePort }}" + {{- if .Values.config.debug }} + - name: DEBUG + value: "enketo*" + {{- end }} + volumeMounts: + - name: secret-volume + readOnly: true + mountPath: "/etc/secrets" + {{- with .Values.volumeMounts }} + {{- toYaml . | nindent 12 }} + {{- end }} + volumes: + - name: secret-volume + secret: + secretName: {{ .Values.global.enketoSecretName }} + {{- with .Values.volumes }} + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/charts/odk-central/charts/enketo/templates/hpa.yaml b/charts/odk-central/charts/enketo/templates/hpa.yaml new file mode 100644 index 0000000..bf0d56f --- /dev/null +++ b/charts/odk-central/charts/enketo/templates/hpa.yaml @@ -0,0 +1,32 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "enketo.fullname" . }} + labels: + {{- include "enketo.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "enketo.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/charts/odk-central/charts/enketo/templates/ingress.yaml b/charts/odk-central/charts/enketo/templates/ingress.yaml new file mode 100644 index 0000000..407d479 --- /dev/null +++ b/charts/odk-central/charts/enketo/templates/ingress.yaml @@ -0,0 +1,61 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "enketo.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.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 "enketo.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.ingress.className }} + {{- end }} + {{- 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: {{ .path }} + {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + pathType: {{ .pathType }} + {{- end }} + 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/charts/odk-central/charts/enketo/templates/service.yaml b/charts/odk-central/charts/enketo/templates/service.yaml new file mode 100644 index 0000000..47a0186 --- /dev/null +++ b/charts/odk-central/charts/enketo/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "enketo.fullname" . }} + labels: + {{- include "enketo.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "enketo.selectorLabels" . | nindent 4 }} diff --git a/charts/odk-central/charts/enketo/templates/serviceaccount.yaml b/charts/odk-central/charts/enketo/templates/serviceaccount.yaml new file mode 100644 index 0000000..d9fc1cc --- /dev/null +++ b/charts/odk-central/charts/enketo/templates/serviceaccount.yaml @@ -0,0 +1,13 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "enketo.serviceAccountName" . }} + labels: + {{- include "enketo.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +automountServiceAccountToken: {{ .Values.serviceAccount.automount }} +{{- end }} diff --git a/charts/odk-central/charts/enketo/templates/tests/test-connection.yaml b/charts/odk-central/charts/enketo/templates/tests/test-connection.yaml new file mode 100644 index 0000000..00777ed --- /dev/null +++ b/charts/odk-central/charts/enketo/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "enketo.fullname" . }}-test-connection" + labels: + {{- include "enketo.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "enketo.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/charts/odk-central/charts/enketo/values.yaml b/charts/odk-central/charts/enketo/values.yaml new file mode 100644 index 0000000..6eaf280 --- /dev/null +++ b/charts/odk-central/charts/enketo/values.yaml @@ -0,0 +1,117 @@ +# Default values for enketo. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: ghcr.io/caktus/central-enketo + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: latest + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +config: + # Set to 64-character random string + # enketoSecret: "" + # Set to 32-character random string + # enketoLessSecret: "" + # Set to 128-character random string + # enketoApiKey: "" + + # redisMainHost: "" + redisMainPort: "6379" + + # redisCacheHost: "" + redisCachePort: "6379" + + supportEmail: "" + httpsPort: "443" + + debug: false + +serviceAccount: + # Specifies whether a service account should be created + create: true + # Automatically mount a ServiceAccount's API credentials? + automount: true + # 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: {} +podLabels: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: ClusterIP + port: 8005 + +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 + +# Additional volumes on the output Deployment definition. +volumes: [] +# - name: foo +# secret: +# secretName: mysecret +# optional: false + +# Additional volumeMounts on the output Deployment definition. +volumeMounts: [] +# - name: foo +# mountPath: "/etc/foo" +# readOnly: true + +nodeSelector: {} + +tolerations: [] + +affinity: {} diff --git a/charts/odk-central/charts/frontend/.helmignore b/charts/odk-central/charts/frontend/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/odk-central/charts/frontend/.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/odk-central/charts/frontend/Chart.yaml b/charts/odk-central/charts/frontend/Chart.yaml new file mode 100644 index 0000000..147b26c --- /dev/null +++ b/charts/odk-central/charts/frontend/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: frontend +description: A Helm chart for Kubernetes + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# 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.0 + +# 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. +# It is recommended to use it with quotes. +appVersion: "1.16.0" diff --git a/charts/odk-central/charts/frontend/templates/NOTES.txt b/charts/odk-central/charts/frontend/templates/NOTES.txt new file mode 100644 index 0000000..81b5583 --- /dev/null +++ b/charts/odk-central/charts/frontend/templates/NOTES.txt @@ -0,0 +1,22 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range .paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "frontend.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 --namespace {{ .Release.Namespace }} svc -w {{ include "frontend.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "frontend.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + 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.kubernetes.io/name={{ include "frontend.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/charts/odk-central/charts/frontend/templates/_helpers.tpl b/charts/odk-central/charts/frontend/templates/_helpers.tpl new file mode 100644 index 0000000..92c6c3b --- /dev/null +++ b/charts/odk-central/charts/frontend/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "frontend.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 "frontend.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 "frontend.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "frontend.labels" -}} +helm.sh/chart: {{ include "frontend.chart" . }} +{{ include "frontend.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "frontend.selectorLabels" -}} +app.kubernetes.io/name: {{ include "frontend.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "frontend.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "frontend.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/charts/odk-central/charts/frontend/templates/deployment.yaml b/charts/odk-central/charts/frontend/templates/deployment.yaml new file mode 100644 index 0000000..db82ad8 --- /dev/null +++ b/charts/odk-central/charts/frontend/templates/deployment.yaml @@ -0,0 +1,80 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "frontend.fullname" . }} + labels: + {{- include "frontend.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "frontend.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "frontend.labels" . | nindent 8 }} + {{- with .Values.podLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "frontend.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: http + containerPort: {{ .Values.service.port }} + protocol: TCP + livenessProbe: + httpGet: + path: / + port: http + readinessProbe: + httpGet: + path: / + port: http + resources: + {{- toYaml .Values.resources | nindent 12 }} + env: + - name: ENKETO_URL + value: '{{ .Values.config.enketoUrl | default (printf "http://%s-enketo:8005" .Release.Name) }}' + - name: SERVICE_URL + value: '{{ .Values.config.serviceUrl | default (printf "http://%s-backend:8383" .Release.Name) }}' + envFrom: + - secretRef: + name: {{ include "frontend.fullname" . }} + {{- with .Values.volumeMounts }} + volumeMounts: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.volumes }} + volumes: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/charts/odk-central/charts/frontend/templates/hpa.yaml b/charts/odk-central/charts/frontend/templates/hpa.yaml new file mode 100644 index 0000000..535b347 --- /dev/null +++ b/charts/odk-central/charts/frontend/templates/hpa.yaml @@ -0,0 +1,32 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "frontend.fullname" . }} + labels: + {{- include "frontend.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "frontend.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/charts/odk-central/charts/frontend/templates/ingress.yaml b/charts/odk-central/charts/frontend/templates/ingress.yaml new file mode 100644 index 0000000..410043a --- /dev/null +++ b/charts/odk-central/charts/frontend/templates/ingress.yaml @@ -0,0 +1,61 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "frontend.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.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 "frontend.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.ingress.className }} + {{- end }} + {{- 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: {{ .path }} + {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + pathType: {{ .pathType }} + {{- end }} + 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/charts/odk-central/charts/frontend/templates/secret.yaml b/charts/odk-central/charts/frontend/templates/secret.yaml new file mode 100644 index 0000000..dabd99d --- /dev/null +++ b/charts/odk-central/charts/frontend/templates/secret.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "frontend.fullname" . }} + labels: + {{- include "frontend.labels" . | nindent 4 }} +{{- with .Values.environmentVariables }} +stringData: + {{- toYaml . | nindent 2 }} +{{- end }} +type: Opaque diff --git a/charts/odk-central/charts/frontend/templates/service.yaml b/charts/odk-central/charts/frontend/templates/service.yaml new file mode 100644 index 0000000..708b0ed --- /dev/null +++ b/charts/odk-central/charts/frontend/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "frontend.fullname" . }} + labels: + {{- include "frontend.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "frontend.selectorLabels" . | nindent 4 }} diff --git a/charts/odk-central/charts/frontend/templates/serviceaccount.yaml b/charts/odk-central/charts/frontend/templates/serviceaccount.yaml new file mode 100644 index 0000000..22facbd --- /dev/null +++ b/charts/odk-central/charts/frontend/templates/serviceaccount.yaml @@ -0,0 +1,13 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "frontend.serviceAccountName" . }} + labels: + {{- include "frontend.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +automountServiceAccountToken: {{ .Values.serviceAccount.automount }} +{{- end }} diff --git a/charts/odk-central/charts/frontend/templates/tests/test-connection.yaml b/charts/odk-central/charts/frontend/templates/tests/test-connection.yaml new file mode 100644 index 0000000..372ac5e --- /dev/null +++ b/charts/odk-central/charts/frontend/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "frontend.fullname" . }}-test-connection" + labels: + {{- include "frontend.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "frontend.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/charts/odk-central/charts/frontend/values.yaml b/charts/odk-central/charts/frontend/values.yaml new file mode 100644 index 0000000..554bacf --- /dev/null +++ b/charts/odk-central/charts/frontend/values.yaml @@ -0,0 +1,102 @@ +# Default values for frontend. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: ghcr.io/caktus/central-nginx + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: latest + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +config: {} + # enketoUrl: "" + # serviceUrl: "" + +serviceAccount: + # Specifies whether a service account should be created + create: true + # Automatically mount a ServiceAccount's API credentials? + automount: true + # 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: {} +podLabels: {} + +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 + +# Additional volumes on the output Deployment definition. +volumes: [] +# - name: foo +# secret: +# secretName: mysecret +# optional: false + +# Additional volumeMounts on the output Deployment definition. +volumeMounts: [] +# - name: foo +# mountPath: "/etc/foo" +# readOnly: true + +nodeSelector: {} + +tolerations: [] + +affinity: {} diff --git a/charts/odk-central/charts/pyxform/.helmignore b/charts/odk-central/charts/pyxform/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/odk-central/charts/pyxform/.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/odk-central/charts/pyxform/Chart.yaml b/charts/odk-central/charts/pyxform/Chart.yaml new file mode 100644 index 0000000..f985dd5 --- /dev/null +++ b/charts/odk-central/charts/pyxform/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: pyxform +description: A Helm chart for Kubernetes + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# 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.0 + +# 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. +# It is recommended to use it with quotes. +appVersion: "1.16.0" diff --git a/charts/odk-central/charts/pyxform/templates/NOTES.txt b/charts/odk-central/charts/pyxform/templates/NOTES.txt new file mode 100644 index 0000000..055137a --- /dev/null +++ b/charts/odk-central/charts/pyxform/templates/NOTES.txt @@ -0,0 +1,22 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range .paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "pyxform.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 --namespace {{ .Release.Namespace }} svc -w {{ include "pyxform.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "pyxform.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + 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.kubernetes.io/name={{ include "pyxform.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/charts/odk-central/charts/pyxform/templates/_helpers.tpl b/charts/odk-central/charts/pyxform/templates/_helpers.tpl new file mode 100644 index 0000000..07b15c5 --- /dev/null +++ b/charts/odk-central/charts/pyxform/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "pyxform.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 "pyxform.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 "pyxform.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "pyxform.labels" -}} +helm.sh/chart: {{ include "pyxform.chart" . }} +{{ include "pyxform.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "pyxform.selectorLabels" -}} +app.kubernetes.io/name: {{ include "pyxform.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "pyxform.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "pyxform.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/charts/odk-central/charts/pyxform/templates/deployment.yaml b/charts/odk-central/charts/pyxform/templates/deployment.yaml new file mode 100644 index 0000000..e28bb3c --- /dev/null +++ b/charts/odk-central/charts/pyxform/templates/deployment.yaml @@ -0,0 +1,72 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "pyxform.fullname" . }} + labels: + {{- include "pyxform.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "pyxform.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "pyxform.labels" . | nindent 8 }} + {{- with .Values.podLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "pyxform.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: http + containerPort: {{ .Values.service.port }} + protocol: TCP + livenessProbe: + httpGet: + path: / + port: http + readinessProbe: + httpGet: + path: / + port: http + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- with .Values.volumeMounts }} + volumeMounts: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.volumes }} + volumes: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/charts/odk-central/charts/pyxform/templates/hpa.yaml b/charts/odk-central/charts/pyxform/templates/hpa.yaml new file mode 100644 index 0000000..1f525fa --- /dev/null +++ b/charts/odk-central/charts/pyxform/templates/hpa.yaml @@ -0,0 +1,32 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "pyxform.fullname" . }} + labels: + {{- include "pyxform.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "pyxform.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/charts/odk-central/charts/pyxform/templates/ingress.yaml b/charts/odk-central/charts/pyxform/templates/ingress.yaml new file mode 100644 index 0000000..fdf2fa7 --- /dev/null +++ b/charts/odk-central/charts/pyxform/templates/ingress.yaml @@ -0,0 +1,61 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "pyxform.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.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 "pyxform.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.ingress.className }} + {{- end }} + {{- 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: {{ .path }} + {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + pathType: {{ .pathType }} + {{- end }} + 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/charts/odk-central/charts/pyxform/templates/service.yaml b/charts/odk-central/charts/pyxform/templates/service.yaml new file mode 100644 index 0000000..f16bfae --- /dev/null +++ b/charts/odk-central/charts/pyxform/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "pyxform.fullname" . }} + labels: + {{- include "pyxform.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "pyxform.selectorLabels" . | nindent 4 }} diff --git a/charts/odk-central/charts/pyxform/templates/serviceaccount.yaml b/charts/odk-central/charts/pyxform/templates/serviceaccount.yaml new file mode 100644 index 0000000..8d2f2ee --- /dev/null +++ b/charts/odk-central/charts/pyxform/templates/serviceaccount.yaml @@ -0,0 +1,13 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "pyxform.serviceAccountName" . }} + labels: + {{- include "pyxform.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +automountServiceAccountToken: {{ .Values.serviceAccount.automount }} +{{- end }} diff --git a/charts/odk-central/charts/pyxform/templates/tests/test-connection.yaml b/charts/odk-central/charts/pyxform/templates/tests/test-connection.yaml new file mode 100644 index 0000000..7990139 --- /dev/null +++ b/charts/odk-central/charts/pyxform/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "pyxform.fullname" . }}-test-connection" + labels: + {{- include "pyxform.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "pyxform.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/charts/odk-central/charts/pyxform/values.yaml b/charts/odk-central/charts/pyxform/values.yaml new file mode 100644 index 0000000..8c8094f --- /dev/null +++ b/charts/odk-central/charts/pyxform/values.yaml @@ -0,0 +1,98 @@ +# Default values for pyxform. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: ghcr.io/getodk/pyxform-http + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "v2.0.0" + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + create: true + # Automatically mount a ServiceAccount's API credentials? + automount: true + # 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: {} +podLabels: {} + +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 + +# Additional volumes on the output Deployment definition. +volumes: [] +# - name: foo +# secret: +# secretName: mysecret +# optional: false + +# Additional volumeMounts on the output Deployment definition. +volumeMounts: [] +# - name: foo +# mountPath: "/etc/foo" +# readOnly: true + +nodeSelector: {} + +tolerations: [] + +affinity: {} diff --git a/charts/odk-central/templates/NOTES.txt b/charts/odk-central/templates/NOTES.txt new file mode 100644 index 0000000..2177ecb --- /dev/null +++ b/charts/odk-central/templates/NOTES.txt @@ -0,0 +1,22 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range .paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "odk-central.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 --namespace {{ .Release.Namespace }} svc -w {{ include "odk-central.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "odk-central.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + 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.kubernetes.io/name={{ include "odk-central.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/charts/odk-central/templates/_helpers.tpl b/charts/odk-central/templates/_helpers.tpl new file mode 100644 index 0000000..40e00fc --- /dev/null +++ b/charts/odk-central/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "odk-central.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 "odk-central.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 "odk-central.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "odk-central.labels" -}} +helm.sh/chart: {{ include "odk-central.chart" . }} +{{ include "odk-central.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "odk-central.selectorLabels" -}} +app.kubernetes.io/name: {{ include "odk-central.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "odk-central.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "odk-central.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/charts/odk-central/templates/deployment.yaml b/charts/odk-central/templates/deployment.yaml new file mode 100644 index 0000000..e6d1ba3 --- /dev/null +++ b/charts/odk-central/templates/deployment.yaml @@ -0,0 +1,72 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "odk-central.fullname" . }} + labels: + {{- include "odk-central.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "odk-central.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "odk-central.labels" . | nindent 8 }} + {{- with .Values.podLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "odk-central.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: http + containerPort: {{ .Values.service.port }} + protocol: TCP + livenessProbe: + httpGet: + path: / + port: http + readinessProbe: + httpGet: + path: / + port: http + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- with .Values.volumeMounts }} + volumeMounts: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.volumes }} + volumes: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/charts/odk-central/templates/hpa.yaml b/charts/odk-central/templates/hpa.yaml new file mode 100644 index 0000000..09d6cbc --- /dev/null +++ b/charts/odk-central/templates/hpa.yaml @@ -0,0 +1,32 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "odk-central.fullname" . }} + labels: + {{- include "odk-central.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "odk-central.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/charts/odk-central/templates/ingress.yaml b/charts/odk-central/templates/ingress.yaml new file mode 100644 index 0000000..840b8a2 --- /dev/null +++ b/charts/odk-central/templates/ingress.yaml @@ -0,0 +1,61 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "odk-central.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.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 "odk-central.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.ingress.className }} + {{- end }} + {{- 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: {{ .path }} + {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + pathType: {{ .pathType }} + {{- end }} + 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/charts/odk-central/templates/secret.yaml b/charts/odk-central/templates/secret.yaml new file mode 100644 index 0000000..36e7629 --- /dev/null +++ b/charts/odk-central/templates/secret.yaml @@ -0,0 +1,10 @@ +apiVersion: v1 +kind: Secret +metadata: + name: {{ .Values.global.enketoSecretName }} + labels: + {{- include "central.labels" . | nindent 4 }} +data: + enketo-secret: "{{ .Values.global.enketoSecrets.enketoSecret | b64enc }}" + enketo-less-secret: "{{ .Values.global.enketoSecrets.enketoLessSecret | b64enc }}" + enketo-api-key: "{{ .Values.global.enketoSecrets.enketoApiKey | b64enc }}" diff --git a/charts/odk-central/templates/service.yaml b/charts/odk-central/templates/service.yaml new file mode 100644 index 0000000..7b5f993 --- /dev/null +++ b/charts/odk-central/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "odk-central.fullname" . }} + labels: + {{- include "odk-central.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "odk-central.selectorLabels" . | nindent 4 }} diff --git a/charts/odk-central/templates/serviceaccount.yaml b/charts/odk-central/templates/serviceaccount.yaml new file mode 100644 index 0000000..0315cb1 --- /dev/null +++ b/charts/odk-central/templates/serviceaccount.yaml @@ -0,0 +1,13 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "odk-central.serviceAccountName" . }} + labels: + {{- include "odk-central.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +automountServiceAccountToken: {{ .Values.serviceAccount.automount }} +{{- end }} diff --git a/charts/odk-central/templates/tests/test-connection.yaml b/charts/odk-central/templates/tests/test-connection.yaml new file mode 100644 index 0000000..f9402c9 --- /dev/null +++ b/charts/odk-central/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "odk-central.fullname" . }}-test-connection" + labels: + {{- include "odk-central.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "odk-central.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/charts/odk-central/values.yaml b/charts/odk-central/values.yaml new file mode 100644 index 0000000..5c0f08f --- /dev/null +++ b/charts/odk-central/values.yaml @@ -0,0 +1,81 @@ +# Default values for odk-central. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +global: + centralDomain: www.example.com + enketoSecretName: central-enketo-secrets + enketoSecrets: {} + # Set to 64-character random string + # enketoSecret: "" + # Set to 32-character random string + # enketoLessSecret: "" + # Set to 128-character random string + # enketoApiKey: "" + +enketo-redis-main: + enabled: true + + replicas: 1 + + # use emptyDir to avoid tying pods to nodes during development + # (not sure what this is used for, might be okay long-term too) + persistentVolume: + enabled: false + emptyDir: + sizeLimit: 500Mi + +enketo-redis-cache: + enabled: true + + replicas: 1 + + # use emptyDir to avoid tying pods to nodes during development + # (maybe okay long-term since this is just a cache?) + persistentVolume: + enabled: false + emptyDir: + sizeLimit: 500Mi + +enketo: + enabled: true + +frontend: + enabled: true + environmentVariables: + CERTBOT_EMAIL: "" + DOMAIN: "" + SENTRY_KEY: 3cf75f54983e473da6bd07daddf0d2ee + SENTRY_ORG_SUBDOMAIN: o130137 + SENTRY_PROJECT: "1298632" + SSL_TYPE: upstream + +backend: + enabled: true + environmentVariables: + DB_HOST: postgres14 + DB_NAME: odk + DB_PASSWORD: odk + DB_SSL: "null" + DB_USER: odk + DOMAIN: "" + EMAIL_FROM: no-reply@ + EMAIL_HOST: mail + EMAIL_IGNORE_TLS: "true" + EMAIL_PASSWORD: "" + EMAIL_PORT: "25" + EMAIL_SECURE: "false" + EMAIL_USER: "" + HTTPS_PORT: "443" + NODE_OPTIONS: "" + OIDC_CLIENT_ID: "" + OIDC_CLIENT_SECRET: "" + OIDC_ENABLED: "false" + OIDC_ISSUER_URL: "" + SENTRY_KEY: 3cf75f54983e473da6bd07daddf0d2ee + SENTRY_ORG_SUBDOMAIN: o130137 + SENTRY_PROJECT: "1298632" + SYSADMIN_EMAIL: "" + +pyxform: + enabled: true