From ca1e79c981a091585f1c0580ef1ce0b96c86edfb Mon Sep 17 00:00:00 2001 From: Dylan Decrulle <81740200+ddecrulle@users.noreply.github.com> Date: Mon, 4 Dec 2023 10:49:16 +0100 Subject: [PATCH] add knowledge chart --- charts/knowledge/.helmignore | 23 +++ charts/knowledge/Chart.yaml | 13 ++ charts/knowledge/templates/NOTES.txt | 1 + charts/knowledge/templates/_helpers.tpl | 143 +++++++++++++ charts/knowledge/templates/api/configmap.yaml | 17 ++ .../knowledge/templates/api/deployment.yaml | 87 ++++++++ charts/knowledge/templates/api/hpa.yaml | 28 +++ charts/knowledge/templates/api/ingress.yaml | 61 ++++++ charts/knowledge/templates/api/service.yaml | 17 ++ .../templates/api/serviceaccount.yaml | 12 ++ .../knowledge/templates/discovery-secret.yaml | 22 ++ .../templates/tests/test-connection-api.yaml | 17 ++ .../templates/tests/test-connection-ui.yaml | 17 ++ charts/knowledge/templates/ui/configmap.yaml | 15 ++ charts/knowledge/templates/ui/deployment.yaml | 64 ++++++ charts/knowledge/templates/ui/ingress.yaml | 61 ++++++ charts/knowledge/templates/ui/service.yaml | 17 ++ .../templates/ui/serviceaccount.yaml | 12 ++ charts/knowledge/values.yaml | 191 ++++++++++++++++++ 19 files changed, 818 insertions(+) create mode 100644 charts/knowledge/.helmignore create mode 100644 charts/knowledge/Chart.yaml create mode 100644 charts/knowledge/templates/NOTES.txt create mode 100644 charts/knowledge/templates/_helpers.tpl create mode 100644 charts/knowledge/templates/api/configmap.yaml create mode 100644 charts/knowledge/templates/api/deployment.yaml create mode 100644 charts/knowledge/templates/api/hpa.yaml create mode 100644 charts/knowledge/templates/api/ingress.yaml create mode 100644 charts/knowledge/templates/api/service.yaml create mode 100644 charts/knowledge/templates/api/serviceaccount.yaml create mode 100644 charts/knowledge/templates/discovery-secret.yaml create mode 100644 charts/knowledge/templates/tests/test-connection-api.yaml create mode 100644 charts/knowledge/templates/tests/test-connection-ui.yaml create mode 100644 charts/knowledge/templates/ui/configmap.yaml create mode 100644 charts/knowledge/templates/ui/deployment.yaml create mode 100644 charts/knowledge/templates/ui/ingress.yaml create mode 100644 charts/knowledge/templates/ui/service.yaml create mode 100644 charts/knowledge/templates/ui/serviceaccount.yaml create mode 100644 charts/knowledge/values.yaml diff --git a/charts/knowledge/.helmignore b/charts/knowledge/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/knowledge/.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/knowledge/Chart.yaml b/charts/knowledge/Chart.yaml new file mode 100644 index 0000000..5c3a42c --- /dev/null +++ b/charts/knowledge/Chart.yaml @@ -0,0 +1,13 @@ +apiVersion: v2 +name: knowledge +description: A Helm chart for Knowledge API, UI and DB + +dependencies: + - name: mongodb + condition: mongodb.enabled + version: 13.15.3 + repository: https://charts.bitnami.com/bitnami + +type: application +version: 0.5.1 +appVersion: "1.16.0" diff --git a/charts/knowledge/templates/NOTES.txt b/charts/knowledge/templates/NOTES.txt new file mode 100644 index 0000000..30404ce --- /dev/null +++ b/charts/knowledge/templates/NOTES.txt @@ -0,0 +1 @@ +TODO \ No newline at end of file diff --git a/charts/knowledge/templates/_helpers.tpl b/charts/knowledge/templates/_helpers.tpl new file mode 100644 index 0000000..66c3c59 --- /dev/null +++ b/charts/knowledge/templates/_helpers.tpl @@ -0,0 +1,143 @@ +{{/* +Expand the name of the chart. +*/}} + + +{{- define "knowledge.api.name" -}} +{{- .Values.api.nameOverride | default (printf "%s-api" .Chart.Name ) }} +{{- end }} + +{{- define "knowledge.ui.name" -}} +{{- .Values.ui.nameOverride | default (printf "%s-ui" .Chart.Name ) }} +{{- 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 "knowledge.api.fullname" -}} +{{- if .Values.api.fullnameOverride }} +{{- .Values.api.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default (printf "%s-api" .Chart.Name ) .Values.api.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{- define "knowledge.ui.fullname" -}} +{{- if .Values.ui.fullnameOverride }} +{{- .Values.ui.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default (printf "%s-ui" .Chart.Name ) .Values.ui.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + + +{{- define "knowledge.mongodb.fullname" -}} +{{- if .Values.mongodb.fullnameOverride -}} +{{- .Values.mongodb.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.mongodb.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 "knowledge.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{- define "knowledge.api.chart" -}} +{{- printf "knowledge-api" -}} +{{- end -}} + +{{- define "knowledge.ui.chart" -}} +{{- printf "knowledge-ui" -}} +{{- end -}} + +{{/* +Common labels +*/}} + +{{- define "knowledge.api.labels" -}} +helm.sh/chart: {{ include "knowledge.api.chart" . }} +{{ include "knowledge.api.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end -}} + +{{- define "knowledge.ui.labels" -}} +helm.sh/chart: {{ include "knowledge.ui.chart" . }} +{{ include "knowledge.ui.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end -}} + +{{/* +Selector labels +*/}} + +{{- define "knowledge.api.selectorLabels" -}} +app.kubernetes.io/name: {{ include "knowledge.api.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end -}} + +{{- define "knowledge.ui.selectorLabels" -}} +app.kubernetes.io/name: {{ include "knowledge.ui.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end -}} + + +{{/* +Create the name of the service account to use +*/}} +{{- define "knowledge.api.serviceAccountName" -}} +{{- if .Values.api.serviceAccount.create }} +{{- default (include "knowledge.api.fullname" .) .Values.api.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.api.serviceAccount.name }} +{{- end }} +{{- end }} + +{{- define "knowledge.ui.serviceAccountName" -}} +{{- if .Values.ui.serviceAccount.create }} +{{- default (include "knowledge.ui.fullname" .) .Values.ui.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.ui.serviceAccount.name }} +{{- end }} +{{- end }} + +{{/* +Create list of mongo host +*/}} +{{- define "mongoList" -}} +{{- $replicaCount := int .Values.mongodb.replicaCount }} +{{- $portNumber := int .Values.mongodb.service.ports.mongodb }} +{{- $fullname := include "knowledge.mongodb.fullname" . }} +{{- $mongoList := list }} +{{- range $e, $i := until $replicaCount }} +{{- $mongoList = append $mongoList (printf "%s-%d.%s-headless:%d" $fullname $i $fullname $portNumber) }} +{{- end }} +{{- printf "%s" (join "," $mongoList) -}} +{{- end }} \ No newline at end of file diff --git a/charts/knowledge/templates/api/configmap.yaml b/charts/knowledge/templates/api/configmap.yaml new file mode 100644 index 0000000..c131e5c --- /dev/null +++ b/charts/knowledge/templates/api/configmap.yaml @@ -0,0 +1,17 @@ +{{- if .Values.api.enabled }} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ template "knowledge.api.fullname" . }} + labels: + app: {{ template "knowledge.api.name" . }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +data: +{{- if .Values.api.env }} +{{- range $key, $value := .Values.api.env }} + {{ $key }}: {{ $value | quote }} +{{- end -}} +{{- end -}} +{{- end -}} \ No newline at end of file diff --git a/charts/knowledge/templates/api/deployment.yaml b/charts/knowledge/templates/api/deployment.yaml new file mode 100644 index 0000000..9317695 --- /dev/null +++ b/charts/knowledge/templates/api/deployment.yaml @@ -0,0 +1,87 @@ +{{- if .Values.api.enabled -}} +{{- $mongodbFullname := include "knowledge.mongodb.fullname" . }} +{{- $secretName := printf "%s-discovery" $mongodbFullname -}} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "knowledge.api.fullname" . }} + labels: + {{- include "knowledge.api.labels" . | nindent 4 }} +spec: + {{- if not .Values.api.autoscaling.enabled }} + replicas: {{ .Values.api.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "knowledge.api.selectorLabels" . | nindent 6 }} + template: + metadata: + annotations: + checksum/config: {{ include (print $.Template.BasePath "/api/configmap.yaml") . | sha256sum }} + labels: + {{- include "knowledge.api.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.api.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "knowledge.api.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.api.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.api.securityContext | nindent 12 }} + image: "{{ .Values.api.image.repository }}:{{ .Values.api.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.api.image.pullPolicy }} + envFrom: + - configMapRef: + name: {{ template "knowledge.api.fullname" . }} + env: + - name: MONGODB_URI + valueFrom: + secretKeyRef: + name: {{$secretName}} + key: mongodb-uri + - name: MONGODB_DATABASE + valueFrom: + secretKeyRef: + name: {{$secretName}} + key: mongodb-database + ports: + - name: http + containerPort: 8080 + protocol: TCP + livenessProbe: + failureThreshold: 3 + httpGet: + path: /api/healthcheck + port: http + scheme: HTTP + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 2 + readinessProbe: + failureThreshold: 3 + httpGet: + path: /api/healthcheck + port: http + scheme: HTTP + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 5 + resources: + {{- toYaml .Values.api.resources | nindent 12 }} + {{- with .Values.api.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.api.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.api.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} +{{- end -}} diff --git a/charts/knowledge/templates/api/hpa.yaml b/charts/knowledge/templates/api/hpa.yaml new file mode 100644 index 0000000..adf3282 --- /dev/null +++ b/charts/knowledge/templates/api/hpa.yaml @@ -0,0 +1,28 @@ +{{- if and .Values.api.autoscaling.enabled .Values.api.enabled}} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "knowledge.api.fullname" . }} + labels: + {{- include "knowledge.api.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "knowledge.api.fullname" . }} + minReplicas: {{ .Values.api.autoscaling.minReplicas }} + maxReplicas: {{ .Values.api.autoscaling.maxReplicas }} + metrics: + {{- if .Values.api.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.api.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.api.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.api.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/charts/knowledge/templates/api/ingress.yaml b/charts/knowledge/templates/api/ingress.yaml new file mode 100644 index 0000000..34f6c07 --- /dev/null +++ b/charts/knowledge/templates/api/ingress.yaml @@ -0,0 +1,61 @@ +{{- if and .Values.api.enabled .Values.api.ingress.enabled -}} +{{- $fullNameApi := include "knowledge.api.fullname" . -}} +{{- $apiSvcPort := .Values.api.service.port -}} +{{- if and .Values.api.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.api.ingress.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.api.ingress.annotations "kubernetes.io/ingress.class" .Values.api.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: {{ $fullNameApi }} + labels: + {{- include "knowledge.api.labels" . | nindent 4 }} + {{- with .Values.api.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if and .Values.api.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.api.ingress.className }} + {{- end }} + {{- if .Values.api.ingress.tls }} + tls: + {{- range .Values.api.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.api.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: {{ $fullNameApi }} + port: + number: {{ $apiSvcPort }} + {{- else }} + serviceName: {{ $fullNameApi }} + servicePort: {{ $apiSvcPort }} + {{- end }} + {{- end }} + {{- end }} +{{- end }} \ No newline at end of file diff --git a/charts/knowledge/templates/api/service.yaml b/charts/knowledge/templates/api/service.yaml new file mode 100644 index 0000000..18bdf69 --- /dev/null +++ b/charts/knowledge/templates/api/service.yaml @@ -0,0 +1,17 @@ +{{- if .Values.api.enabled -}} +apiVersion: v1 +kind: Service +metadata: + name: {{ include "knowledge.api.fullname" . }} + labels: + {{- include "knowledge.api.labels" . | nindent 4 }} +spec: + type: {{ .Values.api.service.type }} + ports: + - port: {{ .Values.api.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "knowledge.api.selectorLabels" . | nindent 4 }} +{{- end }} diff --git a/charts/knowledge/templates/api/serviceaccount.yaml b/charts/knowledge/templates/api/serviceaccount.yaml new file mode 100644 index 0000000..31db075 --- /dev/null +++ b/charts/knowledge/templates/api/serviceaccount.yaml @@ -0,0 +1,12 @@ +{{- if and .Values.api.enabled .Values.api.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "knowledge.api.serviceAccountName" . }} + labels: + {{- include "knowledge.api.labels" . | nindent 4 }} + {{- with .Values.api.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/charts/knowledge/templates/discovery-secret.yaml b/charts/knowledge/templates/discovery-secret.yaml new file mode 100644 index 0000000..fc7a2eb --- /dev/null +++ b/charts/knowledge/templates/discovery-secret.yaml @@ -0,0 +1,22 @@ +{{- if .Values.mongodb.enabled }} +{{- $fullname := include "knowledge.mongodb.fullname" . }} +{{- $db := .Values.mongodb.auth.database }} +{{- $mongoList := include "mongoList" . }} +{{- $user := .Values.mongodb.auth.username }} +{{- $password := .Values.mongodb.auth.password }} +apiVersion: v1 +kind: Secret +metadata: + name: {{ $fullname }}-discovery + annotations: + knowledge/discovery: "knowledge" +type: Opaque +data: + mongodb-service: {{ (include "mongoList" .) | b64enc | quote }} + mongodb-name: {{ printf "%s" $fullname | b64enc | quote }} + mongodb-password: {{ $password | b64enc | quote }} + mongodb-username: {{ $user | b64enc | quote }} + mongodb-database: {{ $db | b64enc | quote}} + mongodb-rootPassword: {{ .Values.mongodb.auth.rootPassword | b64enc | quote }} + mongodb-uri: {{ (printf "mongodb://%s:%s@%s/%s" $user $password $mongoList $db ) | b64enc | quote }} +{{- end -}} \ No newline at end of file diff --git a/charts/knowledge/templates/tests/test-connection-api.yaml b/charts/knowledge/templates/tests/test-connection-api.yaml new file mode 100644 index 0000000..f0fb67c --- /dev/null +++ b/charts/knowledge/templates/tests/test-connection-api.yaml @@ -0,0 +1,17 @@ +{{- if .Values.api.enabled -}} +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "knowledge.api.fullname" . }}-test-connection" + labels: + {{- include "knowledge.api.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "knowledge.api.fullname" . }}:{{ .Values.api.service.port }}'] + restartPolicy: Never +{{- end -}} \ No newline at end of file diff --git a/charts/knowledge/templates/tests/test-connection-ui.yaml b/charts/knowledge/templates/tests/test-connection-ui.yaml new file mode 100644 index 0000000..6fb5894 --- /dev/null +++ b/charts/knowledge/templates/tests/test-connection-ui.yaml @@ -0,0 +1,17 @@ +{{- if .Values.ui.enabled -}} +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "knowledge.ui.fullname" . }}-test-connection" + labels: + {{- include "knowledge.ui.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "knowledge.ui.fullname" . }}:{{ .Values.ui.service.port }}'] + restartPolicy: Never +{{- end -}} \ No newline at end of file diff --git a/charts/knowledge/templates/ui/configmap.yaml b/charts/knowledge/templates/ui/configmap.yaml new file mode 100644 index 0000000..59a2769 --- /dev/null +++ b/charts/knowledge/templates/ui/configmap.yaml @@ -0,0 +1,15 @@ +{{- if and .Values.ui.env .Values.ui.enabled }} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ template "knowledge.ui.fullname" . }} + labels: + app: {{ template "knowledge.ui.name" . }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +data: +{{- range $key, $value := .Values.ui.env }} + {{ $key }}: {{ $value | quote }} +{{- end -}} +{{- end -}} \ No newline at end of file diff --git a/charts/knowledge/templates/ui/deployment.yaml b/charts/knowledge/templates/ui/deployment.yaml new file mode 100644 index 0000000..b3d6af6 --- /dev/null +++ b/charts/knowledge/templates/ui/deployment.yaml @@ -0,0 +1,64 @@ +{{- if .Values.ui.enabled -}} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "knowledge.ui.fullname" . }} + labels: + {{- include "knowledge.ui.labels" . | nindent 4 }} +spec: + {{- if not .Values.ui.autoscaling.enabled }} + replicas: {{ .Values.ui.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "knowledge.ui.selectorLabels" . | nindent 6 }} + template: + metadata: + annotations: + checksum/config: {{ include (print $.Template.BasePath "/ui/configmap.yaml") . | sha256sum }} + labels: + {{- include "knowledge.ui.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.ui.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "knowledge.ui.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.ui.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.ui.securityContext | nindent 12 }} + image: "{{ .Values.ui.image.repository }}:{{ .Values.ui.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.ui.image.pullPolicy }} + envFrom: + - configMapRef: + name: {{ template "knowledge.ui.fullname" . }} + ports: + - name: http + containerPort: 80 + protocol: TCP + livenessProbe: + httpGet: + path: / + port: http + readinessProbe: + httpGet: + path: / + port: http + resources: + {{- toYaml .Values.ui.resources | nindent 12 }} + {{- with .Values.ui.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.ui.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.ui.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} +{{- end }} \ No newline at end of file diff --git a/charts/knowledge/templates/ui/ingress.yaml b/charts/knowledge/templates/ui/ingress.yaml new file mode 100644 index 0000000..b4a3497 --- /dev/null +++ b/charts/knowledge/templates/ui/ingress.yaml @@ -0,0 +1,61 @@ +{{- if and .Values.ui.enabled .Values.ui.ingress.enabled -}} +{{- $fullName := include "knowledge.ui.fullname" . -}} +{{- $svcPort := .Values.ui.service.port -}} +{{- if and .Values.ui.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.ui.ingress.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.ui.ingress.annotations "kubernetes.io/ingress.class" .Values.ui.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 "knowledge.ui.labels" . | nindent 4 }} + {{- with .Values.ui.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if and .Values.ui.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.ui.ingress.className }} + {{- end }} + {{- if .Values.ui.ingress.tls }} + tls: + {{- range .Values.ui.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.ui.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/knowledge/templates/ui/service.yaml b/charts/knowledge/templates/ui/service.yaml new file mode 100644 index 0000000..4f12e24 --- /dev/null +++ b/charts/knowledge/templates/ui/service.yaml @@ -0,0 +1,17 @@ +{{- if .Values.ui.enabled -}} +apiVersion: v1 +kind: Service +metadata: + name: {{ include "knowledge.ui.fullname" . }} + labels: + {{- include "knowledge.ui.labels" . | nindent 4 }} +spec: + type: {{ .Values.ui.service.type }} + ports: + - port: {{ .Values.ui.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "knowledge.ui.selectorLabels" . | nindent 4 }} +{{- end }} diff --git a/charts/knowledge/templates/ui/serviceaccount.yaml b/charts/knowledge/templates/ui/serviceaccount.yaml new file mode 100644 index 0000000..890e264 --- /dev/null +++ b/charts/knowledge/templates/ui/serviceaccount.yaml @@ -0,0 +1,12 @@ +{{- if and .Values.ui.enabled .Values.ui.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "knowledge.ui.serviceAccountName" . }} + labels: + {{- include "knowledge.ui.labels" . | nindent 4 }} + {{- with .Values.ui.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/charts/knowledge/values.yaml b/charts/knowledge/values.yaml new file mode 100644 index 0000000..f57dd9b --- /dev/null +++ b/charts/knowledge/values.yaml @@ -0,0 +1,191 @@ +# Default values for knowledge. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. +ui: + enabled: false + replicaCount: 1 + + image: + repository: ddecrulle/knowledge + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + + imagePullSecrets: [] + nameOverride: "" + fullnameOverride: "" + + serviceAccount: + # Specifies whether a service account should be created + create: 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: {} need to be injected in deployment-ui + + podSecurityContext: + {} + # fsGroup: 2000 + + securityContext: + {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + + service: + type: ClusterIP + port: 80 + + ingress: + enabled: false + className: "" + annotations: + {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: + - path: / + pathType: ImplementationSpecific + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + + resources: + {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + + autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + targetMemoryUtilizationPercentage: 80 + + nodeSelector: {} + + tolerations: [] + + affinity: {} + + env: {} + +api: + enabled: false + replicaCount: 1 + + image: + repository: ddecrulle/knowledge-back-office + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + + imagePullSecrets: [] + nameOverride: "" + fullnameOverride: "" + + serviceAccount: + # Specifies whether a service account should be created + create: 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: {} need to be injected in deployment-api + + podSecurityContext: + {} + # fsGroup: 2000 + + securityContext: + {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + + service: + type: ClusterIP + port: 8080 + + ingress: + enabled: false + className: "" + annotations: + {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: + - path: / + pathType: ImplementationSpecific + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + + resources: + {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + + autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + targetMemoryUtilizationPercentage: 80 + + nodeSelector: {} + + tolerations: [] + + affinity: {} + + env: {} + +mongodb: + enabled: false + resources: {} + fullnameOverride: "" + nameOverride: "" + architecture: replicaset + auth: + rootPassword: rootPassword + #TODO : Depreceated use aray for usernames, passwords and databases + username: username + password: password + database: defaultdb + replicasetKey: default + replicaCount: 3