From 1a10533de0549e52826912b2831e63f73251d25c Mon Sep 17 00:00:00 2001 From: chliddle Date: Mon, 16 Dec 2024 13:52:13 +0000 Subject: [PATCH] chore: add optional argocd sync waves to jobs --- .../namada-indexer/argo-desired-manifest.yaml | 260 ++++++++++++++++++ .../templates/dependencies-job.yaml | 8 +- .../templates/postgresql-cleanup-hook.yaml | 8 +- charts/namada-indexer/values.yaml | 4 + 4 files changed, 276 insertions(+), 4 deletions(-) create mode 100644 charts/namada-indexer/argo-desired-manifest.yaml diff --git a/charts/namada-indexer/argo-desired-manifest.yaml b/charts/namada-indexer/argo-desired-manifest.yaml new file mode 100644 index 0000000..9dbe746 --- /dev/null +++ b/charts/namada-indexer/argo-desired-manifest.yaml @@ -0,0 +1,260 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + annotations: + helm.sh/hook-weight: '-10' + labels: + app.kubernetes.io/instance: namada-indexer + app.kubernetes.io/managed-by: Helm + app.kubernetes.io/name: namada-indexer + app.kubernetes.io/version: '1.0' + argocd.argoproj.io/instance: namada-indexer + helm.sh/chart: namada-indexer-0.0.0-development + name: namada-indexer + namespace: namada-indexer +spec: + replicas: 1 + selector: + matchLabels: + app.kubernetes.io/instance: namada-indexer + app.kubernetes.io/name: namada-indexer + strategy: + rollingUpdate: + maxSurge: 1 + maxUnavailable: 0 + type: RollingUpdate + template: + metadata: + labels: + app.kubernetes.io/instance: namada-indexer + app.kubernetes.io/name: namada-indexer + spec: + containers: + - env: + - name: DB_USER + valueFrom: + secretKeyRef: + key: username + name: >- + namada.namada-indexer-db.credentials.postgresql.acid.zalan.do + - name: DB_PASSWORD + valueFrom: + secretKeyRef: + key: password + name: >- + namada.namada-indexer-db.credentials.postgresql.acid.zalan.do + envFrom: null + image: null + imagePullPolicy: IfNotPresent + name: chain + resources: + limits: + cpu: 100m + memory: 128Mi + requests: + cpu: 50m + memory: 64Mi + - env: + - name: DB_USER + valueFrom: + secretKeyRef: + key: username + name: >- + namada.namada-indexer-db.credentials.postgresql.acid.zalan.do + - name: DB_PASSWORD + valueFrom: + secretKeyRef: + key: password + name: >- + namada.namada-indexer-db.credentials.postgresql.acid.zalan.do + envFrom: null + image: postgres:15-alpine + imagePullPolicy: IfNotPresent + name: debug + resources: + limits: + cpu: 100m + memory: 128Mi + requests: + cpu: 50m + memory: 64Mi + - env: + - name: DB_USER + valueFrom: + secretKeyRef: + key: username + name: >- + namada.namada-indexer-db.credentials.postgresql.acid.zalan.do + - name: DB_PASSWORD + valueFrom: + secretKeyRef: + key: password + name: >- + namada.namada-indexer-db.credentials.postgresql.acid.zalan.do + envFrom: null + image: null + imagePullPolicy: IfNotPresent + name: governance + resources: + limits: + cpu: 100m + memory: 128Mi + requests: + cpu: 50m + memory: 64Mi + - env: + - name: DB_USER + valueFrom: + secretKeyRef: + key: username + name: >- + namada.namada-indexer-db.credentials.postgresql.acid.zalan.do + - name: DB_PASSWORD + valueFrom: + secretKeyRef: + key: password + name: >- + namada.namada-indexer-db.credentials.postgresql.acid.zalan.do + envFrom: null + image: null + imagePullPolicy: IfNotPresent + name: parameters + resources: + limits: + cpu: 100m + memory: 128Mi + requests: + cpu: 50m + memory: 64Mi + - env: + - name: DB_USER + valueFrom: + secretKeyRef: + key: username + name: >- + namada.namada-indexer-db.credentials.postgresql.acid.zalan.do + - name: DB_PASSWORD + valueFrom: + secretKeyRef: + key: password + name: >- + namada.namada-indexer-db.credentials.postgresql.acid.zalan.do + envFrom: null + image: null + imagePullPolicy: IfNotPresent + name: pos + resources: + limits: + cpu: 100m + memory: 128Mi + requests: + cpu: 50m + memory: 64Mi + - env: + - name: DB_USER + valueFrom: + secretKeyRef: + key: username + name: >- + namada.namada-indexer-db.credentials.postgresql.acid.zalan.do + - name: DB_PASSWORD + valueFrom: + secretKeyRef: + key: password + name: >- + namada.namada-indexer-db.credentials.postgresql.acid.zalan.do + envFrom: null + image: null + imagePullPolicy: IfNotPresent + name: rewards + resources: + limits: + cpu: 100m + memory: 128Mi + requests: + cpu: 50m + memory: 64Mi + - env: + - name: DB_USER + valueFrom: + secretKeyRef: + key: username + name: >- + namada.namada-indexer-db.credentials.postgresql.acid.zalan.do + - name: DB_PASSWORD + valueFrom: + secretKeyRef: + key: password + name: >- + namada.namada-indexer-db.credentials.postgresql.acid.zalan.do + envFrom: null + image: null + imagePullPolicy: IfNotPresent + name: transactions + resources: + limits: + cpu: 100m + memory: 128Mi + requests: + cpu: 50m + memory: 64Mi + - env: + - name: DB_USER + valueFrom: + secretKeyRef: + key: username + name: >- + namada.namada-indexer-db.credentials.postgresql.acid.zalan.do + - name: DB_PASSWORD + valueFrom: + secretKeyRef: + key: password + name: >- + namada.namada-indexer-db.credentials.postgresql.acid.zalan.do + envFrom: null + image: null + imagePullPolicy: IfNotPresent + livenessProbe: + failureThreshold: 3 + httpGet: + path: /health + port: 5001 + initialDelaySeconds: 15 + periodSeconds: 15 + startPeriod: 10 + timeoutSeconds: 10 + name: webserver + ports: + - containerPort: 5001 + name: http + protocol: TCP + resources: + limits: + cpu: 100m + memory: 128Mi + requests: + cpu: 50m + memory: 64Mi + initContainers: + - command: [] + env: + - name: DB_USER + valueFrom: + secretKeyRef: + key: username + name: >- + namada.namada-indexer-db.credentials.postgresql.acid.zalan.do + - name: DB_PASSWORD + valueFrom: + secretKeyRef: + key: password + name: >- + namada.namada-indexer-db.credentials.postgresql.acid.zalan.do + envFrom: null + image: postgres:15-alpine + imagePullPolicy: IfNotPresent + name: init-db + restartPolicy: Always + securityContext: {} + serviceAccountName: namada-indexer + volumes: null diff --git a/charts/namada-indexer/templates/dependencies-job.yaml b/charts/namada-indexer/templates/dependencies-job.yaml index 551e41e..122e60b 100644 --- a/charts/namada-indexer/templates/dependencies-job.yaml +++ b/charts/namada-indexer/templates/dependencies-job.yaml @@ -4,9 +4,13 @@ kind: Job metadata: name: {{ include "namada-indexer.fullname" . }}-wait-dependencies annotations: - "helm.sh/hook": post-install + "helm.sh/hook": "pre-install,pre-upgrade" "helm.sh/hook-weight": "-5" - "helm.sh/hook-delete-policy": hook-succeeded,before-hook-creation + "helm.sh/hook-delete-policy": "before-hook-creation,hook-succeeded" + {{- if .Values.argocd.deployment }} + "argocd.argoproj.io/hook": "PreSync" + "argocd.argoproj.io/sync-wave": "-1" + {{- end }} labels: {{- include "namada-indexer.labels" . | nindent 4 }} spec: diff --git a/charts/namada-indexer/templates/postgresql-cleanup-hook.yaml b/charts/namada-indexer/templates/postgresql-cleanup-hook.yaml index ab93f95..693b9c1 100644 --- a/charts/namada-indexer/templates/postgresql-cleanup-hook.yaml +++ b/charts/namada-indexer/templates/postgresql-cleanup-hook.yaml @@ -4,8 +4,12 @@ kind: Job metadata: name: {{ include "namada-indexer.fullname" . }}-db-cleanup annotations: - "helm.sh/hook": pre-delete - "helm.sh/hook-delete-policy": hook-succeeded,before-hook-creation + "helm.sh/hook": "pre-delete" + "helm.sh/hook-delete-policy": "before-hook-creation,hook-succeeded" + {{- if .Values.argocd.deployment }} + "argocd.argoproj.io/hook": "PreDelete" + "argocd.argoproj.io/sync-wave": "-2" + {{- end }} spec: template: spec: diff --git a/charts/namada-indexer/values.yaml b/charts/namada-indexer/values.yaml index 9f1cab5..41f4cce 100644 --- a/charts/namada-indexer/values.yaml +++ b/charts/namada-indexer/values.yaml @@ -1,5 +1,9 @@ replicaCount: 1 +# If deployed by argocd add sync waves to batch jobs +argocd: + deployment: true + # Common configurations in ConfigMaps configmaps: config: