From b3826d6e95987028147f77a791395004414b91d9 Mon Sep 17 00:00:00 2001 From: Mark Rouse <67111550+markjrouse@users.noreply.github.com> Date: Thu, 15 Jun 2023 16:54:01 +0100 Subject: [PATCH] dma - Initial Chart (#9) --- README.md | 1 + charts/deploymanager/Chart.lock | 6 ++ charts/deploymanager/Chart.yaml | 14 +++ charts/deploymanager/templates/_helpers.tpl | 91 +++++++++++++++++++ charts/deploymanager/templates/configmap.yaml | 25 +++++ .../deploymanager/templates/deployment.yaml | 51 +++++++++++ charts/deploymanager/templates/secrets.yaml | 10 ++ charts/deploymanager/templates/svc.yaml | 17 ++++ .../deploymanager/templates/svcaccount.yaml | 12 +++ charts/deploymanager/values.yaml | 45 +++++++++ 10 files changed, 272 insertions(+) create mode 100644 charts/deploymanager/Chart.lock create mode 100644 charts/deploymanager/Chart.yaml create mode 100644 charts/deploymanager/templates/_helpers.tpl create mode 100644 charts/deploymanager/templates/configmap.yaml create mode 100644 charts/deploymanager/templates/deployment.yaml create mode 100644 charts/deploymanager/templates/secrets.yaml create mode 100644 charts/deploymanager/templates/svc.yaml create mode 100644 charts/deploymanager/templates/svcaccount.yaml create mode 100644 charts/deploymanager/values.yaml diff --git a/README.md b/README.md index c16437f..081c055 100644 --- a/README.md +++ b/README.md @@ -4,3 +4,4 @@ A collection of [helm](https://helm.sh) charts created by Digital Catapult for i * [casemanager](charts/casemanager/Chart.yaml) - Deploy the Case Manager microservice * [testmanager](charts/testmanager/Chart.yaml) - Deploy the Test Manager microservice +* [deploymanager](charts/deploymanager/Chart.yaml) - Deploy the Deploy Manager microservice diff --git a/charts/deploymanager/Chart.lock b/charts/deploymanager/Chart.lock new file mode 100644 index 0000000..fa114da --- /dev/null +++ b/charts/deploymanager/Chart.lock @@ -0,0 +1,6 @@ +dependencies: +- name: postgresql + repository: https://charts.bitnami.com/bitnami + version: 12.5.7 +digest: sha256:1b88720b28cd097236ebb696fc76a6fccabe0fe46fa72050cfd56657b0d1c686 +generated: "2023-06-13T11:48:37.838701+01:00" diff --git a/charts/deploymanager/Chart.yaml b/charts/deploymanager/Chart.yaml new file mode 100644 index 0000000..3e272f7 --- /dev/null +++ b/charts/deploymanager/Chart.yaml @@ -0,0 +1,14 @@ +apiVersion: v2 +name: deploymanager +appVersion: 0.1.1 +description: A generated Helm Chart for Soniclabs T&M deploymanager +version: 0.0.1 +type: application +maintainers: + - name: cdecatapult + url: cdecatapult.github.io/soniclabs-helmcharts +dependencies: + - name: postgresql + version: '^12.1.14' + repository: https://charts.bitnami.com/bitnami + condition: postgresql.enabled diff --git a/charts/deploymanager/templates/_helpers.tpl b/charts/deploymanager/templates/_helpers.tpl new file mode 100644 index 0000000..31ee327 --- /dev/null +++ b/charts/deploymanager/templates/_helpers.tpl @@ -0,0 +1,91 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "deploymanager.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 "deploymanager.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 "deploymanager.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "deploymanager.labels" -}} +helm.sh/chart: {{ include "deploymanager.chart" . }} +{{ include "deploymanager.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "deploymanager.selectorLabels" -}} +app.kubernetes.io/name: {{ include "deploymanager.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "deploymanager.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "deploymanager.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} + +{{/* +Create a default fully qualified postgresql name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +*/}} +{{- define "deploymanager.postgresql.fullname" -}} +{{- if .Values.config.externalPostgresql -}} +{{ .Values.config.externalPostgresql | trunc 63 | trimSuffix "-" -}} +{{- else if not ( .Values.postgresql.enabled ) -}} +{{ fail "Postgresql must either be enabled or passed via config.externalPostgresql" }} +{{- else if .Values.postgresql.fullnameOverride -}} +{{- .Values.postgresql.fullnameOverride | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- $name := default "postgresql" .Values.postgresql.nameOverride -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} +{{- end -}} + +{{/* +Conditionally populate imagePullSecrets if present in the context +*/}} +{{- define "deploymanager.imagePullSecrets" -}} + {{- if (not (empty .Values.image.pullSecrets)) }} +imagePullSecrets: + {{- range .Values.image.pullSecrets }} + - name: {{ . }} + {{- end }} + {{- end }} +{{- end -}} diff --git a/charts/deploymanager/templates/configmap.yaml b/charts/deploymanager/templates/configmap.yaml new file mode 100644 index 0000000..d2b1e61 --- /dev/null +++ b/charts/deploymanager/templates/configmap.yaml @@ -0,0 +1,25 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "deploymanager.fullname" . }}-config + labels: + {{- include "deploymanager.labels" . | nindent 4 }} +data: + APP_DEBUG: {{ .Values.config.debug | quote }} + APP_LOG_LEVEL: {{ .Values.config.logLevel | quote }} + POSTGRES_HOST: {{ include "deploymanager.postgresql.fullname" . }} + POSTGRES_DB: {{ .Values.postgresql.auth.database | quote }} + TAM_GUI_HOST: {{ .Values.config.guiHost | quote }} + TAM_GUI_PORT: {{ .Values.config.guiPort | quote }} + TAM_CONFIG_MANAGER_HOST: {{ .Values.config.cmaHost | quote }} + TAM_CONFIG_MANAGER_PORT: {{ .Values.config.cmaPort | quote }} + TAM_CASE_MANAGER_HOST: {{ .Values.config.camHost | quote }} + TAM_CASE_MANAGER_PORT: {{ .Values.config.camPort | quote }} + TAM_TEST_MANAGER_HOST: {{ .Values.config.tmaHost | quote }} + TAM_TEST_MANAGER_PORT: {{ .Values.config.tmaPort | quote }} + TAM_RESULTS_MANAGER_HOST: {{ .Values.config.rmaHost | quote }} + TAM_RESULTS_MANAGER_PORT: {{ .Values.config.rmaPort | quote }} + TAM_API_GATEWAY_HOST: {{ .Values.config.apgHost | quote }} + TAM_API_GATEWAY_PORT: {{ .Values.config.apgPort | quote }} + TAM_DEPLOY_MANAGER_HOST: {{ .Values.config.dmaHost | quote }} + TAM_DEPLOY_MANAGER_PORT: {{ .Values.config.dmaPort | quote }} diff --git a/charts/deploymanager/templates/deployment.yaml b/charts/deploymanager/templates/deployment.yaml new file mode 100644 index 0000000..a76b342 --- /dev/null +++ b/charts/deploymanager/templates/deployment.yaml @@ -0,0 +1,51 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "deploymanager.fullname" . }}-app + labels: + {{- include "deploymanager.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.config.replicaCount }} + selector: + matchLabels: + name: {{ include "deploymanager.fullname" . }}-app + template: + metadata: + annotations: + checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }} + checksum/secret: {{ include (print $.Template.BasePath "/secrets.yaml") . | sha256sum }} + labels: + name: {{ include "deploymanager.fullname" . }}-app + spec: + {{- include "deploymanager.imagePullSecrets" . | indent 6 }} + initContainers: + - name: {{ include "deploymanager.fullname" . }}-init + image: {{ .Values.image.repository }}:{{ .Values.image.tag }} + command: ['sleep', '60'] + containers: + - name: {{ include "deploymanager.fullname" . }}-app + image: {{ .Values.image.repository }}:{{ .Values.image.tag }} + imagePullPolicy: {{ .Values.image.pullPolicy | quote }} + ports: + - containerPort: {{ .Values.config.appPort }} + livenessProbe: + httpGet: + path: /api/dma/healthchecks/readiness + port: {{ .Values.config.appPort }} + initialDelaySeconds: 15 + timeoutSeconds: 15 + periodSeconds: 15 + envFrom: + - configMapRef: + name: {{ include "deploymanager.fullname" . }}-config + - secretRef: + name: {{ include "deploymanager.fullname" . }}-secret + env: + - name: HOST_IP + valueFrom: + fieldRef: + fieldPath: status.hostIP + - name: POD_IP + valueFrom: + fieldRef: + fieldPath: status.podIP diff --git a/charts/deploymanager/templates/secrets.yaml b/charts/deploymanager/templates/secrets.yaml new file mode 100644 index 0000000..def7145 --- /dev/null +++ b/charts/deploymanager/templates/secrets.yaml @@ -0,0 +1,10 @@ +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "deploymanager.fullname" . }}-secret + labels: + {{- include "deploymanager.labels" . | nindent 4 }} +type: Opaque +data: + POSTGRES_PASSWORD: {{ .Values.postgresql.auth.password | b64enc | quote }} + POSTGRES_USER: {{ .Values.postgresql.auth.username | b64enc | quote }} diff --git a/charts/deploymanager/templates/svc.yaml b/charts/deploymanager/templates/svc.yaml new file mode 100644 index 0000000..b13d919 --- /dev/null +++ b/charts/deploymanager/templates/svc.yaml @@ -0,0 +1,17 @@ +{{- $fullName := include "deploymanager.fullname" . -}} +apiVersion: v1 +kind: Service +metadata: + name: {{ $fullName }} + labels: + {{- include "deploymanager.labels" . | nindent 4 }} +spec: + type: {{ .Values.config.type }} + ports: + - port: {{ .Values.config.appPort }} + targetPort: {{ .Values.config.appPort }} + nodePort: {{ .Values.config.nodePort }} + protocol: TCP + name: http + selector: + name: {{ include "deploymanager.fullname" . }}-app diff --git a/charts/deploymanager/templates/svcaccount.yaml b/charts/deploymanager/templates/svcaccount.yaml new file mode 100644 index 0000000..02b9151 --- /dev/null +++ b/charts/deploymanager/templates/svcaccount.yaml @@ -0,0 +1,12 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "deploymanager.serviceAccountName" . }} + labels: + {{- include "deploymanager.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/charts/deploymanager/values.yaml b/charts/deploymanager/values.yaml new file mode 100644 index 0000000..b00888b --- /dev/null +++ b/charts/deploymanager/values.yaml @@ -0,0 +1,45 @@ +postgresql: + enabled: true + auth: + username: tamuser + password: tampassword + database: deploymanager + +config: + replicaCount: 1 + appPort: 8000 + type: LoadBalancer + nodePort: 30315 + debug: "True" + logLevel: DEBUG + guiHost: portal + guiPort: 8000 + cmaHost: configmanager + cmaPort: 8000 + camHost: casemanager + camPort: 8000 + tmaHost: testmanager + tmaPort: 8000 + rmaHost: resultsmanager + rmaPort: 8000 + apgHost: apigateway + apgPort: 8000 + dmaHost: deploymanager + dmaPort: 8000 + +image: + repository: ghcr.io/cdecatapult/soniclabs-deploymanager + pullPolicy: Always + tag: latest + pullSecrets: ['soniclabs'] + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + +serviceAccount: + create: false + annotations: {} + name: ""