From ef482b51dc86522bca7e7a5dc434e84aa27b49ad Mon Sep 17 00:00:00 2001 From: Sebastian Wendel Date: Thu, 10 Nov 2022 17:23:06 +0100 Subject: [PATCH] changed to a cleaner multi-container deployment --- CONTRIBUTING.md | 2 +- Chart.yaml | 5 +- Makefile | 4 +- flake.nix | 2 +- templates/_helpers.tpl | 107 ++++++++--- templates/deployment.yaml | 282 ----------------------------- templates/frontend/deployment.yaml | 95 ++++++++++ templates/frontend/hpa.yaml | 29 +++ templates/frontend/service.yaml | 16 ++ templates/gateway/deployment.yaml | 75 ++++++++ templates/gateway/hpa.yaml | 29 +++ templates/gateway/service.yaml | 16 ++ templates/ingress.yaml | 62 ------- templates/service.yaml | 48 ----- templates/zenflow/deployment.yaml | 100 ++++++++++ templates/zenflow/hpa.yaml | 29 +++ templates/zenflow/service.yaml | 16 ++ templates/zvmlet/deployment.yaml | 81 +++++++++ templates/{ => zvmlet}/hpa.yaml | 4 +- templates/zvmlet/service.yaml | 16 ++ values.yaml | 32 +++- 21 files changed, 617 insertions(+), 433 deletions(-) delete mode 100644 templates/deployment.yaml create mode 100644 templates/frontend/deployment.yaml create mode 100644 templates/frontend/hpa.yaml create mode 100644 templates/frontend/service.yaml create mode 100644 templates/gateway/deployment.yaml create mode 100644 templates/gateway/hpa.yaml create mode 100644 templates/gateway/service.yaml delete mode 100644 templates/ingress.yaml delete mode 100644 templates/service.yaml create mode 100644 templates/zenflow/deployment.yaml create mode 100644 templates/zenflow/hpa.yaml create mode 100644 templates/zenflow/service.yaml create mode 100644 templates/zvmlet/deployment.yaml rename templates/{ => zvmlet}/hpa.yaml (88%) create mode 100644 templates/zvmlet/service.yaml diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3ad0769..4032039 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -39,7 +39,7 @@ In order to use the different tools on this repository, you will first need to: - [Optional: Use the Nix Package Manager](https://nix.dev/tutorials/install-nix). This will allow you to make use of the [nixpkgs](https://github.com/NixOS/nixpkgs), automatically managing all required dependencies from the [`nix shell env`](shell.nix). In addition you also need the [nixpkgs: direnv](https://search.nixos.org/packages?query=direnv) for automatic environment selection. ```bash -k3d cluster create --config k3d-fcos-dev.yaml +k3d cluster create --config k3d-fcoscore-dev.yaml ``` Validate chart rendering diff --git a/Chart.yaml b/Chart.yaml index 25958f8..984f3c1 100644 --- a/Chart.yaml +++ b/Chart.yaml @@ -1,6 +1,6 @@ --- name: fcoscore -description: Fab City OS Core Chart using Kubernetes Helm +description: Fab City OS Core Kubernetes Helm Chart version: 0.0.1 type: application appVersion: latest @@ -11,8 +11,9 @@ sources: - https://github.com/dyne/zenflows-crypto - https://www.interfacerproject.eu/ keywords: - - fabcity - fcos + - fabcity + - blockchain - zenflow - zvmlet - fediverse diff --git a/Makefile b/Makefile index 7c8e425..bf14c52 100644 --- a/Makefile +++ b/Makefile @@ -20,10 +20,10 @@ up: k3d-create build ## Create a local k3d development cluster. down: k3d-delete ## Delete the local k3d development cluster. k3d-create: ## Create a local K3D development cluster. - @k3d cluster create fcos-dev --config k3d-dev.yaml + @k3d cluster create fcoscore-dev --config k3d-dev.yaml k3d-delete: ## Delete the local K3D development cluster - @k3d cluster delete fcos-dev + @k3d cluster delete fcoscore-dev info: ## Show k3d cluster info @k3d cluster list diff --git a/flake.nix b/flake.nix index cbf4d47..254d2b2 100644 --- a/flake.nix +++ b/flake.nix @@ -1,5 +1,5 @@ { - description = "fc k8s runtime flake"; + description = "fcoscore k8s runtime flake"; inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable-small"; diff --git a/templates/_helpers.tpl b/templates/_helpers.tpl index 907b182..f27101a 100644 --- a/templates/_helpers.tpl +++ b/templates/_helpers.tpl @@ -23,15 +23,6 @@ If release name contains chart name it will be used as a full name. {{- end }} {{- 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 "fcoscore.zvmlet.fullname" -}} -{{- printf "%s-%s" (include "common.names.fullname" . ) ( .Values.zvmlet.name) }} -{{- end }} - {{/* Create chart name and version as used by the chart label. */}} @@ -96,6 +87,81 @@ If not using ClusterIP, or if a host or LoadBalancerIP is not defined, the value {{- end -}} {{- 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 "fcoscore.zenflow.fullname" -}} +{{- printf "%s-zenflow" (include "common.names.fullname" .) | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{- define "fcoscore.zenflow.host" -}} +{{- printf "%s" (include "fcoscore.zenflow.fullname" . ) -}} +{{- end -}} + +{{- define "fcoscore.zenflow.port" -}} +{{- .Values.zvmlet.service.port -}} +{{- end -}} + +{{- define "fcoscore.zenflow.url" -}} +{{- printf "http://%s:%s" (include "fcoscore.zenflow.host" . ) (include "fcoscore.zenflow.port" . ) -}} +{{- 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 "fcoscore.zvmlet.fullname" -}} +{{- printf "%s-zvmlet" (include "common.names.fullname" .) | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{- define "fcoscore.zvmlet.host" -}} +{{- printf "%s" (include "fcoscore.zvmlet.fullname" . ) -}} +{{- end -}} + +{{- define "fcoscore.zvmlet.port" -}} +{{- .Values.zvmlet.service.port | quote -}} +{{- 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 "fcoscore.frontend.fullname" -}} +{{- printf "%s-frontend" (include "common.names.fullname" .) | 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 "fcoscore.gateway.fullname" -}} +{{- printf "%s-gateway" (include "common.names.fullname" .) | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{- define "fcoscore.gateway.host" -}} +{{- printf "%s" (include "fcoscore.gateway.fullname" . ) -}} +{{- end -}} + +{{- define "fcoscore.gateway.port" -}} +{{- .Values.gateway.service.port | quote -}} +{{- end -}} + +{{- define "fcoscore.gateway.url" -}} +{{- printf "http://%s:%s" (include "fcoscore.gateway.host" . ) (include "fcoscore.gateway.port" . ) -}} +{{- end -}} + +{{/* +Return the Fab City Core secret name +*/}} +{{- define "fcoscore.secretName" -}} +{{- default (include "common.names.fullname" .) -}} +{{- end -}} + {{/* Return true if a secret object for FabCityOS should be created */}} @@ -105,13 +171,6 @@ Return true if a secret object for FabCityOS should be created {{- end -}} {{- end -}} -{{/* -Return the zenflow secret name -*/}} -{{- define "zenflow.secretName" -}} -{{- default (include "common.names.fullname" .) -}} -{{- end -}} - {{/* Return the Postgresql hostname */}} @@ -217,6 +276,10 @@ Return the Postgresql postgres password secret key {{- end -}} {{- end -}} +{{- define "fcoscore.meilisearch.host" -}} +{{- include "common.names.dependency.fullname" (dict "chartName" "meilisearch" "chartValues" .Values.meilisearch "context" $) -}} +{{- 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). @@ -225,18 +288,6 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this {{- include "common.names.dependency.fullname" (dict "chartName" "postgresql" "chartValues" .Values.postgresql "context" $) -}} {{- end -}} -{{- define "fcoscore.zvmlet.host" -}} -{{- printf "%s" (include "fcoscore.zvmlet.fullname" . ) -}} -{{- end -}} - -{{- define "fcoscore.zvmlet.port" -}} -{{- .Values.zvmlet.service.port | quote -}} -{{- end -}} - -{{- define "fcoscore.meilisearch.host" -}} -{{- include "common.names.dependency.fullname" (dict "chartName" "meilisearch" "chartValues" .Values.meilisearch "context" $) -}} -{{- end }} - {{- define "fcoscore.meilisearch.port" -}} {{- .Values.meilisearch.service.port -}} {{- end -}} diff --git a/templates/deployment.yaml b/templates/deployment.yaml deleted file mode 100644 index 5b2bb80..0000000 --- a/templates/deployment.yaml +++ /dev/null @@ -1,282 +0,0 @@ ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - name: "{{ .Chart.Name }}-{{ .Values.zenflow.name }}" - labels: - {{- include "fcoscore.labels" . | nindent 4 }} -spec: - {{- if not .Values.autoscaling.enabled }} - replicas: {{ .Values.replicaCount }} - {{- end }} - selector: - matchLabels: - {{- include "fcoscore.selectorLabels" . | nindent 6 }} - template: - metadata: - {{- with .Values.podAnnotations }} - annotations: - {{- toYaml . | nindent 8 }} - {{- end }} - labels: - {{- include "fcoscore.selectorLabels" . | nindent 8 }} - spec: - {{- with .Values.imagePullSecrets }} - imagePullSecrets: - {{- toYaml . | nindent 8 }} - {{- end }} - serviceAccountName: {{ include "fcoscore.serviceAccountName" . }} - securityContext: - {{- toYaml .Values.podSecurityContext | nindent 8 }} - containers: - - name: {{ .Values.zenflow.name }} - securityContext: - {{- toYaml .Values.securityContext | nindent 12 }} - image: "{{ .Values.zenflow.repository }}:{{ .Values.zenflow.tag | default .Chart.AppVersion }}" - imagePullPolicy: {{ .Values.zenflow.pullPolicy }} - {{- if .Values.lifecycleHooks }} - lifecycle: {{- include "common.tplvalues.render" (dict "value" .Values.lifecycleHooks "context" $) | nindent 12 }} - {{- end }} - {{- if .Values.containerSecurityContext.enabled }} - securityContext: {{- omit .Values.containerSecurityContext "enabled" | toYaml | nindent 12 }} - {{- end }} - {{- if .Values.diagnosticMode.enabled }} - command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 12 }} - {{- else if .Values.command }} - command: {{- include "common.tplvalues.render" (dict "value" .Values.command "context" $) | nindent 12 }} - {{- end }} - {{- if .Values.diagnosticMode.enabled }} - args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 12 }} - {{- else if .Values.args }} - args: {{- include "common.tplvalues.render" (dict "value" .Values.args "context" $) | nindent 12 }} - {{- end }} - env: - {{- if or .Values.postgresql.enabled .Values.externalDatabase.create }} - - name: DB_HOST - value: {{ template "fcoscore.database.host" . }} - - name: DB_PORT - value: {{ template "fcoscore.database.port" . }} - - name: DB_NAME - value: {{ template "fcoscore.database.name" . }} - - name: DB_USER - value: {{ template "fcoscore.database.user" . }} - - name: DB_PASS - valueFrom: - secretKeyRef: - name: {{ include "fcoscore.database.secretName" . }} - key: {{ include "fcoscore.database.secretPasswordKey" . }} - {{- end }} - - name: ROOM_HOST - value: {{ template "fcoscore.zvmlet.host" . }} - - name: ROOM_PORT - value: {{ template "fcoscore.zvmlet.port" . }} - - name: ROOM_SALT - valueFrom: - secretKeyRef: - name: {{ include "zenflow.secretName" . }} - key: room-salt - - name: ADMIN_KEY - valueFrom: - secretKeyRef: - name: {{ include "zenflow.secretName" . }} - key: admin-key - ports: - - name: http - containerPort: {{ .Values.zenflow.service.port }} - protocol: TCP - # livenessProbe: - # httpGet: - # path: / - # port: http - # readinessProbe: - # httpGet: - # path: / - # port: http - resources: - {{- toYaml .Values.resources | nindent 12 }} - {{- with .Values.nodeSelector }} - nodeSelector: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.affinity }} - affinity: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.tolerations }} - tolerations: - {{- toYaml . | nindent 8 }} - {{- end }} ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - name: "{{ .Chart.Name }}-{{ .Values.zvmlet.name }}" - labels: - {{- include "fcoscore.labels" . | nindent 4 }} -spec: - {{- if not .Values.autoscaling.enabled }} - replicas: {{ .Values.replicaCount }} - {{- end }} - selector: - matchLabels: - {{- include "fcoscore.selectorLabels" . | nindent 6 }} - template: - metadata: - {{- with .Values.podAnnotations }} - annotations: - {{- toYaml . | nindent 8 }} - {{- end }} - labels: - {{- include "fcoscore.selectorLabels" . | nindent 8 }} - spec: - {{- with .Values.imagePullSecrets }} - imagePullSecrets: - {{- toYaml . | nindent 8 }} - {{- end }} - serviceAccountName: {{ include "fcoscore.serviceAccountName" . }} - securityContext: - {{- toYaml .Values.podSecurityContext | nindent 8 }} - containers: - - name: {{ .Values.zvmlet.name }} - securityContext: - {{- toYaml .Values.securityContext | nindent 12 }} - image: "{{ .Values.zvmlet.repository }}:{{ .Values.zvmlet.tag | default .Chart.AppVersion }}" - imagePullPolicy: {{ .Values.zvmlet.pullPolicy }} - {{- if .Values.lifecycleHooks }} - lifecycle: {{- include "common.tplvalues.render" (dict "value" .Values.lifecycleHooks "context" $) | nindent 12 }} - {{- end }} - {{- if .Values.containerSecurityContext.enabled }} - securityContext: {{- omit .Values.containerSecurityContext "enabled" | toYaml | nindent 12 }} - {{- end }} - {{- if .Values.diagnosticMode.enabled }} - command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 12 }} - {{- else if .Values.command }} - command: {{- include "common.tplvalues.render" (dict "value" .Values.command "context" $) | nindent 12 }} - {{- end }} - {{- if .Values.diagnosticMode.enabled }} - args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 12 }} - {{- else if .Values.args }} - args: {{- include "common.tplvalues.render" (dict "value" .Values.args "context" $) | nindent 12 }} - {{- end }} - env: - - name: HTTP_PORT - value: {{ .Values.zvmlet.service.port | quote }} - ports: - - name: http - containerPort: {{ .Values.zvmlet.service.port }} - protocol: TCP - livenessProbe: - httpGet: - path: /docs/ - port: http - readinessProbe: - httpGet: - path: /docs/ - port: http - resources: - {{- toYaml .Values.resources | nindent 12 }} - {{- with .Values.nodeSelector }} - nodeSelector: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.affinity }} - affinity: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.tolerations }} - tolerations: - {{- toYaml . | nindent 8 }} - {{- end }} ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - name: "{{ .Chart.Name }}-{{ .Values.frontend.name }}" - labels: - {{- include "fcoscore.labels" . | nindent 4 }} -spec: - {{- if not .Values.autoscaling.enabled }} - replicas: {{ .Values.replicaCount }} - {{- end }} - selector: - matchLabels: - {{- include "fcoscore.selectorLabels" . | nindent 6 }} - template: - metadata: - {{- with .Values.podAnnotations }} - annotations: - {{- toYaml . | nindent 8 }} - {{- end }} - labels: - {{- include "fcoscore.selectorLabels" . | nindent 8 }} - spec: - {{- with .Values.imagePullSecrets }} - imagePullSecrets: - {{- toYaml . | nindent 8 }} - {{- end }} - serviceAccountName: {{ include "fcoscore.serviceAccountName" . }} - securityContext: - {{- toYaml .Values.podSecurityContext | nindent 8 }} - containers: - - name: {{ .Values.frontend.name }} - securityContext: - {{- toYaml .Values.securityContext | nindent 12 }} - image: "{{ .Values.frontend.repository }}:{{ .Values.frontend.tag | default .Chart.AppVersion }}" - imagePullPolicy: {{ .Values.frontend.pullPolicy }} - {{- if .Values.lifecycleHooks }} - lifecycle: {{- include "common.tplvalues.render" (dict "value" .Values.lifecycleHooks "context" $) | nindent 12 }} - {{- end }} - {{- if .Values.containerSecurityContext.enabled }} - securityContext: {{- omit .Values.containerSecurityContext "enabled" | toYaml | nindent 12 }} - {{- end }} - {{- if .Values.diagnosticMode.enabled }} - command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 12 }} - {{- else if .Values.command }} - command: {{- include "common.tplvalues.render" (dict "value" .Values.command "context" $) | nindent 12 }} - {{- end }} - {{- if .Values.diagnosticMode.enabled }} - args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 12 }} - {{- else if .Values.args }} - args: {{- include "common.tplvalues.render" (dict "value" .Values.args "context" $) | nindent 12 }} - {{- end }} - env: - - name: PORT - value: {{ .Values.frontend.service.port | quote }} - - name: BASE_URL - value: "https://gateway0.interfacer.dyne.org" - - name: NEXT_PUBLIC_ZENFLOWS_ADMIN - valueFrom: - secretKeyRef: - name: {{ include "zenflow.secretName" . }} - key: admin-key - - name: NEXT_PUBLIC_INVITATION_KEY - valueFrom: - secretKeyRef: - name: {{ include "zenflow.secretName" . }} - key: invitation-key - ports: - - name: http - containerPort: {{ .Values.frontend.service.port }} - protocol: TCP - livenessProbe: - httpGet: - path: / - port: http - readinessProbe: - httpGet: - path: / - port: http - resources: - {{- toYaml .Values.resources | nindent 12 }} - {{- 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/templates/frontend/deployment.yaml b/templates/frontend/deployment.yaml new file mode 100644 index 0000000..279747b --- /dev/null +++ b/templates/frontend/deployment.yaml @@ -0,0 +1,95 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "fcoscore.frontend.fullname" . }} + labels: + {{- include "fcoscore.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "fcoscore.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "fcoscore.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "fcoscore.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ include "fcoscore.frontend.fullname" . }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.frontend.repository }}:{{ .Values.frontend.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.frontend.pullPolicy }} + {{- if .Values.lifecycleHooks }} + lifecycle: {{- include "common.tplvalues.render" (dict "value" .Values.lifecycleHooks "context" $) | nindent 12 }} + {{- end }} + {{- if .Values.containerSecurityContext.enabled }} + securityContext: {{- omit .Values.containerSecurityContext "enabled" | toYaml | nindent 12 }} + {{- end }} + {{- if .Values.diagnosticMode.enabled }} + command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 12 }} + {{- else if .Values.command }} + command: {{- include "common.tplvalues.render" (dict "value" .Values.command "context" $) | nindent 12 }} + {{- end }} + {{- if .Values.diagnosticMode.enabled }} + args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 12 }} + {{- else if .Values.args }} + args: {{- include "common.tplvalues.render" (dict "value" .Values.args "context" $) | nindent 12 }} + {{- end }} + env: + - name: PORT + value: {{ .Values.frontend.service.port | quote }} + - name: BASE_URL + # TODO: + # value: "{{ include "fcoscore.gateway.url" . }}" + value: https://gateway0.interfacer.dyne.org/ + - name: NEXT_PUBLIC_ZENFLOWS_ADMIN + valueFrom: + secretKeyRef: + name: {{ include "fcoscore.secretName" . }} + key: admin-key + - name: NEXT_PUBLIC_INVITATION_KEY + valueFrom: + secretKeyRef: + name: {{ include "fcoscore.secretName" . }} + key: invitation-key + ports: + - name: http + containerPort: {{ .Values.frontend.service.port }} + protocol: TCP + livenessProbe: + httpGet: + path: / + port: http + readinessProbe: + httpGet: + path: / + port: http + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- 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/templates/frontend/hpa.yaml b/templates/frontend/hpa.yaml new file mode 100644 index 0000000..31b9d99 --- /dev/null +++ b/templates/frontend/hpa.yaml @@ -0,0 +1,29 @@ +--- +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "fcoscore.frontend.fullname" . }} + labels: + {{- include "fcoscore.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "fcoscore.frontend.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/templates/frontend/service.yaml b/templates/frontend/service.yaml new file mode 100644 index 0000000..6a503eb --- /dev/null +++ b/templates/frontend/service.yaml @@ -0,0 +1,16 @@ +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ include "fcoscore.frontend.fullname" . }} + labels: + {{- include "fcoscore.labels" . | nindent 4 }} +spec: + type: {{ .Values.zenflow.service.type }} + ports: + - port: {{ .Values.zenflow.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "fcoscore.selectorLabels" . | nindent 4 }} diff --git a/templates/gateway/deployment.yaml b/templates/gateway/deployment.yaml new file mode 100644 index 0000000..28d9528 --- /dev/null +++ b/templates/gateway/deployment.yaml @@ -0,0 +1,75 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "fcoscore.gateway.fullname" . }} + labels: + {{- include "fcoscore.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "fcoscore.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "fcoscore.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "fcoscore.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ include "fcoscore.gateway.fullname" . }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.gateway.repository }}:{{ .Values.gateway.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.gateway.pullPolicy }} + {{- if .Values.lifecycleHooks }} + lifecycle: {{- include "common.tplvalues.render" (dict "value" .Values.lifecycleHooks "context" $) | nindent 12 }} + {{- end }} + {{- if .Values.containerSecurityContext.enabled }} + securityContext: {{- omit .Values.containerSecurityContext "enabled" | toYaml | nindent 12 }} + {{- end }} + {{- if .Values.diagnosticMode.enabled }} + command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 12 }} + {{- else if .Values.command }} + command: {{- include "common.tplvalues.render" (dict "value" .Values.command "context" $) | nindent 12 }} + {{- end }} + {{- if .Values.diagnosticMode.enabled }} + args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 12 }} + {{- else if .Values.args }} + args: {{- include "common.tplvalues.render" (dict "value" .Values.args "context" $) | nindent 12 }} + {{- end }} + env: + - name: ZENFLOWS + value: {{ template "fcoscore.zenflow.url" . }} + - name: PORT + value: {{ template "fcoscore.zvmlet.port" . }} + ports: + - name: http + containerPort: {{ .Values.gateway.service.port }} + protocol: TCP + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- 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/templates/gateway/hpa.yaml b/templates/gateway/hpa.yaml new file mode 100644 index 0000000..34d20cc --- /dev/null +++ b/templates/gateway/hpa.yaml @@ -0,0 +1,29 @@ +--- +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "fcoscore.gateway.fullname" . }} + labels: + {{- include "fcoscore.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "fcoscore.gateway.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/templates/gateway/service.yaml b/templates/gateway/service.yaml new file mode 100644 index 0000000..f0fe64a --- /dev/null +++ b/templates/gateway/service.yaml @@ -0,0 +1,16 @@ +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ include "fcoscore.gateway.fullname" . }} + labels: + {{- include "fcoscore.labels" . | nindent 4 }} +spec: + type: {{ .Values.gateway.service.type }} + ports: + - port: {{ .Values.gateway.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "fcoscore.selectorLabels" . | nindent 4 }} diff --git a/templates/ingress.yaml b/templates/ingress.yaml deleted file mode 100644 index df3597f..0000000 --- a/templates/ingress.yaml +++ /dev/null @@ -1,62 +0,0 @@ -{{- if .Values.ingress.enabled -}} -{{- $fullName := include "fcoscore.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 "fcoscore.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/templates/service.yaml b/templates/service.yaml deleted file mode 100644 index c86dbc5..0000000 --- a/templates/service.yaml +++ /dev/null @@ -1,48 +0,0 @@ ---- -apiVersion: v1 -kind: Service -metadata: - name: "{{ .Chart.Name }}-{{ .Values.zenflow.name }}" - labels: - {{- include "fcoscore.labels" . | nindent 4 }} -spec: - type: {{ .Values.zenflow.service.type }} - ports: - - port: {{ .Values.zenflow.service.port }} - targetPort: http - protocol: TCP - name: http - selector: - {{- include "fcoscore.selectorLabels" . | nindent 4 }} ---- -apiVersion: v1 -kind: Service -metadata: - name: "{{ .Chart.Name }}-{{ .Values.zvmlet.name }}" - labels: - {{- include "fcoscore.labels" . | nindent 4 }} -spec: - type: {{ .Values.zvmlet.service.type }} - ports: - - port: {{ .Values.zvmlet.service.port }} - targetPort: http - protocol: TCP - name: http - selector: - {{- include "fcoscore.selectorLabels" . | nindent 4 }} ---- -apiVersion: v1 -kind: Service -metadata: - name: "{{ .Chart.Name }}-{{ .Values.frontend.name }}" - labels: - {{- include "fcoscore.labels" . | nindent 4 }} -spec: - type: {{ .Values.frontend.service.type }} - ports: - - port: {{ .Values.frontend.service.port }} - targetPort: http - protocol: TCP - name: http - selector: - {{- include "fcoscore.selectorLabels" . | nindent 4 }} diff --git a/templates/zenflow/deployment.yaml b/templates/zenflow/deployment.yaml new file mode 100644 index 0000000..1a5e58a --- /dev/null +++ b/templates/zenflow/deployment.yaml @@ -0,0 +1,100 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "fcoscore.zenflow.fullname" . }} + labels: + {{- include "fcoscore.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "fcoscore.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "fcoscore.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "fcoscore.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ include "fcoscore.zenflow.fullname" . }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.zenflow.repository }}:{{ .Values.zenflow.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.zenflow.pullPolicy }} + {{- if .Values.lifecycleHooks }} + lifecycle: {{- include "common.tplvalues.render" (dict "value" .Values.lifecycleHooks "context" $) | nindent 12 }} + {{- end }} + {{- if .Values.containerSecurityContext.enabled }} + securityContext: {{- omit .Values.containerSecurityContext "enabled" | toYaml | nindent 12 }} + {{- end }} + {{- if .Values.diagnosticMode.enabled }} + command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 12 }} + {{- else if .Values.command }} + command: {{- include "common.tplvalues.render" (dict "value" .Values.command "context" $) | nindent 12 }} + {{- end }} + {{- if .Values.diagnosticMode.enabled }} + args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 12 }} + {{- else if .Values.args }} + args: {{- include "common.tplvalues.render" (dict "value" .Values.args "context" $) | nindent 12 }} + {{- end }} + env: + {{- if or .Values.postgresql.enabled .Values.externalDatabase.create }} + - name: DB_HOST + value: {{ template "fcoscore.database.host" . }} + - name: DB_PORT + value: {{ template "fcoscore.database.port" . }} + - name: DB_NAME + value: {{ template "fcoscore.database.name" . }} + - name: DB_USER + value: {{ template "fcoscore.database.user" . }} + - name: DB_PASS + valueFrom: + secretKeyRef: + name: {{ include "fcoscore.database.secretName" . }} + key: {{ include "fcoscore.database.secretPasswordKey" . }} + {{- end }} + - name: ROOM_HOST + value: {{ template "fcoscore.zvmlet.host" . }} + - name: ROOM_PORT + value: {{ template "fcoscore.zvmlet.port" . }} + - name: ROOM_SALT + valueFrom: + secretKeyRef: + name: {{ include "fcoscore.secretName" . }} + key: room-salt + - name: ADMIN_KEY + valueFrom: + secretKeyRef: + name: {{ include "fcoscore.secretName" . }} + key: admin-key + ports: + - name: http + containerPort: {{ .Values.zenflow.service.port }} + protocol: TCP + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- 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/templates/zenflow/hpa.yaml b/templates/zenflow/hpa.yaml new file mode 100644 index 0000000..65b6534 --- /dev/null +++ b/templates/zenflow/hpa.yaml @@ -0,0 +1,29 @@ +--- +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "fcoscore.zenflow.fullname" . }} + labels: + {{- include "fcoscore.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "fcoscore.zenflow.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/templates/zenflow/service.yaml b/templates/zenflow/service.yaml new file mode 100644 index 0000000..779ad3e --- /dev/null +++ b/templates/zenflow/service.yaml @@ -0,0 +1,16 @@ +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ include "fcoscore.zenflow.fullname" . }} + labels: + {{- include "fcoscore.labels" . | nindent 4 }} +spec: + type: {{ .Values.zenflow.service.type }} + ports: + - port: {{ .Values.zenflow.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "fcoscore.selectorLabels" . | nindent 4 }} diff --git a/templates/zvmlet/deployment.yaml b/templates/zvmlet/deployment.yaml new file mode 100644 index 0000000..2f1a989 --- /dev/null +++ b/templates/zvmlet/deployment.yaml @@ -0,0 +1,81 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "fcoscore.zvmlet.fullname" . }} + labels: + {{- include "fcoscore.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "fcoscore.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "fcoscore.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "fcoscore.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ include "fcoscore.zvmlet.fullname" . }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.zvmlet.repository }}:{{ .Values.zvmlet.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.zvmlet.pullPolicy }} + {{- if .Values.lifecycleHooks }} + lifecycle: {{- include "common.tplvalues.render" (dict "value" .Values.lifecycleHooks "context" $) | nindent 12 }} + {{- end }} + {{- if .Values.containerSecurityContext.enabled }} + securityContext: {{- omit .Values.containerSecurityContext "enabled" | toYaml | nindent 12 }} + {{- end }} + {{- if .Values.diagnosticMode.enabled }} + command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 12 }} + {{- else if .Values.command }} + command: {{- include "common.tplvalues.render" (dict "value" .Values.command "context" $) | nindent 12 }} + {{- end }} + {{- if .Values.diagnosticMode.enabled }} + args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 12 }} + {{- else if .Values.args }} + args: {{- include "common.tplvalues.render" (dict "value" .Values.args "context" $) | nindent 12 }} + {{- end }} + env: + - name: HTTP_PORT + value: {{ .Values.zvmlet.service.port | quote }} + ports: + - name: http + containerPort: {{ .Values.zvmlet.service.port }} + protocol: TCP + livenessProbe: + httpGet: + path: /docs/ + port: http + readinessProbe: + httpGet: + path: /docs/ + port: http + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- 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/templates/hpa.yaml b/templates/zvmlet/hpa.yaml similarity index 88% rename from templates/hpa.yaml rename to templates/zvmlet/hpa.yaml index 6a28861..2cb443e 100644 --- a/templates/hpa.yaml +++ b/templates/zvmlet/hpa.yaml @@ -3,14 +3,14 @@ apiVersion: autoscaling/v2beta1 kind: HorizontalPodAutoscaler metadata: - name: {{ include "fcoscore.fullname" . }} + name: {{ include "fcoscore.zvmlet.fullname" . }} labels: {{- include "fcoscore.labels" . | nindent 4 }} spec: scaleTargetRef: apiVersion: apps/v1 kind: Deployment - name: {{ include "fcoscore.fullname" . }} + name: {{ include "fcoscore.zvmlet.fullname" . }} minReplicas: {{ .Values.autoscaling.minReplicas }} maxReplicas: {{ .Values.autoscaling.maxReplicas }} metrics: diff --git a/templates/zvmlet/service.yaml b/templates/zvmlet/service.yaml new file mode 100644 index 0000000..359925c --- /dev/null +++ b/templates/zvmlet/service.yaml @@ -0,0 +1,16 @@ +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ include "fcoscore.zvmlet.fullname" . }} + labels: + {{- include "fcoscore.labels" . | nindent 4 }} +spec: + type: {{ .Values.zvmlet.service.type }} + ports: + - port: {{ .Values.zvmlet.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "fcoscore.selectorLabels" . | nindent 4 }} diff --git a/values.yaml b/values.yaml index 62ab7bf..39806d7 100644 --- a/values.yaml +++ b/values.yaml @@ -176,7 +176,6 @@ affinity: {} ## @param image.debug Enable image debug mode ## zenflow: - name: zenflow registry: docker.io repository: fabcityhamburg/zenflows ## Specify a imagePullPolicy @@ -207,7 +206,6 @@ zenflow: salt: "" zvmlet: - name: zvmlet registry: docker.io repository: fabcityhamburg/zvmlet ## Specify a imagePullPolicy @@ -233,7 +231,6 @@ zvmlet: port: 3000 frontend: - name: interfacer-gui registry: docker.io repository: fabcityhamburg/interfacer-gui ## Specify a imagePullPolicy @@ -256,7 +253,32 @@ frontend: debug: false service: type: ClusterIP - port: 3030 + port: 8080 + +gateway: + registry: docker.io + repository: fabcityhamburg/interfacer-gateway + ## Specify a imagePullPolicy + ## Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent' + ## ref: https://kubernetes.io/docs/user-guide/images/#pre-pulling-images + ## + pullPolicy: IfNotPresent + ## Optionally specify an array of imagePullSecrets. + ## Secrets must be manually created in the namespace. + ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/ + ## e.g: + ## pullSecrets: + ## - myRegistryKeySecretName + ## + pullSecrets: [] + ## Set to true if you would like to see extra information on logs + ## + # Overrides the image tag whose default is the chart appVersion. + tag: "" + debug: false + service: + type: ClusterIP + port: 4040 ## Persistence Parameters ## ref: https://kubernetes.io/docs/user-guide/persistent-volumes/ @@ -384,7 +406,7 @@ postgresql: enabled: true auth: username: zenflow - database: fcos_zenflow + database: fcoscore_zenflow audit: logHostname: true logConnections: true