Skip to content

Commit

Permalink
Merge pull request #7 from chgl/updated-ohdsi
Browse files Browse the repository at this point in the history
Updated ohdsi
  • Loading branch information
chgl authored Dec 19, 2020
2 parents 6d847cc + b497dea commit ca38fa1
Show file tree
Hide file tree
Showing 14 changed files with 181 additions and 116 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,20 @@ helm repo update

## Development

1. Install the [pre-commit](https://pre-commit.com/) hooks
1. (Optional) Install the [pre-commit](https://pre-commit.com/) hooks

```sh
pip install pre-commit
pre-commit install
```

1. (Optional) Setup a KinD cluster with Nginx ingress support

```sh
kind create cluster --config=hack/kind-config.yaml
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/static/provider/kind/deploy.yaml
```

1. Make changes to the charts

1. Mount the folder in the [kube-powertools](https://github.com/chgl/kube-powertools) container to easily run linters and checks
Expand Down
2 changes: 1 addition & 1 deletion charts/ohdsi/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: ohdsi
description: A Helm chart for deploying OHDSI ATLAS and the WebAPI
type: application
version: 0.1.4
version: 0.1.5
home: https://github.com/OHDSI
keywords:
- ohdsi
Expand Down
143 changes: 72 additions & 71 deletions charts/ohdsi/README.md

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions charts/ohdsi/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
{{- if .Values.webapi.enabled }}
{{- if .Values.webApi.enabled }}
- Get the application URL for the WebAPI running these commands:
{{- if .Values.webapi.ingress.enabled }}
{{- range $host := .Values.webapi.ingress.hosts }}
{{- if .Values.webApi.ingress.enabled }}
{{- range $host := .Values.webApi.ingress.hosts }}
{{- range .paths }}
http{{ if $.Values.webapi.ingress.tls }}s{{ end }}://{{ $host.host }}{{ . }}
http{{ if $.Values.webApi.ingress.tls }}s{{ end }}://{{ $host.host }}{{ . }}
{{- end }}
{{- end }}
{{- else if contains "NodePort" .Values.webapi.service.type }}
{{- else if contains "NodePort" .Values.webApi.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "ohdsi.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.webapi.service.type }}
{{- else if contains "LoadBalancer" .Values.webApi.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 "ohdsi.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "ohdsi.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.webapi.service.port }}
{{- else if contains "ClusterIP" .Values.webapi.service.type }}
echo http://$SERVICE_IP:{{ .Values.webApi.service.port }}
{{- else if contains "ClusterIP" .Values.webApi.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "ohdsi.name" . }}-webapi,app.kubernetes.io/instance={{ .Release.Name }}-webapi" -o jsonpath="{.items[0].metadata.name}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:80
Expand Down
6 changes: 3 additions & 3 deletions charts/ohdsi/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ Get the name of the secret containing the DB password
{{- else -}}
{{ printf "%s-%s" $fullname "postgresqlha-postgresql" }}
{{- end -}}
{{- else if .Values.webapi.db.existingSecret -}}
{{ .Values.webapi.db.existingSecret | quote }}
{{- else if .Values.webApi.db.existingSecret -}}
{{ .Values.webApi.db.existingSecret | quote }}
{{- else -}}
{{ printf "%s-%s" $fullname "webapi-db-secret" }}
{{- end -}}
Expand All @@ -68,6 +68,6 @@ Create the JDBC URL from the host, port and database name.
{{- $pgpoolServiceName := ( printf "%s-%s" $fullname "postgresqlha-pgpool") -}}
{{ printf "jdbc:postgresql://%s:%d/%s" $pgpoolServiceName 5432 .Values.global.postgresql.database }}
{{- else -}}
{{ printf "jdbc:postgresql://%s:%d/%s" .Values.webapi.db.host (int64 .Values.webapi.db.port) .Values.webapi.db.database }}
{{ printf "jdbc:postgresql://%s:%d/%s" .Values.webApi.db.host (int64 .Values.webApi.db.port) .Values.webApi.db.database }}
{{- end -}}
{{- end -}}
9 changes: 7 additions & 2 deletions charts/ohdsi/templates/atlas-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,14 @@ spec:
resources:
{{- toYaml .resources | nindent 12 }}
env:
{{- if .ingress.enabled }}
{{- if .webApiUrl }}
- name: WEBAPI_URL
value: http{{ if .ingress.tls }}s{{ end }}://{{ (index .ingress.hosts 0).host }}/atlas
value: {{ .webApiUrl }}
{{- else if $.Values.webApi.ingress.enabled }}
- name: WEBAPI_URL
{{- $host := (index $.Values.webApi.ingress.hosts 0) }}
{{- $path := index (index $.Values.webApi.ingress.hosts 0).paths 0 }}
value: http{{ if $.Values.webApi.ingress.tls }}s{{ end }}://{{ $host.host }}{{ $path }}
{{- end }}
{{- if .extraEnv }}
{{- toYaml .extraEnv | nindent 12 }}
Expand Down
39 changes: 27 additions & 12 deletions charts/ohdsi/templates/atlas-ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
{{- if and .Values.atlas.ingress.enabled .Values.atlas.enabled -}}
{{- $fullName := include "ohdsi.fullname" . -}}
{{- $svcPort := .Values.service.port -}}
{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
{{- with .Values.atlas }}
{{- if and .ingress.enabled .enabled -}}
{{- $fullName := include "ohdsi.fullname" $ -}}
{{- $svcPort := .service.port -}}
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
apiVersion: networking.k8s.io/v1
{{- else if semverCompare ">=1.14-0" $.Capabilities.KubeVersion.GitVersion }}
apiVersion: networking.k8s.io/v1beta1
{{- else -}}
{{ else }}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
name: {{ $fullName }}
name: {{ $fullName }}-atlas
labels:
{{- include "ohdsi.labels" . | nindent 4 }}
{{- include "ohdsi.labels" $ | nindent 4 }}
app.kubernetes.io/name: {{ include "ohdsi.name" $ }}-atlas
app.kubernetes.io/instance: {{ $.Release.Name }}-atlas
{{- with .Values.ingress.annotations }}
{{- with .ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if .Values.ingress.tls }}
{{- if .ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
{{- range .ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
Expand All @@ -29,15 +32,27 @@ spec:
{{- end }}
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
{{- range .ingress.hosts }}
{{- $pathType := .pathType }}
- host: {{ .host | quote }}
http:
paths:
{{- range .paths }}
- path: {{ . }}
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
pathType: {{ $pathType | default "ImplementationSpecific" }}
{{- end }}
backend:
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
service:
name: {{ $fullName }}
port:
number: {{ $svcPort }}
{{ else }}
serviceName: {{ $fullName }}
servicePort: {{ $svcPort }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
2 changes: 1 addition & 1 deletion charts/ohdsi/templates/tests/test-connection.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ spec:
image: busybox:1
imagePullPolicy: Always
command: ['wget', '-O', '-']
args: ['{{ include "ohdsi.fullname" . }}-webapi:{{ .Values.webapi.service.port }}/atlas/']
args: ['{{ include "ohdsi.fullname" . }}-webapi:{{ .Values.webApi.service.port }}/atlas/']
securityContext:
readOnlyRootFilesystem: true
runAsUser: 1111
Expand Down
4 changes: 2 additions & 2 deletions charts/ohdsi/templates/webapi-db-secret.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if .Values.webapi.enabled }}
{{- if .Values.webApi.enabled }}
{{- if not .Values.postgresqlha.enabled -}}
apiVersion: v1
kind: Secret
Expand All @@ -10,6 +10,6 @@ metadata:
app.kubernetes.io/instance: {{ .Release.Name }}-webapi-db-secret
type: Opaque
data:
postgresql-password: {{ .Values.webapi.db.password | b64enc | quote }}
postgresql-password: {{ .Values.webApi.db.password | b64enc | quote }}
{{- end -}}
{{- end -}}
2 changes: 1 addition & 1 deletion charts/ohdsi/templates/webapi-deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- with .Values.webapi }}
{{- with .Values.webApi }}
{{- if .enabled }}
apiVersion: apps/v1
kind: Deployment
Expand Down
39 changes: 27 additions & 12 deletions charts/ohdsi/templates/webapi-ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
{{- if and .Values.webapi.ingress.enabled .Values.webapi.enabled -}}
{{- $fullName := include "ohdsi.fullname" . -}}
{{- $svcPort := .Values.service.port -}}
{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
{{- with .Values.webApi }}
{{- if and .ingress.enabled .enabled -}}
{{- $fullName := include "ohdsi.fullname" $ -}}
{{- $svcPort := .service.port -}}
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
apiVersion: networking.k8s.io/v1
{{- else if semverCompare ">=1.14-0" $.Capabilities.KubeVersion.GitVersion }}
apiVersion: networking.k8s.io/v1beta1
{{- else -}}
{{ else }}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
name: {{ $fullName }}
name: {{ $fullName }}-webapi
labels:
{{- include "ohdsi.labels" . | nindent 4 }}
{{- include "ohdsi.labels" $ | nindent 4 }}
app.kubernetes.io/name: {{ include "ohdsi.name" $ }}-webapi
app.kubernetes.io/instance: {{ $.Release.Name }}-webapi
{{- with .Values.ingress.annotations }}
{{- with .ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if .Values.ingress.tls }}
{{- if .ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
{{- range .ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
Expand All @@ -29,15 +32,27 @@ spec:
{{- end }}
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
{{- range .ingress.hosts }}
{{- $pathType := .pathType }}
- host: {{ .host | quote }}
http:
paths:
{{- range .paths }}
- path: {{ . }}
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
pathType: {{ $pathType | default "ImplementationSpecific" }}
{{- end }}
backend:
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
service:
name: {{ $fullName }}
port:
number: {{ $svcPort }}
{{ else }}
serviceName: {{ $fullName }}
servicePort: {{ $svcPort }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
2 changes: 1 addition & 1 deletion charts/ohdsi/templates/webapi-service.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- with .Values.webapi }}
{{- with .Values.webApi }}
{{- if .enabled }}
apiVersion: v1
kind: Service
Expand Down
7 changes: 6 additions & 1 deletion charts/ohdsi/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ postgresqlha:
postgresqlImage:
tag: 13.1.0

webapi:
webApi:
enabled: true
replicaCount: 1
image:
Expand Down Expand Up @@ -116,6 +116,11 @@ atlas:
tag: 2.8.0-dev
pullPolicy: Always

# the base URL of the OHDSI WebAPI, e.g. https://example.com/WebAPI
# if this value is not set but `webapi.ingress.enabled=true`, then this
# URL is constructed from `webapi.ingress`
webApiUrl: ""

podAnnotations: {}

podSecurityContext:
Expand Down
17 changes: 17 additions & 0 deletions hack/kind-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
kubeadmConfigPatches:
- |
kind: InitConfiguration
nodeRegistration:
kubeletExtraArgs:
node-labels: "ingress-ready=true"
extraPortMappings:
- containerPort: 80
hostPort: 80
protocol: TCP
- containerPort: 443
hostPort: 443
protocol: TCP

0 comments on commit ca38fa1

Please sign in to comment.