From fcedc27d18c604e57d7e77aca781c101f326d9de Mon Sep 17 00:00:00 2001 From: iamvigneshwars Date: Tue, 5 Mar 2024 12:08:09 +0000 Subject: [PATCH 1/3] Rename service name in helm chart for compound library --- .../compound-library/templates/_helpers.tpl | 20 +++++++++---------- .../templates/deployment.yaml | 12 +++++------ .../compound-library/templates/service.yaml | 6 +++--- .../templates/serviceaccount.yaml | 4 ++-- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/charts/xchemlab/charts/compound-library/templates/_helpers.tpl b/charts/xchemlab/charts/compound-library/templates/_helpers.tpl index 26450c4b..10c49b56 100644 --- a/charts/xchemlab/charts/compound-library/templates/_helpers.tpl +++ b/charts/xchemlab/charts/compound-library/templates/_helpers.tpl @@ -1,7 +1,7 @@ {{/* Expand the name of the chart. */}} -{{- define "pinPacking.name" -}} +{{- define "compoundLibrary.name" -}} {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} {{- end }} @@ -10,7 +10,7 @@ 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 "pinPacking.fullname" -}} +{{- define "compoundLibrary.fullname" -}} {{- if .Values.fullnameOverride }} {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} {{- else }} @@ -26,16 +26,16 @@ If release name contains chart name it will be used as a full name. {{/* Create chart name and version as used by the chart label. */}} -{{- define "pinPacking.chart" -}} +{{- define "compoundLibrary.chart" -}} {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} {{- end }} {{/* Common labels */}} -{{- define "pinPacking.labels" -}} -helm.sh/chart: {{ include "pinPacking.chart" . }} -{{ include "pinPacking.selectorLabels" . }} +{{- define "compoundLibrary.labels" -}} +helm.sh/chart: {{ include "compoundLibrary.chart" . }} +{{ include "compoundLibrary.selectorLabels" . }} {{- if .Chart.AppVersion }} app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} {{- end }} @@ -45,15 +45,15 @@ app.kubernetes.io/managed-by: {{ .Release.Service }} {{/* Selector labels */}} -{{- define "pinPacking.selectorLabels" -}} -app.kubernetes.io/name: {{ include "pinPacking.name" . }} +{{- define "compoundLibrary.selectorLabels" -}} +app.kubernetes.io/name: {{ include "compoundLibrary.name" . }} app.kubernetes.io/instance: {{ .Release.Name }} {{- end }} {{/* Create the name of the service account to use */}} -{{- define "pinPacking.serviceAccountName" -}} +{{- define "compoundLibrary.serviceAccountName" -}} {{- if .Values.serviceAccount.create }} {{- default (include "xchemlab.fullname" .) .Values.serviceAccount.name }} {{- else }} @@ -64,7 +64,7 @@ Create the name of the service account to use {{/* Create the database URL string */}} -{{- define "pinPacking.databaseURL" -}} +{{- define "compoundLibrary.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 }} diff --git a/charts/xchemlab/charts/compound-library/templates/deployment.yaml b/charts/xchemlab/charts/compound-library/templates/deployment.yaml index 83a48579..75e54d03 100644 --- a/charts/xchemlab/charts/compound-library/templates/deployment.yaml +++ b/charts/xchemlab/charts/compound-library/templates/deployment.yaml @@ -1,14 +1,14 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: {{ include "pinPacking.fullname" . }} + name: {{ include "compoundLibrary.fullname" . }} labels: - {{- include "pinPacking.labels" . | nindent 4 }} + {{- include "compoundLibrary.labels" . | nindent 4 }} spec: replicas: {{ .Values.replicaCount }} selector: matchLabels: - {{- include "pinPacking.selectorLabels" . | nindent 6 }} + {{- include "compoundLibrary.selectorLabels" . | nindent 6 }} template: metadata: {{- with .Values.podAnnotations }} @@ -16,13 +16,13 @@ spec: {{- toYaml . | nindent 8 }} {{- end }} labels: - {{- include "pinPacking.selectorLabels" . | nindent 8 }} + {{- include "compoundLibrary.selectorLabels" . | nindent 8 }} spec: {{- with .Values.imagePullSecrets }} imagePullSecrets: {{- toYaml . | nindent 8 }} {{- end }} - serviceAccountName: {{ include "pinPacking.serviceAccountName" . }} + serviceAccountName: {{ include "compoundLibrary.serviceAccountName" . }} securityContext: {{- toYaml .Values.podSecurityContext | nindent 8 }} containers: @@ -40,7 +40,7 @@ spec: name: {{ .Values.database.password.secretName }} key: {{ .Values.database.password.secretKey }} - name: DATABASE_URL - value: {{ include "pinPacking.databaseURL" . }} + value: {{ include "compoundLibrary.databaseURL" . }} - name: OPA_URL value: {{ tpl .Values.opa.url . }} ports: diff --git a/charts/xchemlab/charts/compound-library/templates/service.yaml b/charts/xchemlab/charts/compound-library/templates/service.yaml index 51f73bd5..b785d9a2 100644 --- a/charts/xchemlab/charts/compound-library/templates/service.yaml +++ b/charts/xchemlab/charts/compound-library/templates/service.yaml @@ -1,9 +1,9 @@ apiVersion: v1 kind: Service metadata: - name: {{ include "pinPacking.fullname" . }} + name: {{ include "compoundLibrary.fullname" . }} labels: - {{- include "pinPacking.labels" . | nindent 4 }} + {{- include "compoundLibrary.labels" . | nindent 4 }} spec: type: {{ .Values.service.type }} ports: @@ -12,4 +12,4 @@ spec: protocol: TCP name: http selector: - {{- include "pinPacking.selectorLabels" . | nindent 4 }} + {{- include "compoundLibrary.selectorLabels" . | nindent 4 }} diff --git a/charts/xchemlab/charts/compound-library/templates/serviceaccount.yaml b/charts/xchemlab/charts/compound-library/templates/serviceaccount.yaml index 4ed9da7c..512bab68 100644 --- a/charts/xchemlab/charts/compound-library/templates/serviceaccount.yaml +++ b/charts/xchemlab/charts/compound-library/templates/serviceaccount.yaml @@ -2,9 +2,9 @@ apiVersion: v1 kind: ServiceAccount metadata: - name: {{ include "pinPacking.serviceAccountName" . }} + name: {{ include "compoundLibrary.serviceAccountName" . }} labels: - {{- include "pinPacking.labels" . | nindent 4 }} + {{- include "compoundLibrary.labels" . | nindent 4 }} {{- with .Values.serviceAccount.annotations }} annotations: {{- toYaml . | nindent 4 }} From ae3734cb8327e729d44fc756bce5e8314f3b15be Mon Sep 17 00:00:00 2001 From: iamvigneshwars Date: Tue, 5 Mar 2024 12:44:01 +0000 Subject: [PATCH 2/3] Add crystal library helm chart --- charts/xchemlab/Chart.lock | 7 +- charts/xchemlab/Chart.yaml | 5 +- .../charts/crystal-library/Chart.yaml | 15 ++++ .../crystal-library/templates/_helpers.tpl | 73 +++++++++++++++++++ .../crystal-library/templates/deployment.yaml | 63 ++++++++++++++++ .../crystal-library/templates/service.yaml | 15 ++++ .../templates/serviceaccount.yaml | 12 +++ .../charts/crystal-library/values.yaml | 43 +++++++++++ charts/xchemlab/values.yaml | 13 +++- 9 files changed, 242 insertions(+), 4 deletions(-) create mode 100644 charts/xchemlab/charts/crystal-library/Chart.yaml create mode 100644 charts/xchemlab/charts/crystal-library/templates/_helpers.tpl create mode 100644 charts/xchemlab/charts/crystal-library/templates/deployment.yaml create mode 100644 charts/xchemlab/charts/crystal-library/templates/service.yaml create mode 100644 charts/xchemlab/charts/crystal-library/templates/serviceaccount.yaml create mode 100644 charts/xchemlab/charts/crystal-library/values.yaml diff --git a/charts/xchemlab/Chart.lock b/charts/xchemlab/Chart.lock index 97e52cab..43ab0c9d 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: crystal-library + repository: "" + version: 0.0.1 - name: pin-packing repository: "" version: 0.0.3 @@ -35,5 +38,5 @@ dependencies: - name: oauth2-proxy repository: oci://registry-1.docker.io/bitnamicharts version: 3.7.4 -digest: sha256:37e0bc3ab1b7e071e600dc4e8416c4e98bed058f54fec0b1ee7b488f2eabe8d7 -generated: "2024-02-19T17:22:02.993010787Z" +digest: sha256:e2987ea5e22dfa308a63f6f5e029d90bbc3cbd1c926161a2b72aa23ff7605825 +generated: "2024-03-05T14:33:24.387624369Z" diff --git a/charts/xchemlab/Chart.yaml b/charts/xchemlab/Chart.yaml index 650a28d1..e1493f9f 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.7.0 +version: 0.8.0 dependencies: - name: chimp-chomp @@ -15,6 +15,9 @@ dependencies: - name: compound-library version: 0.0.1 condition: compound-library.enabled + - name: crystal-library + version: 0.0.1 + condition: crystal-library.enabled - name: pin-packing version: 0.0.3 condition: pin-packing.enabled diff --git a/charts/xchemlab/charts/crystal-library/Chart.yaml b/charts/xchemlab/charts/crystal-library/Chart.yaml new file mode 100644 index 00000000..00048d4c --- /dev/null +++ b/charts/xchemlab/charts/crystal-library/Chart.yaml @@ -0,0 +1,15 @@ +apiVersion: v2 +name: crystal-library +description: A service for crystals 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.5" diff --git a/charts/xchemlab/charts/crystal-library/templates/_helpers.tpl b/charts/xchemlab/charts/crystal-library/templates/_helpers.tpl new file mode 100644 index 00000000..7d888c9a --- /dev/null +++ b/charts/xchemlab/charts/crystal-library/templates/_helpers.tpl @@ -0,0 +1,73 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "crystalLibrary.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 "crystalLibrary.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 "crystalLibrary.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "crystalLibrary.labels" -}} +helm.sh/chart: {{ include "crystalLibrary.chart" . }} +{{ include "crystalLibrary.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "crystalLibrary.selectorLabels" -}} +app.kubernetes.io/name: {{ include "crystalLibrary.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "crystalLibrary.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 "crystalLibrary.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/crystal-library/templates/deployment.yaml b/charts/xchemlab/charts/crystal-library/templates/deployment.yaml new file mode 100644 index 00000000..5ea372fe --- /dev/null +++ b/charts/xchemlab/charts/crystal-library/templates/deployment.yaml @@ -0,0 +1,63 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "crystalLibrary.fullname" . }} + labels: + {{- include "crystalLibrary.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + {{- include "crystalLibrary.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "crystalLibrary.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "crystalLibrary.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 "crystalLibrary.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/crystal-library/templates/service.yaml b/charts/xchemlab/charts/crystal-library/templates/service.yaml new file mode 100644 index 00000000..b37f953f --- /dev/null +++ b/charts/xchemlab/charts/crystal-library/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "crystalLibrary.fullname" . }} + labels: + {{- include "crystalLibrary.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "crystalLibrary.selectorLabels" . | nindent 4 }} diff --git a/charts/xchemlab/charts/crystal-library/templates/serviceaccount.yaml b/charts/xchemlab/charts/crystal-library/templates/serviceaccount.yaml new file mode 100644 index 00000000..817f5963 --- /dev/null +++ b/charts/xchemlab/charts/crystal-library/templates/serviceaccount.yaml @@ -0,0 +1,12 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "crystalLibrary.serviceAccountName" . }} + labels: + {{- include "crystalLibrary.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/charts/xchemlab/charts/crystal-library/values.yaml b/charts/xchemlab/charts/crystal-library/values.yaml new file mode 100644 index 00000000..9c5bbca5 --- /dev/null +++ b/charts/xchemlab/charts/crystal-library/values.yaml @@ -0,0 +1,43 @@ +nameOverride: "" +fullnameOverride: "" + +image: + repository: ghcr.io/diamondlightsource/xchemlab-crystal-library + 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 0dfc4c00..eab41862 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 +crystal-library: + 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 + pin-packing: enabled: true database: @@ -159,7 +170,7 @@ prometheus: - host: xchemlab-alertmanager.diamond.ac.uk paths: - path: / - pathType: ImplementationSpecific + pathType: Prefix tls: - hosts: - xchemlab-alertmanager.diamond.ac.uk From 142eca95d727ba85167cbd11b6ccd7e64e8975cf Mon Sep 17 00:00:00 2001 From: iamvigneshwars Date: Tue, 5 Mar 2024 15:04:08 +0000 Subject: [PATCH 3/3] Bump helm charts appVersion from 0.0.5 to 0.0.6 --- charts/xchemlab/charts/chimp-chomp/Chart.yaml | 2 +- charts/xchemlab/charts/compound-library/Chart.yaml | 2 +- charts/xchemlab/charts/crystal-library/Chart.yaml | 2 +- charts/xchemlab/charts/pin-packing/Chart.yaml | 2 +- charts/xchemlab/charts/targeting/Chart.yaml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/charts/xchemlab/charts/chimp-chomp/Chart.yaml b/charts/xchemlab/charts/chimp-chomp/Chart.yaml index eb1b1eb4..66c98705 100644 --- a/charts/xchemlab/charts/chimp-chomp/Chart.yaml +++ b/charts/xchemlab/charts/chimp-chomp/Chart.yaml @@ -12,4 +12,4 @@ version: 0.0.3 # 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.5" +appVersion: "0.0.6" diff --git a/charts/xchemlab/charts/compound-library/Chart.yaml b/charts/xchemlab/charts/compound-library/Chart.yaml index cd9849d8..286d6306 100644 --- a/charts/xchemlab/charts/compound-library/Chart.yaml +++ b/charts/xchemlab/charts/compound-library/Chart.yaml @@ -12,4 +12,4 @@ version: 0.0.1 # 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.5" +appVersion: "0.0.6" diff --git a/charts/xchemlab/charts/crystal-library/Chart.yaml b/charts/xchemlab/charts/crystal-library/Chart.yaml index 00048d4c..f3e57c6f 100644 --- a/charts/xchemlab/charts/crystal-library/Chart.yaml +++ b/charts/xchemlab/charts/crystal-library/Chart.yaml @@ -12,4 +12,4 @@ version: 0.0.1 # 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.5" +appVersion: "0.0.6" diff --git a/charts/xchemlab/charts/pin-packing/Chart.yaml b/charts/xchemlab/charts/pin-packing/Chart.yaml index ff38b9ce..578c9d0e 100644 --- a/charts/xchemlab/charts/pin-packing/Chart.yaml +++ b/charts/xchemlab/charts/pin-packing/Chart.yaml @@ -12,4 +12,4 @@ version: 0.0.3 # 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.5" +appVersion: "0.0.6" diff --git a/charts/xchemlab/charts/targeting/Chart.yaml b/charts/xchemlab/charts/targeting/Chart.yaml index 345483de..686300b3 100644 --- a/charts/xchemlab/charts/targeting/Chart.yaml +++ b/charts/xchemlab/charts/targeting/Chart.yaml @@ -12,4 +12,4 @@ version: 0.0.2 # 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.5" +appVersion: "0.0.6"