diff --git a/deploy/helm-charts/docs/01.installation.md b/deploy/helm-charts/docs/01.installation.md index 5d6a09f..a2722f1 100644 --- a/deploy/helm-charts/docs/01.installation.md +++ b/deploy/helm-charts/docs/01.installation.md @@ -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 diff --git a/deploy/helm-charts/docs/03.TriggerNewJobs.md b/deploy/helm-charts/docs/03.TriggerNewJobs.md index 2652844..d281c6a 100644 --- a/deploy/helm-charts/docs/03.TriggerNewJobs.md +++ b/deploy/helm-charts/docs/03.TriggerNewJobs.md @@ -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: diff --git a/deploy/helm-charts/files/sample-workflows/hello-world-argo-template.yml b/deploy/helm-charts/files/sample-workflows/hello-world-argo-template.yml index 7b557fd..3dde89f 100644 --- a/deploy/helm-charts/files/sample-workflows/hello-world-argo-template.yml +++ b/deploy/helm-charts/files/sample-workflows/hello-world-argo-template.yml @@ -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 @@ -62,4 +60,4 @@ spec: - /bin/sh args: - '-c' - - date && cp -r /var/monai/input/* /var/monai/output && date \ No newline at end of file + - date && cp -vr /var/monai/input/* /var/monai/output && date \ No newline at end of file diff --git a/deploy/helm-charts/templates/00-secrets.yaml b/deploy/helm-charts/templates/00-secrets.yaml index e96efa4..498e689 100644 --- a/deploy/helm-charts/templates/00-secrets.yaml +++ b/deploy/helm-charts/templates/00-secrets.yaml @@ -33,4 +33,15 @@ metadata: name: {{ .Values.rabbitmq.name }}-secret data: username: {{ .Values.rabbitmq.username | b64enc | quote }} - password: {{ .Values.rabbitmq.password | b64enc | quote }} \ No newline at end of file + 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 }} \ No newline at end of file diff --git a/deploy/helm-charts/templates/05-postgres-deployment.yaml b/deploy/helm-charts/templates/05-postgres-deployment.yaml new file mode 100644 index 0000000..c1ee150 --- /dev/null +++ b/deploy/helm-charts/templates/05-postgres-deployment.yaml @@ -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 }} diff --git a/deploy/helm-charts/templates/05-postgres-pvc.yaml b/deploy/helm-charts/templates/05-postgres-pvc.yaml new file mode 100644 index 0000000..6cc5f44 --- /dev/null +++ b/deploy/helm-charts/templates/05-postgres-pvc.yaml @@ -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 }} diff --git a/deploy/helm-charts/templates/05-postgres-service.yaml b/deploy/helm-charts/templates/05-postgres-service.yaml new file mode 100644 index 0000000..202d231 --- /dev/null +++ b/deploy/helm-charts/templates/05-postgres-service.yaml @@ -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 }} diff --git a/deploy/helm-charts/values.yaml b/deploy/helm-charts/values.yaml index 5eded20..297dfaa 100644 --- a/deploy/helm-charts/values.yaml +++ b/deploy/helm-charts/values.yaml @@ -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 @@ -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 ..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 \ No newline at end of file + - --auth-mode=server + extraInitContainers: + # change the servicename and namespace below if needed ..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 \ No newline at end of file