Skip to content

Commit b759b1c

Browse files
committed
add support for postgres
Signed-off-by: Davanum Srinivas <[email protected]>
1 parent a84099d commit b759b1c

File tree

46 files changed

+5764
-78
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+5764
-78
lines changed

.github/workflows/e2e-test.yml

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@
1515
name: E2E Tests
1616

1717
# This workflow runs end-to-end tests on both AMD64 and ARM64 architectures in parallel
18-
# to ensure compatibility across different hardware platforms.
18+
# with both MongoDB and PostgreSQL datastores to ensure compatibility across different
19+
# hardware platforms and database backends.
1920
#
2021
# Configuration:
2122
# - Set RUNNER_ARCH_LARGE_AMD64 variable to override default AMD64 runner
2223
# - Set RUNNER_ARCH_LARGE_ARM64 variable to override default ARM64 runner
23-
# - Each architecture gets its own isolated cluster and test artifacts
24+
# - Each architecture + datastore combination gets its own isolated cluster and test artifacts
2425

2526
on:
2627
push:
@@ -39,18 +40,33 @@ permissions:
3940

4041
jobs:
4142
e2e-test:
43+
# Run E2E tests on both AMD64 and ARM64 architectures with both MongoDB and PostgreSQL
4244
strategy:
43-
fail-fast: false # Allow both architectures to complete even if one fails
45+
fail-fast: false # Allow all combinations to complete even if some fail
4446
matrix:
4547
include:
4648
- arch: amd64
4749
runner: ${{ vars.RUNNER_ARCH_LARGE_AMD64 || 'linux-amd64-cpu32' }}
4850
arch_name: "AMD64"
51+
datastore: "mongodb"
52+
datastore_name: "MongoDB"
4953
- arch: arm64
5054
runner: ${{ vars.RUNNER_ARCH_LARGE_ARM64 || 'linux-arm64-cpu32' }}
5155
arch_name: "ARM64"
56+
datastore: "mongodb"
57+
datastore_name: "MongoDB"
58+
- arch: amd64
59+
runner: ${{ vars.RUNNER_ARCH_LARGE_AMD64 || 'linux-amd64-cpu32' }}
60+
arch_name: "AMD64"
61+
datastore: "postgresql"
62+
datastore_name: "PostgreSQL"
63+
- arch: arm64
64+
runner: ${{ vars.RUNNER_ARCH_LARGE_ARM64 || 'linux-arm64-cpu32' }}
65+
arch_name: "ARM64"
66+
datastore: "postgresql"
67+
datastore_name: "PostgreSQL"
5268

