From c05fdb18f9f67a570f73a1bc0b806b5073ed7cea Mon Sep 17 00:00:00 2001 From: iamvigneshwars Date: Wed, 6 Mar 2024 11:43:36 +0000 Subject: [PATCH] Add helm chart for compound soaking --- .devcontainer/docker-compose.yaml | 2 +- charts/xchemlab/Chart.lock | 7 +- charts/xchemlab/Chart.yaml | 5 +- .../charts/compound-soaking/Chart.yaml | 15 ++++ .../compound-soaking/templates/_helpers.tpl | 73 +++++++++++++++++++ .../templates/deployment.yaml | 63 ++++++++++++++++ .../compound-soaking/templates/service.yaml | 15 ++++ .../templates/serviceaccount.yaml | 12 +++ .../charts/compound-soaking/values.yaml | 43 +++++++++++ charts/xchemlab/values.yaml | 11 +++ 10 files changed, 242 insertions(+), 4 deletions(-) create mode 100644 charts/xchemlab/charts/compound-soaking/Chart.yaml create mode 100644 charts/xchemlab/charts/compound-soaking/templates/_helpers.tpl create mode 100644 charts/xchemlab/charts/compound-soaking/templates/deployment.yaml create mode 100644 charts/xchemlab/charts/compound-soaking/templates/service.yaml create mode 100644 charts/xchemlab/charts/compound-soaking/templates/serviceaccount.yaml create mode 100644 charts/xchemlab/charts/compound-soaking/values.yaml diff --git a/.devcontainer/docker-compose.yaml b/.devcontainer/docker-compose.yaml index fd99f802..2b7f74b4 100644 --- a/.devcontainer/docker-compose.yaml +++ b/.devcontainer/docker-compose.yaml @@ -11,7 +11,7 @@ services: command: - --dev - -config - - config/router.yaml + - /dist/config/router.yaml - -supergraph - schema/supergraph.graphql diff --git a/charts/xchemlab/Chart.lock b/charts/xchemlab/Chart.lock index 43ab0c9d..8799909a 100644 --- a/charts/xchemlab/Chart.lock +++ b/charts/xchemlab/Chart.lock @@ -5,6 +5,9 @@ dependencies: - name: compound-library repository: "" version: 0.0.1 +- name: compound-soaking + repository: "" + version: 0.0.1 - name: crystal-library repository: "" version: 0.0.1 @@ -38,5 +41,5 @@ dependencies: - name: oauth2-proxy repository: oci://registry-1.docker.io/bitnamicharts version: 3.7.4 -digest: sha256:e2987ea5e22dfa308a63f6f5e029d90bbc3cbd1c926161a2b72aa23ff7605825 -generated: "2024-03-05T14:33:24.387624369Z" +digest: sha256:2738fe6bf788e283ebdd64f5bbf8c0094b9e7271b40fe693b661117d4bed9eb9 +generated: "2024-03-06T11:37:40.525320982Z" diff --git a/charts/xchemlab/Chart.yaml b/charts/xchemlab/Chart.yaml index e1493f9f..10476304 100644 --- a/charts/xchemlab/Chart.yaml +++ b/charts/xchemlab/Chart.yaml @@ -6,7 +6,7 @@ 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.8.0 +version: 0.9.0 dependencies: - name: chimp-chomp @@ -15,6 +15,9 @@ dependencies: - name: compound-library version: 0.0.1 condition: compound-library.enabled + - name: compound-soaking + version: 0.0.1 + condition: compound-soaking.enabled - name: crystal-library version: 0.0.1 condition: crystal-library.enabled diff --git a/charts/xchemlab/charts/compound-soaking/Chart.yaml b/charts/xchemlab/charts/compound-soaking/Chart.yaml new file mode 100644 index 00000000..c813da41 --- /dev/null +++ b/charts/xchemlab/charts/compound-soaking/Chart.yaml @@ -0,0 +1,15 @@ +apiVersion: v2 +name: compound-soaking +description: A service for tracking soaked compounds currently available in the XChem lab +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.0.1 + +# 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: "0.0.6" diff --git a/charts/xchemlab/charts/compound-soaking/templates/_helpers.tpl b/charts/xchemlab/charts/compound-soaking/templates/_helpers.tpl new file mode 100644 index 00000000..3ed00917 --- /dev/null +++ b/charts/xchemlab/charts/compound-soaking/templates/_helpers.tpl @@ -0,0 +1,73 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "compoundSoaking.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 "compoundSoaking.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 "compoundSoaking.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "compoundSoaking.labels" -}} +helm.sh/chart: {{ include "compoundSoaking.chart" . }} +{{ include "compoundSoaking.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "compoundSoaking.selectorLabels" -}} +app.kubernetes.io/name: {{ include "compoundSoaking.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "compoundSoaking.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "xchemlab.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} + +{{/* +Create the database URL string +*/}} +{{- define "compoundSoaking.databaseURL" -}} +{{- $host_parts := urlParse .Values.database.host }} +{{- $raw_user_info := printf "%s:$DATABASE_PASSWORD" .Values.database.user }} +{{- $url_parts := set $host_parts "userinfo" $raw_user_info }} +{{- $raw_database_url := urlJoin $url_parts }} +{{- replace "$DATABASE_PASSWORD" "$(DATABASE_PASSWORD)" $raw_database_url }} +{{- end }} diff --git a/charts/xchemlab/charts/compound-soaking/templates/deployment.yaml b/charts/xchemlab/charts/compound-soaking/templates/deployment.yaml new file mode 100644 index 00000000..a96359e5 --- /dev/null +++ b/charts/xchemlab/charts/compound-soaking/templates/deployment.yaml @@ -0,0 +1,63 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "compoundSoaking.fullname" . }} + labels: + {{- include "compoundSoaking.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + {{- include "compoundSoaking.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "compoundSoaking.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "compoundSoaking.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 }} + args: + - serve + env: + - name: DATABASE_PASSWORD + valueFrom: + secretKeyRef: + name: {{ .Values.database.password.secretName }} + key: {{ .Values.database.password.secretKey }} + - name: DATABASE_URL + value: {{ include "compoundSoaking.databaseURL" . }} + - name: OPA_URL + value: {{ tpl .Values.opa.url . }} + ports: + - name: http + containerPort: {{ .Values.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/charts/xchemlab/charts/compound-soaking/templates/service.yaml b/charts/xchemlab/charts/compound-soaking/templates/service.yaml new file mode 100644 index 00000000..7d594725 --- /dev/null +++ b/charts/xchemlab/charts/compound-soaking/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "compoundSoaking.fullname" . }} + labels: + {{- include "compoundSoaking.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "compoundSoaking.selectorLabels" . | nindent 4 }} diff --git a/charts/xchemlab/charts/compound-soaking/templates/serviceaccount.yaml b/charts/xchemlab/charts/compound-soaking/templates/serviceaccount.yaml new file mode 100644 index 00000000..fbf3ecbb --- /dev/null +++ b/charts/xchemlab/charts/compound-soaking/templates/serviceaccount.yaml @@ -0,0 +1,12 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "compoundSoaking.serviceAccountName" . }} + labels: + {{- include "compoundSoaking.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/charts/xchemlab/charts/compound-soaking/values.yaml b/charts/xchemlab/charts/compound-soaking/values.yaml new file mode 100644 index 00000000..0336ea52 --- /dev/null +++ b/charts/xchemlab/charts/compound-soaking/values.yaml @@ -0,0 +1,43 @@ +nameOverride: "" +fullnameOverride: "" + +image: + repository: ghcr.io/diamondlightsource/xchemlab-compound-soaking + pullPolicy: Always + tag: "" + +imagePullSecrets: [] + +database: + host: "" + user: "" + password: + secretName: "" + secretKey: "" + +opa: + url: "" + +replicaCount: 1 + +service: + type: ClusterIP + port: 80 + +serviceAccount: + create: false + name: "" + +podAnnotations: {} + +podSecurityContext: {} + +securityContext: {} + +resources: {} + +nodeSelector: {} + +tolerations: [] + +affinity: {} diff --git a/charts/xchemlab/values.yaml b/charts/xchemlab/values.yaml index eab41862..352a55b0 100644 --- a/charts/xchemlab/values.yaml +++ b/charts/xchemlab/values.yaml @@ -30,6 +30,17 @@ compound-library: opa: url: http://{{ .Release.Name }}-opa-kube-mgmt:8181 +compound-soaking: + enabled: true + database: + host: postgres://postgresql-ha-pgpool + user: postgres + password: + secretName: postgres-passwords + secretKey: password + opa: + url: http://{{ .Release.Name }}-opa-kube-mgmt:8181 + crystal-library: enabled: true database: