Skip to content

Commit

Permalink
Adding cohort-middleware helm chart to the gen3-helm repo (#240)
Browse files Browse the repository at this point in the history
* First commit of cohort-middleware

* I think our service is broken

* Also need to update service name

* I think cohort-middleware has more config than last time

* Just trying to eliminate differences

* Have to be sure

* It's going to be embarassing if this is it

* Ready to merge

* Adding cohort-middleware to umbrella chart

* Updating cohort-middleware depdendencies

* Another dependency update

* Version bumps

* Adding global values to cohort-middleware

* Bumping versions in umbrella chart

* Trying to get CI to pass

* Adding external secrets to cohort-middleware chart

* externalSecrets.deploy, not .enable

* Syntax error in secrets.yaml

* Put the external secrets deployment in the wrong spot

* Making CI happy
  • Loading branch information
AidanHilt authored Feb 27, 2025
1 parent 754bb7d commit 89f3afc
Show file tree
Hide file tree
Showing 17 changed files with 696 additions and 22 deletions.
23 changes: 23 additions & 0 deletions helm/cohort-middleware/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
33 changes: 33 additions & 0 deletions helm/cohort-middleware/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
apiVersion: v2
name: cohort-middleware
description: A Helm chart for gen3 cohort-middleware

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
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.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: "master"

dependencies:
- name: common
version: 0.1.16
repository: file://../common
- name: postgresql
version: 11.9.13
repository: "https://charts.bitnami.com/bitnami"
condition: postgres.separate
110 changes: 110 additions & 0 deletions helm/cohort-middleware/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# cohort-middleware

![Version: 0.1.1](https://img.shields.io/badge/Version-0.1.1-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: master](https://img.shields.io/badge/AppVersion-master-informational?style=flat-square)

A Helm chart for gen3 cohort-middleware

## Requirements

| Repository | Name | Version |
|------------|------|---------|
| file://../common | common | 0.1.16 |
| https://charts.bitnami.com/bitnami | postgresql | 11.9.13 |

## Values

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| affinity.nodeAffinity.preferredDuringSchedulingIgnoredDuringExecution[0].preference.matchExpressions[0].key | string | `"karpenter.sh/capacity-type"` | |
| affinity.nodeAffinity.preferredDuringSchedulingIgnoredDuringExecution[0].preference.matchExpressions[0].operator | string | `"In"` | |
| affinity.nodeAffinity.preferredDuringSchedulingIgnoredDuringExecution[0].preference.matchExpressions[0].values[0] | string | `"spot"` | |
| affinity.nodeAffinity.preferredDuringSchedulingIgnoredDuringExecution[0].weight | int | `100` | |
| affinity.nodeAffinity.preferredDuringSchedulingIgnoredDuringExecution[1].preference.matchExpressions[0].key | string | `"eks.amazonaws.com/capacityType"` | |
| affinity.nodeAffinity.preferredDuringSchedulingIgnoredDuringExecution[1].preference.matchExpressions[0].operator | string | `"In"` | |
| affinity.nodeAffinity.preferredDuringSchedulingIgnoredDuringExecution[1].preference.matchExpressions[0].values[0] | string | `"SPOT"` | |
| affinity.nodeAffinity.preferredDuringSchedulingIgnoredDuringExecution[1].weight | int | `99` | |
| affinity.podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution[0].podAffinityTerm.labelSelector.matchExpressions[0].key | string | `"app"` | |
| affinity.podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution[0].podAffinityTerm.labelSelector.matchExpressions[0].operator | string | `"In"` | |
| affinity.podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution[0].podAffinityTerm.labelSelector.matchExpressions[0].values[0] | string | `"cohort-middleware"` | |
| affinity.podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution[0].podAffinityTerm.topologyKey | string | `"kubernetes.io/hostname"` | |
| affinity.podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution[0].weight | int | `25` | |
| autoscaling.enabled | bool | `false` | |
| autoscaling.maxReplicas | int | `100` | |
| autoscaling.minReplicas | int | `1` | |
| autoscaling.targetCPUUtilizationPercentage | int | `80` | |
| config.arboristEndpoint | string | `"http://arborist-service"` | |
| config.atlasDbHost | string | `""` | |
| config.atlasDbPassword | string | `""` | |
| config.atlasDbPort | int | `5432` | |
| config.atlasDbUsername | string | `""` | |
| config.db | string | `"atlas_default"` | |
| config.globalReaderRole | string | `"public"` | |
| config.schema | string | `"ohdsi"` | |
| externalSecrets | map | `{"cohortMiddlewareG3Auto":null}` | External Secrets settings. |
| externalSecrets.cohortMiddlewareG3Auto | string | `nil` | Will override the name of the aws secrets manager secret. Default is "cohort-middleware-g3auto" |
| fullnameOverride | string | `""` | |
| global.aws | map | `{"awsAccessKeyId":null,"awsSecretAccessKey":null,"enabled":false}` | AWS configuration |
| global.aws.awsAccessKeyId | string | `nil` | Credentials for AWS stuff. |
| global.aws.awsSecretAccessKey | string | `nil` | Credentials for AWS stuff. |
| global.aws.enabled | bool | `false` | Set to true if deploying to AWS. Controls ingress annotations. |
| global.dev | bool | `true` | Whether the deployment is for development purposes. |
| global.dictionaryUrl | string | `"https://s3.amazonaws.com/dictionary-artifacts/datadictionary/develop/schema.json"` | URL of the data dictionary. |
| global.dispatcherJobNum | int | `"10"` | Number of dispatcher jobs. |
| global.environment | string | `"default"` | Environment name. This should be the same as vpcname if you're doing an AWS deployment. Currently this is being used to share ALB's if you have multiple namespaces. Might be used other places too. |
| global.externalSecrets | map | `{"deploy":false}` | External Secrets settings. |
| global.externalSecrets.deploy | bool | `false` | Will use ExternalSecret resources to pull secrets from Secrets Manager instead of creating them locally. Be cautious as this will override any fence secrets you have deployed. |
| global.hostname | string | `"localhost"` | Hostname for the deployment. |
| global.kubeBucket | string | `"kube-gen3"` | S3 bucket name for Kubernetes manifest files. |
| global.logsBucket | string | `"logs-gen3"` | S3 bucket name for log files. |
| global.minAvialable | int | `1` | The minimum amount of pods that are available at all times if the PDB is deployed. |
| global.netPolicy | map | `{"enabled":false}` | Controls network policy settings |
| global.pdb | bool | `false` | If the service will be deployed with a Pod Disruption Budget. Note- you need to have more than 2 replicas for the pdb to be deployed. |
| global.portalApp | string | `"gitops"` | Portal application name. |
| global.postgres.dbCreate | bool | `true` | Whether the database should be created. |
| global.postgres.externalSecret | string | `""` | Name of external secret. Disabled if empty |
| global.postgres.master | map | `{"host":null,"password":null,"port":"5432","username":"postgres"}` | Master credentials to postgres. This is going to be the default postgres server being used for each service, unless each service specifies their own postgres |
| global.postgres.master.host | string | `nil` | hostname of postgres server |
| global.postgres.master.password | string | `nil` | password for superuser in postgres. This is used to create or restore databases |
| 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 |
| global.publicDataSets | bool | `true` | Whether public datasets are enabled. |
| global.revproxyArn | string | `"arn:aws:acm:us-east-1:123456:certificate"` | ARN of the reverse proxy certificate. |
| global.tierAccessLevel | string | `"libre"` | Access level for tiers. |
| global.tierAccessLimit | int | `"1000"` | Only relevant if tireAccessLevel is set to "regular". Summary charts below this limit will not appear for aggregated data. |
| image.pullPolicy | string | `"IfNotPresent"` | |
| image.repository | string | `"quay.io/cdis/cohort-middleware"` | |
| image.tag | string | `""` | |
| imagePullSecrets | list | `[]` | |
| ingress.annotations | object | `{}` | |
| ingress.className | string | `""` | |
| ingress.enabled | bool | `false` | |
| ingress.hosts[0].host | string | `"chart-example.local"` | |
| ingress.hosts[0].paths[0].path | string | `"/"` | |
| ingress.hosts[0].paths[0].pathType | string | `"ImplementationSpecific"` | |
| ingress.tls | list | `[]` | |
| livenessProbe.httpGet.path | string | `"/_health"` | |
| livenessProbe.httpGet.port | int | `8080` | |
| livenessProbe.initialDelaySeconds | int | `30` | |
| livenessProbe.periodSeconds | int | `60` | |
| livenessProbe.timeoutSeconds | int | `30` | |
| nameOverride | string | `""` | |
| nodeSelector | object | `{}` | |
| podAnnotations | object | `{}` | |
| podLabels | object | `{}` | |
| podSecurityContext | object | `{}` | |
| readinessProbe.httpGet.path | string | `"/_health"` | |
| readinessProbe.httpGet.port | int | `8080` | |
| replicaCount | int | `1` | |
| resources.limits.memory | string | `"4Gi"` | |
| resources.requests.cpu | string | `"100m"` | |
| resources.requests.memory | string | `"128Mi"` | |
| securityContext | object | `{}` | |
| service.port | int | `80` | |
| service.type | string | `"ClusterIP"` | |
| serviceAccount.annotations | object | `{}` | |
| serviceAccount.automount | bool | `true` | |
| serviceAccount.create | bool | `true` | |
| serviceAccount.name | string | `""` | |
| tolerations | list | `[]` | |
| volumeMounts | list | `[]` | |
| volumes | string | `nil` | |
19 changes: 19 additions & 0 deletions helm/cohort-middleware/cohort-middleware-g3auto/development.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Can probably hardcode this
catch_all_cohort_id: 121
worker_pool_size: 10
arborist_endpoint: "http://arborist-service"
batch_size: 30
global_reader_role: "public"
atlas_db:
host: "{{ .Values.postgres.host }}"
port: "{{ .Values.postgres.port }}"
username: "{{ .Values.postgres.username }}"
password: "{{ .Values.postgres.password }}"
db: "{{ .Values.postgres.db }}"
schema: ohdsi
# optional validation config:
validate:
# TODO need to get an explanation for this from VA team
single_observation_for_concept_ids:
# HARE concept id:
- "2000007027"
1 change: 1 addition & 0 deletions helm/cohort-middleware/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{ .Chart.Name }} has been deployed successfully.
70 changes: 70 additions & 0 deletions helm/cohort-middleware/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "cohort-middleware.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 "cohort-middleware.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 "cohort-middleware.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "cohort-middleware.labels" -}}
helm.sh/chart: {{ include "cohort-middleware.chart" . }}
{{ include "cohort-middleware.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "cohort-middleware.selectorLabels" -}}
app.kubernetes.io/name: {{ include "cohort-middleware.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "cohort-middleware.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "cohort-middleware.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}


{{/*
cohortmiddleware-g3auto secret
*/}}
{{- define "cohort-middleware-g3auto" -}}
{{- default "cohort-middleware-g3auto" .Values.externalSecrets.cohortMiddlewareG3Auto }}
{{- end }}
82 changes: 82 additions & 0 deletions helm/cohort-middleware/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: cohort-middleware-deployment
labels:
{{- include "cohort-middleware.labels" . | nindent 4 }}
annotations:
gen3.io/network-ingress: "cohort-middleware"
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "cohort-middleware.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
dbohdsi: "yes"
dbomop-data: "yes"
public: "yes"
app: "cohort-middleware"
{{- include "cohort-middleware.selectorLabels" . | nindent 8 }}
{{- include "common.extraLabels" . | nindent 8 }}
spec:
volumes:
- name: cohort-middleware-g3auto
secret:
secretName: cohort-middleware-g3auto
#serviceAccountName: {{ include "cohort-middleware.serviceAccountName" . }}
serviceAccountName: default
automountServiceAccountToken: false
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 }}
env:
- name: GIN_MODE
value: "release"
- name: PORT
value: "8080"
volumeMounts:
- name: cohort-middleware-g3auto
readOnly: true
mountPath: /config/development.yaml
subPath: development.yaml
ports:
- containerPort: 8080
livenessProbe:
{{- toYaml .Values.livenessProbe | nindent 12 }}
readinessProbe:
{{- toYaml .Values.readinessProbe | nindent 12 }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.volumes }}
volumes:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
19 changes: 19 additions & 0 deletions helm/cohort-middleware/templates/external-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{{- if .Values.global.externalSecrets.deploy }}
apiVersion: external-secrets.io/v1beta1
kind: ExternalSecret
metadata:
name: cohort-middleware-g3auto
spec:
refreshInterval: 5m
secretStoreRef:
name: {{include "common.SecretStore" .}}
kind: SecretStore
target:
name: cohort-middleware-g3auto
creationPolicy: Owner
data:
- secretKey: development.yaml
remoteRef:
#name of secret in secrets manager
key: {{ include "cohort-middleware-g3auto" . }}
{{- end }}
32 changes: 32 additions & 0 deletions helm/cohort-middleware/templates/hpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{{- if .Values.autoscaling.enabled }}
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "cohort-middleware.fullname" . }}
labels:
{{- include "cohort-middleware.labels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "cohort-middleware.fullname" . }}
minReplicas: {{ .Values.autoscaling.minReplicas }}
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
metrics:
{{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
{{- end }}
{{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
{{- end }}
{{- end }}
Loading

0 comments on commit 89f3afc

Please sign in to comment.