Skip to content

Commit

Permalink
Add data-dashboard-backend
Browse files Browse the repository at this point in the history
  • Loading branch information
pvannierop committed Apr 10, 2024
1 parent 0394516 commit 2f01987
Show file tree
Hide file tree
Showing 27 changed files with 634 additions and 6 deletions.
Empty file modified .github/ci_config/bin/install-dependencies
100755 → 100644
Empty file.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ If installed, to upgrade `timescaledb`, uncomment the `production.yaml` line `ti
```shell
kubectl delete secrets timescaledb-postgresql
kubectl delete statefulsets timescaledb-postgresql
helmfile -f helmfile.d/20-grafana.yaml apply
helmfile -f helmfile.d/20-dashboard.yaml apply
```

If installed, to upgrade `radar-upload-postgresql`, uncomment the `production.yaml` line `radar_upload_postgresql.primary.existingClaim: "data-radar-upload-postgresql-postgresql-0"`. Then run
Expand Down
Empty file modified bin/chart-updates
100755 → 100644
Empty file.
1 change: 1 addition & 0 deletions bin/generate-secrets
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ insert_secret ".management_portal.oauth_clients.radar_redcap_integrator.client_s
insert_secret ".management_portal.oauth_clients.radar_fitbit_connector.client_secret"
insert_secret ".management_portal.oauth_clients.radar_appconfig.client_secret"
insert_secret ".management_portal.oauth_clients.radar_push_endpoint.client_secret"
insert_secret ".management_portal.oauth_clients.radar_data_dashboard_backend.client_secret"

insert_secret \
".radar_appserver_postgresql.global.postgresql.auth.postgresPassword" \
Expand Down
Empty file modified bin/init
100755 → 100644
Empty file.
Empty file modified bin/keystore-init
100755 → 100644
Empty file.
Empty file modified bin/log-failed-release
100755 → 100644
Empty file.
Empty file modified bin/util.sh
100755 → 100644
Empty file.
23 changes: 23 additions & 0 deletions charts/data-dashboard-backend/.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/
22 changes: 22 additions & 0 deletions charts/data-dashboard-backend/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: v2
appVersion: "0.1.0"
name: data-dashboard-backend
description: API for data in the data dashboard
version: 0.1.6
sources: ["https://github.com/thehyve/radar-data-dashboard-backend"]
deprecated: false
type: application
home: "https://radar-base.org"
maintainers:
- email: keyvan@thehyve.nl
name: Keyvan Hedayati
url: https://www.thehyve.nl
- email: nivethika@thehyve.nl
name: Nivethika Mahasivam
url: https://www.thehyve.nl/experts/nivethika-mahasivam
- email: bastiaan@thehyve.nl
name: Bastiaan de Graaf
url: https://www.thehyve.nl/experts/bastiaan-de-graaf
- email: pim@thehyve.nl
name: Pim van Nierop
url: https://www.thehyve.nl/experts/pim-van-nierop
Empty file.
67 changes: 67 additions & 0 deletions charts/data-dashboard-backend/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# data-dashboard-backend

![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: 0.1.0](https://img.shields.io/badge/AppVersion-0.1.0-informational?style=flat-square)

API for data in the data dashboard

**Homepage:** <https://radar-base.org>

## Maintainers

| Name | Email | Url |
| ---- | ------ | --- |
| Keyvan Hedayati | <keyvan@thehyve.nl> | <https://www.thehyve.nl> |
| Joris Borgdorff | <joris@thehyve.nl> | <https://www.thehyve.nl/experts/joris-borgdorff> |
| Nivethika Mahasivam | <nivethika@thehyve.nl> | <https://www.thehyve.nl/experts/nivethika-mahasivam> |

## Source Code

* <https://github.com/IMI-H2O/outcomes-dashboard>

## Prerequisites
* Kubernetes 1.17+
* Kubectl 1.17+
* Helm 3.1.0+

## Values

| Key | Type | Default | Description |
|-----|------|----------------------------------------------------|-------------|
| replicaCount | int | `2` | Number of replicas to deploy |
| image.repository | string | `"quay.io/imi-h2o/data-dashboard-backend"` | docker image repository |
| image.pullPolicy | string | `"Always"` | image pull policy |
| image.tag | string | `"dev"` | |
| imagePullSecrets | list | `[]` | Docker registry secret names as an array |
| nameOverride | string | `""` | String to partially override fullname template with a string (will prepend the release name) |
| fullnameOverride | string | `""` | String to fully override fullname template with a string |
| podSecurityContext | object | `{}` | Configure pod's Security Context |
| securityContext | object | `{}` | Configure container's Security Context |
| service.type | string | `"ClusterIP"` | Kubernetes Service type |
| service.port | int | `9000` | data-dashboard-backend port |
| ingress.enabled | bool | `true` | Enable ingress controller resource |
| ingress.className | string | `""` | Ingress class name |
| ingress.annotations | object | check values.yaml | Annotations that define default ingress class, certificate issuer |
| ingress.path | string | `"/api($ |/)(.*)"` | Path within the url structure |
| ingress.pathType | string | `"ImplementationSpecific"` | |
| ingress.hosts | list | `["localhost"]` | Hosts to accept requests from |
| ingress.tls.secretName | string | `"radar-base-tls"` | TLS Secret Name |
| resources | object | `{}` | |
| autoscaling.enabled | bool | `false` | Enable horizontal autoscaling |
| autoscaling.minReplicas | int | `1` | |
| autoscaling.maxReplicas | int | `100` | |
| autoscaling.targetCPUUtilizationPercentage | int | `80` | |
| nodeSelector | object | `{}` | Node labels for pod assignment |
| tolerations | list | `[]` | Toleration labels for pod assignment |
| affinity | object | `{}` | Affinity labels for pod assignment |
| existingSecret | string | `""` | |
| javaOpts | string | `"-Xmx550m"` | Standard JAVA_OPTS that should be passed to this service |
| managementPortal.url | string | `"http://management-portal:8080/managementportal"` | ManagementPortal URL |
| managementPortal.clientId | string | `"data_dashboard_backend"` | ManagementPortal OAuth 2.0 client ID, having grant type client_credentials |
| managementPortal.clientSecret | string | `"secret"` | ManagementPortal OAuth 2.0 client secret |
| path | string | `"/api"` | |
| score | object | Diabetes score calculation table configurations | Where to find lookup tables for score calculations, and how to calculate them. |
| jdbc.driver | string | `"org.postgresql.Driver"` | JDBC Driver to connect to the database. |
| jdbc.url | string | `"jdbc:postgresql://postgresql:5432/outcomes"` | JDBC Connection url of the database. |
| jdbc.user | string | `"radarbase"` | Username of the database |
| jdbc.password | string | `"password"` | Password of the user |
| jdbc.dialect | string | `"org.hibernate.dialect.PostgreSQLDialect"` | Hibernate dialect to use for JDBC Connection |
18 changes: 18 additions & 0 deletions charts/data-dashboard-backend/README.md.gotmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{{ template "chart.header" . }}
{{ template "chart.deprecationWarning" . }}

{{ template "chart.badgesSection" . }}

{{ template "chart.description" . }}

{{ template "chart.homepageLine" . }}

{{ template "chart.maintainersSection" . }}

{{ template "chart.sourcesSection" . }}

{{ template "common.prerequisites" . }}

{{ template "chart.requirementsSection" . }}

{{ template "chart.valuesSection" . }}
20 changes: 20 additions & 0 deletions charts/data-dashboard-backend/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
1. Get the application URL by running these commands:
{{- if .Values.ingress.enabled }}
{{- range $host := .Values.ingress.hosts }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host }}{{ $.Values.path }}
{{- end }}
{{- else if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "data-dashboard-backend.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "data-dashboard-backend.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "data-dashboard-backend.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.service.port }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "data-dashboard-backend.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
echo "Visit http://127.0.0.1:9000 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 9000:$CONTAINER_PORT
{{- end }}
73 changes: 73 additions & 0 deletions charts/data-dashboard-backend/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "data-dashboard-backend.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 "data-dashboard-backend.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 "data-dashboard-backend.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Get the password secret.
*/}}
{{- define "data-dashboard-backend.secretName" -}}
{{- if .Values.existingSecret }}
{{- printf "%s" .Values.existingSecret -}}
{{- else -}}
{{- printf "%s" (include "data-dashboard-backend.fullname" .) -}}
{{- end -}}
{{- end -}}

{{/*
Return true if a secret object should be created
*/}}
{{- define "data-dashboard-backend.createSecret" -}}
{{- if .Values.existingSecret }}
{{- else if .Values.existingSecret -}}
{{- else -}}
{{- true -}}
{{- end -}}
{{- end -}}

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

{{/*
Selector labels
*/}}
{{- define "data-dashboard-backend.selectorLabels" -}}
app.kubernetes.io/name: {{ include "data-dashboard-backend.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
26 changes: 26 additions & 0 deletions charts/data-dashboard-backend/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "data-dashboard-backend.fullname" . }}
labels:
app: {{ template "data-dashboard-backend.name" . }}
chart: {{ template "data-dashboard-backend.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
data:
dashboard.yml: |
service:
baseUri: http://0.0.0.0:9000{{ .Values.path }}
advertisedBaseUri: null
enableCors: true
auth:
managementPortal:
url: {{ .Values.managementPortal.url }}
clientId: {{ .Values.managementPortal.clientId }}
clientSecret: {{ .Values.managementPortal.clientSecret }}
jwtResourceName: res_data_dashboard_backend
database:
url: {{ .Values.jdbc.url }}
user: {{ .Values.jdbc.user }}
password: {{ .Values.jdbc.password }}
dialect: {{ .Values.jdbc.dialect }}
93 changes: 93 additions & 0 deletions charts/data-dashboard-backend/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "data-dashboard-backend.fullname" . }}
labels:
{{- include "data-dashboard-backend.labels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "data-dashboard-backend.selectorLabels" . | nindent 6 }}
template:
metadata:
annotations:
checksum/configmap: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
checksum/secrets: {{ include (print $.Template.BasePath "/secrets.yaml") . | sha256sum }}
{{- range $key, $value := .Values.podAnnotations }}
{{ $key }}: {{ $value | quote }}
{{- end }}
labels:
{{- include "data-dashboard-backend.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
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:
- "/etc/data-dashboard-backend/dashboard.yml"
env:
- name: DATABASE_URL
valueFrom:
secretKeyRef:
name: {{ template "data-dashboard-backend.secretName" . }}
key: databaseUrl
- name: DATABASE_USER
valueFrom:
secretKeyRef:
name: {{ template "data-dashboard-backend.secretName" . }}
key: databaseUser
- name: DATABASE_PASSWORD
valueFrom:
secretKeyRef:
name: {{ template "data-dashboard-backend.secretName" . }}
key: databasePassword
ports:
- name: http
containerPort: 9000
protocol: TCP
livenessProbe:
httpGet:
path: /api/health
port: http
httpHeaders:
- name: Accept
value: application/json
readinessProbe:
httpGet:
path: /api/health
port: http
httpHeaders:
- name: Accept
value: application/json
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts:
- name: config
mountPath: /etc/data-dashboard-backend/
volumes:
- name: config
configMap:
name: {{ include "data-dashboard-backend.fullname" . }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
28 changes: 28 additions & 0 deletions charts/data-dashboard-backend/templates/hpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{{- if .Values.autoscaling.enabled }}
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "data-dashboard-backend.fullname" . }}
labels:
{{- include "data-dashboard-backend.labels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "data-dashboard-backend.fullname" . }}
minReplicas: {{ .Values.autoscaling.minReplicas }}
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
metrics:
{{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
{{- end }}
{{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
{{- end }}
{{- end }}
Loading

0 comments on commit 2f01987

Please sign in to comment.