github.com/smartcontractkit/chainlink-testing-framework/libs@v0.0.0-20240227141906-ec710b4eb1a3/charts/chainlink/templates/pg-deployment.yaml (about) 1 {{- range $cfg := .Values.nodes }} 2 apiVersion: apps/v1 3 {{ if $.Values.db.stateful }} 4 kind: StatefulSet 5 {{ else }} 6 kind: Deployment 7 {{ end }} 8 metadata: 9 name: {{ $.Release.Name }}-postgres-{{ $cfg.name }} 10 spec: 11 {{ if $.Values.db.stateful }} 12 serviceName: {{ $.Release.Name }}-postgres-{{ $cfg.name }} 13 podManagementPolicy: Parallel 14 volumeClaimTemplates: 15 - metadata: 16 name: postgres 17 spec: 18 accessModes: 19 - ReadWriteOnce 20 resources: 21 requests: 22 storage: {{ $.Values.db.capacity }} 23 {{ end }} 24 selector: 25 matchLabels: 26 app: {{ $.Release.Name }}-postgres 27 instance: {{ $cfg.name }} 28 release: {{ $.Release.Name }} 29 template: 30 metadata: 31 labels: 32 app: {{ $.Release.Name }}-postgres 33 instance: {{ $cfg.name }} 34 release: {{ $.Release.Name }} 35 {{- range $key, $value := $.Values.db.labels }} 36 {{ $key }}: {{ $value | quote }} 37 {{- end }} 38 annotations: 39 prometheus.io/scrape: 'true' 40 spec: 41 volumes: 42 - name: {{ $.Release.Name }}-{{ $cfg.name }}-config-map 43 configMap: 44 name: {{ $.Release.Name }}-{{ $cfg.name }}-cm 45 containers: 46 - name: chainlink-db 47 {{- $image := $.Values.db.image.image }} 48 {{- $tag := $.Values.db.image.version }} 49 {{- if $cfg.db }} 50 {{- if $cfg.db.image }} 51 {{- if $cfg.db.image.image }} 52 {{ $image = $cfg.db.image.image }} 53 {{- end }} 54 {{- if $cfg.db.image.version }} 55 {{ $tag = $cfg.db.image.version }} 56 {{- end }} 57 {{- end }} 58 {{- end }} 59 image: {{ $image }}:{{ $tag }} 60 command: 61 - docker-entrypoint.sh 62 args: 63 {{- range $arg := $.Values.db.pgArgs}} 64 - {{ $arg }} 65 {{- end }} 66 {{- range $arg := $.Values.db.additionalArgs}} 67 - {{ $arg }} 68 {{- end }} 69 ports: 70 - name: postgres 71 containerPort: 5432 72 env: 73 - name: POSTGRES_DB 74 value: {{ $.Values.db.postgresDatabase }} 75 - name: POSTGRES_PASSWORD 76 value: {{ $.Values.db.postgresPassword }} 77 - name: PGPASSWORD 78 value: {{ $.Values.db.postgresPassword }} 79 - name: PGUSER 80 value: {{ $.Values.db.postgresUser }} 81 lifecycle: 82 preStop: 83 exec: 84 command: [ "/bin/sh", "-c", "while [ $(psql -d chainlink -c \"SELECT COUNT(*) FROM pg_stat_activity WHERE datname = 'chainlink' AND state = 'active';\" -tA ) -ne 0 ]; do echo \"waiting for connection to become 0\"; sleep 10; done" ] 85 livenessProbe: 86 exec: 87 command: 88 - pg_isready 89 - -U 90 - postgres 91 initialDelaySeconds: 1 92 periodSeconds: 5 93 timeoutSeconds: 10 94 readinessProbe: 95 exec: 96 command: 97 - pg_isready 98 - -U 99 - postgres 100 initialDelaySeconds: 1 101 periodSeconds: 5 102 timeoutSeconds: 10 103 startupProbe: 104 exec: 105 command: 106 - pg_isready 107 - -U 108 - postgres 109 initialDelaySeconds: 15 110 periodSeconds: 5 111 failureThreshold: 20 112 resources: 113 requests: 114 memory: {{ $.Values.db.resources.requests.memory }} 115 cpu: {{ $.Values.db.resources.requests.cpu }} 116 limits: 117 memory: {{ $.Values.db.resources.limits.memory }} 118 cpu: {{ $.Values.db.resources.limits.cpu }} 119 volumeMounts: 120 - mountPath: /docker-entrypoint-initdb.d/init.sql 121 name: {{ $.Release.Name }}-{{ $cfg.name }}-config-map 122 subPath: init.sql 123 {{ if $.Values.db.stateful }} 124 volumeMounts: 125 - mountPath: /var/lib/postgresql/data 126 name: postgres 127 subPath: postgres-db 128 {{ end }} 129 {{- with $.Values.nodeSelector }} 130 nodeSelector: 131 {{ toYaml . | indent 8 }} 132 {{- end }} 133 {{- with $.Values.affinity }} 134 affinity: 135 {{ toYaml . | indent 8 }} 136 {{- end }} 137 {{- with $.Values.tolerations }} 138 tolerations: 139 {{ toYaml . | indent 8 }} 140 {{- end }} 141 --- 142 {{- end }}