From fc06405495963cfecded1d52dd15baa1490ab837 Mon Sep 17 00:00:00 2001 From: jacob50231 Date: Thu, 3 Jul 2025 12:59:51 -0500 Subject: [PATCH 1/5] Make item_schemas.json configurable in user-data-library --- .secrets.baseline | 25 +------- helm/gen3-user-data-library/Chart.yaml | 2 +- helm/gen3-user-data-library/README.md | 3 +- .../templates/configmap.yaml | 9 +++ .../templates/deployment.yaml | 61 +++++++++++++------ helm/gen3-user-data-library/values.yaml | 5 ++ 6 files changed, 59 insertions(+), 46 deletions(-) create mode 100644 helm/gen3-user-data-library/templates/configmap.yaml diff --git a/.secrets.baseline b/.secrets.baseline index 1404f92d8..3d30075d0 100644 --- a/.secrets.baseline +++ b/.secrets.baseline @@ -423,29 +423,6 @@ "line_number": 13 } ], - "helm/gen3-user-data-library/README.md": [ - { - "type": "Secret Keyword", - "filename": "helm/gen3-user-data-library/README.md", - "hashed_secret": "4f2a84424eb908cfbe25c1e486024ae59b5a6085", - "is_verified": false, - "line_number": 28 - }, - { - "type": "Secret Keyword", - "filename": "helm/gen3-user-data-library/README.md", - "hashed_secret": "d84ce25b0f9bc2cc263006ae39453efb22cc2900", - "is_verified": false, - "line_number": 45 - }, - { - "type": "Secret Keyword", - "filename": "helm/gen3-user-data-library/README.md", - "hashed_secret": "f09dd6e359833a12f48c4c4255d6e87a6e55cfe9", - "is_verified": false, - "line_number": 66 - } - ], "helm/guppy/README.md": [ { "type": "Secret Keyword", @@ -718,5 +695,5 @@ } ] }, - "generated_at": "2025-06-30T19:20:23Z" + "generated_at": "2025-07-03T17:59:41Z" } diff --git a/helm/gen3-user-data-library/Chart.yaml b/helm/gen3-user-data-library/Chart.yaml index cc482661d..1e8817901 100644 --- a/helm/gen3-user-data-library/Chart.yaml +++ b/helm/gen3-user-data-library/Chart.yaml @@ -15,7 +15,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.1.2 +version: 0.1.3 # 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 diff --git a/helm/gen3-user-data-library/README.md b/helm/gen3-user-data-library/README.md index 0b14d3197..31597a8d1 100644 --- a/helm/gen3-user-data-library/README.md +++ b/helm/gen3-user-data-library/README.md @@ -1,6 +1,6 @@ # gen3-user-data-library -![Version: 0.1.2](https://img.shields.io/badge/Version-0.1.2-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: main](https://img.shields.io/badge/AppVersion-main-informational?style=flat-square) +![Version: 0.1.3](https://img.shields.io/badge/Version-0.1.3-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: main](https://img.shields.io/badge/AppVersion-main-informational?style=flat-square) A Helm chart for Kubernetes @@ -58,6 +58,7 @@ A Helm chart for Kubernetes | ingress.hosts[0].paths[0].path | string | `"/"` | | | ingress.hosts[0].paths[0].pathType | string | `"ImplementationSpecific"` | | | ingress.tls | list | `[]` | | +| itemSchemas | string | `nil` | | | livenessProbe.httpGet.path | string | `"/"` | | | livenessProbe.httpGet.port | string | `"http"` | | | metricsEnabled | bool | `false` | Whether Metrics are enabled. | diff --git a/helm/gen3-user-data-library/templates/configmap.yaml b/helm/gen3-user-data-library/templates/configmap.yaml new file mode 100644 index 000000000..918afce6a --- /dev/null +++ b/helm/gen3-user-data-library/templates/configmap.yaml @@ -0,0 +1,9 @@ +{{- if .Values.itemSchemas}} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "gen3-user-data-library.fullname" . }}-config +data: + item_schemas.json: |- + {{ .Values.itemSchemas| toJson | indent 4}} +{{- end}} \ No newline at end of file diff --git a/helm/gen3-user-data-library/templates/deployment.yaml b/helm/gen3-user-data-library/templates/deployment.yaml index 542de5cd5..8f7712510 100644 --- a/helm/gen3-user-data-library/templates/deployment.yaml +++ b/helm/gen3-user-data-library/templates/deployment.yaml @@ -21,7 +21,6 @@ spec: labels: {{- include "gen3-user-data-library.selectorLabels" . | nindent 8 }} {{- include "common.extraLabels" . | nindent 8 }} - # gen3 networkpolicy labels netnolimit: 'yes' public: 'yes' userhelper: 'yes' @@ -30,18 +29,31 @@ spec: {{- include "common.grafanaAnnotations" . | nindent 8 }} {{- end }} spec: + hostAliases: + - ip: "172.18.0.2" + hostnames: + - "jacobdaugherty.dev.planx-pla.net" {{- with .Values.affinity }} affinity: {{- toYaml . | nindent 8 }} {{- end }} automountServiceAccountToken: {{ .Values.automountServiceAccountToken }} + volumes: - name: gen3-user-data-library-g3auto-volume secret: secretName: gen3userdatalibrary-g3auto + {{- if .Values.itemSchemas }} + - name: gen3-user-data-library-config-volume + configMap: + name: {{ include "gen3-user-data-library.fullname" . }}-config + {{- end }} + containers: - name: {{ .Chart.Name }} image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + env: {{- toYaml .Values.env | nindent 12 }} - name: URL_PREFIX @@ -51,35 +63,31 @@ spec: secretKeyRef: name: gen3-user-data-library-dbcreds key: host - optional: false - name: DB_USER valueFrom: secretKeyRef: name: gen3-user-data-library-dbcreds key: username - optional: false - name: DB_PASSWORD valueFrom: secretKeyRef: name: gen3-user-data-library-dbcreds key: password - optional: false - name: DB_DATABASE valueFrom: secretKeyRef: name: gen3-user-data-library-dbcreds key: database - optional: false - name: DBREADY valueFrom: secretKeyRef: name: gen3-user-data-library-dbcreds key: dbcreated - optional: false - imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: - containerPort: 80 name: http + livenessProbe: httpGet: path: /_status @@ -87,22 +95,33 @@ spec: initialDelaySeconds: 30 periodSeconds: 60 timeoutSeconds: 30 + readinessProbe: httpGet: path: /_status port: 80 - {{- with .Values.volumeMounts }} + volumeMounts: - {{- toYaml . | nindent 10 }} - {{- end }} + {{- with .Values.volumeMounts }} + {{ toYaml . | nindent 12 }} + {{- end }} + {{- if .Values.itemSchemas }} + - name: gen3-user-data-library-config-volume + mountPath: /gen3userdatalibrary/config/item_schemas.json + readOnly: true + subPath: item_schemas.json + {{- end }} + {{- with .Values.resources }} resources: {{- toYaml . | nindent 12 }} {{- end }} + initContainers: - name: gen3-user-data-library-init image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" imagePullPolicy: {{ .Values.image.pullPolicy }} + env: - name: GEN3_DEBUG value: "False" @@ -111,44 +130,46 @@ spec: secretKeyRef: name: gen3-user-data-library-dbcreds key: host - optional: false - name: DB_USER valueFrom: secretKeyRef: name: gen3-user-data-library-dbcreds key: username - optional: false - name: DB_PASSWORD valueFrom: secretKeyRef: name: gen3-user-data-library-dbcreds key: password - optional: false - name: DB_DATABASE valueFrom: secretKeyRef: name: gen3-user-data-library-dbcreds key: database - optional: false - name: DBREADY valueFrom: secretKeyRef: name: gen3-user-data-library-dbcreds key: dbcreated - optional: false - {{- with .Values.volumeMounts }} volumeMounts: - {{- toYaml . | nindent 12 }} - {{- end }} + {{- with .Values.volumeMounts }} + {{ toYaml . | nindent 12 }} + {{- end }} + {{- if .Values.itemSchemas }} + - name: gen3-user-data-library-config-volume + mountPath: /gen3userdatalibrary/config/item_schemas.json + readOnly: true + subPath: item_schemas.json + {{- end }} + {{- with .Values.resources }} resources: {{- toYaml . | nindent 12 }} {{- end }} + command: [ "/bin/sh" ] args: - "-c" - | - # Managing virtual environments via poetry instead of python since the AL base image update, but retaining backwards compatibility printenv - poetry run alembic upgrade head || /env/bin/alembic upgrade head \ No newline at end of file + poetry run alembic upgrade head || /env/bin/alembic upgrade head diff --git a/helm/gen3-user-data-library/values.yaml b/helm/gen3-user-data-library/values.yaml index c35411aaf..3b08d69f0 100644 --- a/helm/gen3-user-data-library/values.yaml +++ b/helm/gen3-user-data-library/values.yaml @@ -128,6 +128,7 @@ volumeMounts: readOnly: true subPath: gen3-user-data-library.env + affinity: {} automountServiceAccountToken: false @@ -188,3 +189,7 @@ secrets: # -- (str) AWS secret access key ID. Overrides global key. awsSecretAccessKey: gunicornWorkers: 1 + + +# Item Schema +itemSchemas: Null \ No newline at end of file From 92b19ea761187026bc8829708c379727026d1d7a Mon Sep 17 00:00:00 2001 From: jacob50231 Date: Thu, 3 Jul 2025 13:35:11 -0500 Subject: [PATCH 2/5] Clean up hostAlias from deployment --- helm/gen3-user-data-library/README.md | 1 + .../templates/deployment.yaml | 20 +++++++++++++++---- helm/gen3-user-data-library/values.yaml | 5 ++++- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/helm/gen3-user-data-library/README.md b/helm/gen3-user-data-library/README.md index 31597a8d1..46cce63f0 100644 --- a/helm/gen3-user-data-library/README.md +++ b/helm/gen3-user-data-library/README.md @@ -48,6 +48,7 @@ A Helm chart for Kubernetes | global.postgres.master.port | string | `"5432"` | Port for Postgres. | | global.postgres.master.username | string | `"postgres"` | username of superuser in postgres. This is used to create or restore databases | | gunicornWorkers | int | `1` | | +| hostAliases | list | `[]` | | | image.pullPolicy | string | `"Always"` | | | image.repository | string | `"quay.io/cdis/gen3-user-data-library"` | | | image.tag | string | `"main"` | | diff --git a/helm/gen3-user-data-library/templates/deployment.yaml b/helm/gen3-user-data-library/templates/deployment.yaml index 8f7712510..3f90e1a54 100644 --- a/helm/gen3-user-data-library/templates/deployment.yaml +++ b/helm/gen3-user-data-library/templates/deployment.yaml @@ -21,6 +21,7 @@ spec: labels: {{- include "gen3-user-data-library.selectorLabels" . | nindent 8 }} {{- include "common.extraLabels" . | nindent 8 }} + # gen3 networkpolicy labels netnolimit: 'yes' public: 'yes' userhelper: 'yes' @@ -29,10 +30,10 @@ spec: {{- include "common.grafanaAnnotations" . | nindent 8 }} {{- end }} spec: + {{- with .Values.hostAliases}} hostAliases: - - ip: "172.18.0.2" - hostnames: - - "jacobdaugherty.dev.planx-pla.net" + {{- toYaml . | nindent 4}} + {{- end}} {{- with .Values.affinity }} affinity: {{- toYaml . | nindent 8 }} @@ -63,26 +64,31 @@ spec: secretKeyRef: name: gen3-user-data-library-dbcreds key: host + optional: false - name: DB_USER valueFrom: secretKeyRef: name: gen3-user-data-library-dbcreds key: username + optional: false - name: DB_PASSWORD valueFrom: secretKeyRef: name: gen3-user-data-library-dbcreds key: password + optional: false - name: DB_DATABASE valueFrom: secretKeyRef: name: gen3-user-data-library-dbcreds key: database + optional: false - name: DBREADY valueFrom: secretKeyRef: name: gen3-user-data-library-dbcreds key: dbcreated + optional: false ports: - containerPort: 80 @@ -130,26 +136,31 @@ spec: secretKeyRef: name: gen3-user-data-library-dbcreds key: host + optional: false - name: DB_USER valueFrom: secretKeyRef: name: gen3-user-data-library-dbcreds key: username + optional: false - name: DB_PASSWORD valueFrom: secretKeyRef: name: gen3-user-data-library-dbcreds key: password + optional: false - name: DB_DATABASE valueFrom: secretKeyRef: name: gen3-user-data-library-dbcreds key: database + optional: false - name: DBREADY valueFrom: secretKeyRef: name: gen3-user-data-library-dbcreds key: dbcreated + optional: false volumeMounts: {{- with .Values.volumeMounts }} @@ -171,5 +182,6 @@ spec: args: - "-c" - | + # Managing virtual environments via poetry instead of python since the AL base image update, but retaining backwards compatibility printenv - poetry run alembic upgrade head || /env/bin/alembic upgrade head + poetry run alembic upgrade head || /env/bin/alembic upgrade head \ No newline at end of file diff --git a/helm/gen3-user-data-library/values.yaml b/helm/gen3-user-data-library/values.yaml index 3b08d69f0..7fb0f9c9e 100644 --- a/helm/gen3-user-data-library/values.yaml +++ b/helm/gen3-user-data-library/values.yaml @@ -192,4 +192,7 @@ gunicornWorkers: 1 # Item Schema -itemSchemas: Null \ No newline at end of file +itemSchemas: Null + +# Host Aliases +hostAliases: [] \ No newline at end of file From 27dbbbc890a3511dbf4795f2b405127fc0a0df0e Mon Sep 17 00:00:00 2001 From: jacob50231 Date: Thu, 3 Jul 2025 13:44:45 -0500 Subject: [PATCH 3/5] Add if statement above to prevent templating error if no volumeMounts or itemSchema --- helm/gen3-user-data-library/templates/deployment.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/helm/gen3-user-data-library/templates/deployment.yaml b/helm/gen3-user-data-library/templates/deployment.yaml index 3f90e1a54..8cb10d406 100644 --- a/helm/gen3-user-data-library/templates/deployment.yaml +++ b/helm/gen3-user-data-library/templates/deployment.yaml @@ -106,7 +106,7 @@ spec: httpGet: path: /_status port: 80 - + {{- if or .Values.itemSchemas .Values.volumeMounts }} volumeMounts: {{- with .Values.volumeMounts }} {{ toYaml . | nindent 12 }} @@ -117,6 +117,7 @@ spec: readOnly: true subPath: item_schemas.json {{- end }} + {{- end}} {{- with .Values.resources }} resources: From e71c852f3b051360c38afb59f35cbc97a84a3cee Mon Sep 17 00:00:00 2001 From: jacob50231 Date: Thu, 3 Jul 2025 13:47:01 -0500 Subject: [PATCH 4/5] Add if or statement for initContainers too --- helm/gen3-user-data-library/templates/deployment.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/helm/gen3-user-data-library/templates/deployment.yaml b/helm/gen3-user-data-library/templates/deployment.yaml index 8cb10d406..908c827ba 100644 --- a/helm/gen3-user-data-library/templates/deployment.yaml +++ b/helm/gen3-user-data-library/templates/deployment.yaml @@ -163,6 +163,7 @@ spec: key: dbcreated optional: false + {{- if or .Values.itemSchemas .Values.volumeMounts }} volumeMounts: {{- with .Values.volumeMounts }} {{ toYaml . | nindent 12 }} @@ -173,7 +174,7 @@ spec: readOnly: true subPath: item_schemas.json {{- end }} - + {{- end}} {{- with .Values.resources }} resources: {{- toYaml . | nindent 12 }} From c2981f2bdd27a7b3e5d2bda4063f3dec522351ba Mon Sep 17 00:00:00 2001 From: jacob50231 Date: Thu, 3 Jul 2025 13:53:24 -0500 Subject: [PATCH 5/5] Add new line to values.yaml to pass lint --- helm/gen3-user-data-library/values.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helm/gen3-user-data-library/values.yaml b/helm/gen3-user-data-library/values.yaml index 7fb0f9c9e..5a70a809f 100644 --- a/helm/gen3-user-data-library/values.yaml +++ b/helm/gen3-user-data-library/values.yaml @@ -195,4 +195,4 @@ gunicornWorkers: 1 itemSchemas: Null # Host Aliases -hostAliases: [] \ No newline at end of file +hostAliases: []