Skip to content

Commit

Permalink
Add postgres for argo job archive
Browse files Browse the repository at this point in the history
  • Loading branch information
mocsharp committed Sep 7, 2023
1 parent b010ca6 commit 5b5259b
Show file tree
Hide file tree
Showing 8 changed files with 238 additions and 6 deletions.
1 change: 1 addition & 0 deletions deploy/helm-charts/docs/01.installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ Use the following commands to install MONAI Deploy Helm charts and its dependenc
- RabbitMQ
- [Argo Workflows](https://github.com/argoproj/argo-helm/tree/main/charts/argo-workflows)
- [local-path-provisioner](https://github.com/rancher/local-path-provisioner)
- Postgres - archives Argo jobs (can be disabled in `values.yaml` > `argo-workflows` > `controller` > `persistence` > `archive=false`)

```bash
helm upgrade -i monai-deploy . # default/current namespace
Expand Down
2 changes: 1 addition & 1 deletion deploy/helm-charts/docs/03.TriggerNewJobs.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ click on a study, from the menu on the left, click on *Send to DICOM modality* a

After a minute or two, depending on the size of the DICOM dataset, you may find the job listed in Argo.

Note: The jobs get deleted from the page after a while by Argo GC.
Note: Check the **Archived Workflows** page if jobs cannot be found on the **Workflows** page.

Enable UI (http://localhost:2746) access with the following command to forward port 2476:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ spec:
entrypoint: hello-world-pipeline
podGC:
strategy: OnWorkflowSuccess
# Uncomment for Argo 3.5
# deleteDelayDuration: 300s
arguments: {}
templates:
- name: hello-world-pipeline
Expand Down Expand Up @@ -62,4 +60,4 @@ spec:
- /bin/sh
args:
- '-c'
- date && cp -r /var/monai/input/* /var/monai/output && date
- date && cp -vr /var/monai/input/* /var/monai/output && date
13 changes: 12 additions & 1 deletion deploy/helm-charts/templates/00-secrets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,15 @@ metadata:
name: {{ .Values.rabbitmq.name }}-secret
data:
username: {{ .Values.rabbitmq.username | b64enc | quote }}
password: {{ .Values.rabbitmq.password | b64enc | quote }}
password: {{ .Values.rabbitmq.password | b64enc | quote }}


---

apiVersion: v1
kind: Secret
metadata:
name: {{ .Values.postgres.name }}-secret
data:
username: {{ .Values.postgres.username | b64enc | quote }}
password: {{ .Values.postgres.password | b64enc | quote }}
98 changes: 98 additions & 0 deletions deploy/helm-charts/templates/05-postgres-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
{{- if index .Values "argo-workflows" "controller" "persistence" "archive" -}}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Values.postgres.serviceName }}
labels:
{{- include "local.labels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
selector:
matchLabels:
role: internal-svcs
{{- include "local.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
app: postgres
role: internal-svcs
{{- include "local.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "local.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.postgres.repository }}:{{ .Values.postgres.tag }}"
imagePullPolicy: {{ .Values.postgres.pullPolicy }}
ports:
- name: postgres-port
containerPort: 5432
protocol: TCP
volumeMounts:
- name: {{ .Release.Name }}-postgresdb
mountPath: /var/lib/postgresql/data
subPath: data
resources:
{{- toYaml .Values.postgres.resources | nindent 12 }}
env:
- name: POSTGRES_USER
valueFrom:
secretKeyRef:
name: {{ .Values.postgres.name }}-secret
key: username
- name: POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
name: {{ .Values.postgres.name }}-secret
key: password
livenessProbe:
exec:
command:
- /bin/bash
- -c
- pg_isready -U postgres
initialDelaySeconds: 10
periodSeconds: 5
timeoutSeconds: 10
failureThreshold: 300
readinessProbe:
exec:
command:
- /bin/bash
- -c
- pg_isready -U postgres
initialDelaySeconds: 15
periodSeconds: 5
timeoutSeconds: 10
failureThreshold: 300
volumes:
- name: {{ .Release.Name }}-postgresdb
persistentVolumeClaim:
claimName: {{ .Release.Name }}-{{ .Values.postgres.name }}-volume-claim

{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
13 changes: 13 additions & 0 deletions deploy/helm-charts/templates/05-postgres-pvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{- if index .Values "argo-workflows" "controller" "persistence" "archive" -}}
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ .Release.Name }}-{{ .Values.postgres.name }}-volume-claim
spec:
accessModes:
- ReadWriteOnce
storageClassName: local-path
resources:
requests:
storage: {{ .Values.postgres.size }}
{{- end }}
18 changes: 18 additions & 0 deletions deploy/helm-charts/templates/05-postgres-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{{- if index .Values "argo-workflows" "controller" "persistence" "archive" -}}
apiVersion: v1
kind: Service
metadata:
name: {{ .Values.postgres.serviceName }}
labels:
{{- include "local.labels" . | nindent 4 }}
spec:
type: {{ .Values.postgres.serviceType }}
ports:
- port: {{ .Values.postgres.port }}
targetPort: postgres-port
protocol: TCP
name: postgres
selector:
role: internal-svcs
{{- include "local.selectorLabels" . | nindent 4 }}
{{- end }}
95 changes: 94 additions & 1 deletion deploy/helm-charts/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,32 @@ rabbitmq:
# cpu: 100m
# memory: 128Mi

postgres:
name: postgres
serviceName: postgres
repository: postgres
tag: 15.4
pullPolicy: IfNotPresent
imagePullSecrets: []
username: monai
password: monai
erlangCookie: SWQOKODSQALRPCLNMEQG
vhost: monaideploy
serviceType: NodePort
size: 1Gi
port: 5432
resources: {}
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi

serviceAccount:
# Specifies whether a service account should be created
create: true
Expand Down Expand Up @@ -239,6 +265,73 @@ argo-workflows:
workflowNamespaces:
# include your namespace here
- default
persistence:
archive: true
postgresql:
host: postgres
port: 5432
database: postgres
tableName: argo_workflows
userNameSecret:
name: postgres-secret
key: username
passwordSecret:
name: postgres-secret
key: password
extraInitContainers:
# change the servicename and namespace below if needed <serviceName>.<namespace>.svc.cluster.local
- name: init-postgres
image: docker.io/postgres:14
env:
- name: PGHOST
value: postgres
- name: PGUSER
valueFrom:
secretKeyRef:
name: postgres-secret
key: username
- name: PGPASSWORD
valueFrom:
secretKeyRef:
name: postgres-secret
key: password
- name: PGDATABASE
value: postgres
command:
- /bin/sh
- -c
- |
while ! psql -c 'select 1' > /dev/null 2>&1; do
echo "waiting for Postgres"
sleep 1
done
server:
extraArgs:
- --auth-mode=server
- --auth-mode=server
extraInitContainers:
# change the servicename and namespace below if needed <serviceName>.<namespace>.svc.cluster.local
- name: init-postgres
image: docker.io/postgres:14
env:
- name: PGHOST
value: postgres
- name: PGUSER
valueFrom:
secretKeyRef:
name: postgres-secret
key: username
- name: PGPASSWORD
valueFrom:
secretKeyRef:
name: postgres-secret
key: password
- name: PGDATABASE
value: postgres
command:
- /bin/sh
- -c
- |
while ! psql -c 'select 1' > /dev/null 2>&1; do
echo "waiting for Postgres"
sleep 1
done

0 comments on commit 5b5259b

Please sign in to comment.