53-
name: "E2E Tests (${{ matrix.arch_name }})"
69+
name: "E2E Tests (${{ matrix.arch_name }} + ${{ matrix.datastore_name }})"
5470
runs-on: ${{ matrix.runner }}
5571
timeout-minutes: 90
5672
steps:
@@ -120,24 +136,32 @@ jobs:
120136
env:
121137
CI_COMMIT_REF_NAME: ${{ steps.ref-name.outputs.value }}
122138
CTLPTL_YAML: .ctlptl.yaml
123-
# Make cluster names unique per architecture to avoid conflicts in parallel runs
124-
CLUSTER_NAME_SUFFIX: "-${{ matrix.arch }}"
139+
# Make cluster names unique per architecture and datastore to avoid conflicts in parallel runs
140+
CLUSTER_NAME_SUFFIX: "-${{ matrix.arch }}-${{ matrix.datastore }}"
125141
run: |
126142
make cluster-create
127143
144+
- name: Override MongoDB image for ARM64
145+
if: matrix.arch == 'arm64' && matrix.datastore == 'mongodb'
146+
run: |
147+
sed -i 's/repository: "bitnamilegacy\/mongodb"/repository: "dlavrenuek\/bitnami-mongodb-arm"/' distros/kubernetes/nvsentinel/values-tilt.yaml
148+
sed -i 's/tag: "8.0.3-debian-12-r1"/tag: "8.0.4"/' distros/kubernetes/nvsentinel/values-tilt.yaml
149+
128150
- name: Run E2E tests
129151
env:
130152
CI_COMMIT_REF_NAME: ${{ steps.ref-name.outputs.value }}
131153
CTLPTL_YAML: .ctlptl.yaml
132154
# Use same cluster name suffix for consistency
133-
CLUSTER_NAME_SUFFIX: "-${{ matrix.arch }}"
155+
CLUSTER_NAME_SUFFIX: "-${{ matrix.arch }}-${{ matrix.datastore }}"
156+
# Set USE_POSTGRESQL for PostgreSQL tests (our integrated Tiltfile approach)
157+
USE_POSTGRESQL: ${{ matrix.datastore == 'postgresql' && '1' || '0' }}
134158
run: |
135159
make e2e-test-ci
136160
137161
- name: Upload test results
138162
uses: ./.github/actions/upload-test-artifacts
139163
with:
140-
component-name: e2e-test-${{ matrix.arch }}
164+
component-name: e2e-test-${{ matrix.arch }}-${{ matrix.datastore }}
141165
file-paths: |
142166
tests/results/
143167
tests/*.log
@@ -167,15 +191,15 @@ jobs:
167191
if: always()
168192
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
169193
with:
170-
name: e2e-kind-logs-${{ matrix.arch }}-${{ github.run_id }}
194+
name: e2e-kind-logs-${{ matrix.arch }}-${{ matrix.datastore }}-${{ github.run_id }}
171195
path: /tmp/kind-logs/
172196
retention-days: 7
173197

174198
- name: Upload debug artifacts
175199
if: failure()
176200
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
177201
with:
178-
name: e2e-debug-artifacts-${{ matrix.arch }}-${{ github.run_id }}
202+
name: e2e-debug-artifacts-${{ matrix.arch }}-${{ matrix.datastore }}-${{ github.run_id }}
179203
path: /tmp/debug-artifacts/
180204
retention-days: 7
181205

distros/kubernetes/nvsentinel/Chart.lock

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ dependencies:
55
- name: mongodb-store
66
repository: ""
77
version: 0.1.0
8+
- name: postgresql
9+
repository: oci://registry-1.docker.io/bitnamicharts
10+
version: 15.5.38
811
- name: fault-quarantine
912
repository: ""
1013
version: 0.1.0
@@ -29,5 +32,11 @@ dependencies:
2932
- name: labeler
3033
repository: ""
3134
version: 0.1.0
32-
digest: sha256:c10f6e7fdb0b99a47f38e210c25e610da182c94fe32d89753a34352d12c0bb22
33-
generated: "2025-10-15T10:37:19.739789+05:30"
35+
- name: janitor
36+
repository: ""
37+
version: 0.1.0
38+
- name: metadata-collector
39+
repository: ""
40+
version: 0.1.0
41+
digest: sha256:fbd3a4e221d47238452d3d157828b25b66eab2c1f02f829c3edbada6d3b11efe
42+
generated: "2025-11-16T11:25:12.087718-05:00"

distros/kubernetes/nvsentinel/Chart.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ dependencies:
2525
- name: mongodb-store
2626
version: "0.1.0"
2727
condition: global.mongodbStore.enabled
28+
- name: postgresql
29+
version: "15.5.38"
30+
repository: oci://registry-1.docker.io/bitnamicharts
31+
condition: postgresql.enabled
2832
- name: fault-quarantine
2933
version: "0.1.0"
3034
condition: global.faultQuarantine.enabled

distros/kubernetes/nvsentinel/charts/csp-health-monitor/templates/deployment.yaml

Lines changed: 73 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,54 @@ spec:
3636
{{- toYaml . | nindent 8 }}
3737
{{- end }}
3838
serviceAccountName: {{ include "csp-health-monitor.fullname" . }}
39+
{{- if and .Values.global.datastore (eq .Values.global.datastore.provider "postgresql") }}
40+
initContainers:
41+
- name: fix-cert-permissions
42+
image: "docker.io/bitnamilegacy/os-shell:12-debian-12-r30"
43+
imagePullPolicy: IfNotPresent
44+
securityContext:
45+
runAsUser: 1001
46+
runAsGroup: 1001
47+
command:
48+
- sh
49+
- -c
50+
- |
51+
echo "Copying PostgreSQL client certificates with correct permissions..."
52+
cp /etc/ssl/client-certs-original/tls.crt /etc/ssl/client-certs-fixed/
53+
cp /etc/ssl/client-certs-original/ca.crt /etc/ssl/client-certs-fixed/
54+
cp /etc/ssl/client-certs-original/tls.key /etc/ssl/client-certs-fixed/
55+
chmod 644 /etc/ssl/client-certs-fixed/tls.crt
56+
chmod 644 /etc/ssl/client-certs-fixed/ca.crt
57+
chmod 600 /etc/ssl/client-certs-fixed/tls.key
58+
echo "Certificate permissions fixed:"
59+
ls -la /etc/ssl/client-certs-fixed/
60+
volumeMounts:
61+
- name: postgresql-client-cert-original
62+
mountPath: /etc/ssl/client-certs-original
63+
readOnly: true
64+
- name: client-certs-fixed
65+
mountPath: /etc/ssl/client-certs-fixed
66+
{{- end }}
3967
volumes:
4068
- name: config-volume
4169
configMap:
4270
name: {{ include "csp-health-monitor.fullname" . }}
4371
items:
4472
- key: config.toml
4573
path: config.toml
74+
{{- if and .Values.global.datastore (eq .Values.global.datastore.provider "postgresql") }}
75+
- name: postgresql-client-cert-original
76+
secret:
77+
secretName: postgresql-client-cert
78+
optional: true
79+
- name: client-certs-fixed
80+
emptyDir: {}
81+
{{- else }}
4682
- name: mongo-app-client-cert
4783
secret:
4884
secretName: mongo-app-client-cert-secret # Defined in mongodb-store chart
4985
optional: true
86+
{{- end }}
5087
- name: platform-connector-uds
5188
hostPath:
5289
path: /var/run/nvsentinel
@@ -55,10 +92,19 @@ spec:
5592
- name: {{ .Chart.Name }}
5693
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default ((.Values.global).image).tag | default .Chart.AppVersion }}"
5794
imagePullPolicy: {{ .Values.image.pullPolicy }}
95+
{{- if and .Values.global.datastore (eq .Values.global.datastore.provider "postgresql") }}
96+
securityContext:
97+
runAsUser: 1001
98+
runAsGroup: 1001
99+
{{- end }}
58100
args:
59101
- "--config=/etc/config/config.toml"
60102
- "--metrics-port={{ ((.Values.global).metricsPort) | default 2112 }}"
61-
- "--mongo-client-cert-mount-path=/etc/ssl/mongo-client"
103+
{{- if and .Values.global.datastore (eq .Values.global.datastore.provider "postgresql") }}
104+
- "--mongo-client-cert-mount-path={{ .Values.clientCertMountPath }}"
105+
{{- else }}
106+
- "--mongo-client-cert-mount-path={{ .Values.clientCertMountPath }}"
107+
{{- end }}
62108
resources:
63109
{{- toYaml .Values.resources | nindent 12 }}
64110
ports:
@@ -68,25 +114,40 @@ spec:
68114
volumeMounts:
69115
- name: config-volume
70116
mountPath: /etc/config/
117+
{{- if and .Values.global.datastore (eq .Values.global.datastore.provider "postgresql") }}
118+
- name: client-certs-fixed
119+
mountPath: {{ .Values.clientCertMountPath }}
120+
readOnly: true
121+
{{- else }}
71122
- name: mongo-app-client-cert
72-
mountPath: /etc/ssl/mongo-client
123+
mountPath: {{ .Values.clientCertMountPath }}
73124
readOnly: true
125+
{{- end }}
74126
env:
75127
- name: LOG_LEVEL
76128
value: "{{ .Values.logLevel }}"
77129
envFrom:
78130
- configMapRef:
79-
name: mongodb-config
131+
name: {{ if .Values.global.datastore }}{{ .Release.Name }}-datastore-config{{ else }}mongodb-config{{ end }}
80132
optional: true
81133

82134
- name: maintenance-notifier
83135
image: "{{ .Values.quarantineTriggerEngine.image.repository }}:{{ .Values.image.tag | default ((.Values.global).image).tag | default .Chart.AppVersion }}"
84136
imagePullPolicy: {{ .Values.quarantineTriggerEngine.image.pullPolicy | default .Values.image.pullPolicy }}
85137
securityContext:
138+
{{- if and .Values.global.datastore (eq .Values.global.datastore.provider "postgresql") }}
139+
runAsUser: 1001
140+
runAsGroup: 1001
141+
{{- else }}
86142
runAsUser: 0
143+
{{- end }}
87144
args:
88145
- "--config=/etc/config/config.toml"
89-
- "--mongo-client-cert-mount-path=/etc/ssl/mongo-client"
146+
{{- if and .Values.global.datastore (eq .Values.global.datastore.provider "postgresql") }}
147+
- "--mongo-client-cert-mount-path={{ .Values.clientCertMountPath }}"
148+
{{- else }}
149+
- "--mongo-client-cert-mount-path={{ .Values.clientCertMountPath }}"
150+
{{- end }}
90151
- "--uds-path=/run/nvsentinel/nvsentinel.sock"
91152
- "--metrics-port=2113"
92153
resources:
@@ -98,17 +159,23 @@ spec:
98159
volumeMounts:
99160
- name: config-volume
100161
mountPath: /etc/config/
162+
{{- if and .Values.global.datastore (eq .Values.global.datastore.provider "postgresql") }}
163+
- name: client-certs-fixed
164+
mountPath: {{ .Values.clientCertMountPath }}
165+
readOnly: true
166+
{{- else }}
101167
- name: mongo-app-client-cert
102-
mountPath: /etc/ssl/mongo-client
168+
mountPath: {{ .Values.clientCertMountPath }}
103169
readOnly: true
170+
{{- end }}
104171
- name: platform-connector-uds
105172
mountPath: /run/nvsentinel
106173
env:
107174
- name: LOG_LEVEL
108175
value: "{{ .Values.quarantineTriggerEngine.logLevel | default .Values.logLevel }}"
109176
envFrom:
110177
- configMapRef:
111-
name: mongodb-config
178+
name: {{ if .Values.global.datastore }}{{ .Release.Name }}-datastore-config{{ else }}mongodb-config{{ end }}
112179
optional: true
113180
restartPolicy: Always
114181
{{- with (((.Values.global).systemNodeSelector) | default .Values.nodeSelector) }}

distros/kubernetes/nvsentinel/charts/csp-health-monitor/values.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ podAnnotations: {}
5252
# Log verbosity level for the main CSP health monitor container (e.g. "debug", "info", "warn", "error")
5353
logLevel: info
5454

55+
# Client certificate mount path for database connections
56+
clientCertMountPath: /etc/ssl/client-certs
57+
5558
# cspName specifies the active cloud service provider. Can be "gcp" or "aws".
5659
cspName: ""
5760

0 commit comments

Comments
 (0)