Skip to content

Commit c48145e

Browse files
committed
fix postgres impl
Signed-off-by: Davanum Srinivas <[email protected]>
1 parent a55619f commit c48145e

File tree

22 files changed

+823
-162
lines changed

22 files changed

+823
-162
lines changed

.github/workflows/lint-test.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ jobs:
6767
- component: helm-charts
6868
make_command: 'make helm-lint'
6969
step_name: 'Validate Helm charts'
70+
- component: postgres-schema
71+
make_command: 'make validate-postgres-schema'
72+
step_name: 'Validate PostgreSQL schema consistency'
7073
- component: scripts
7174
make_command: 'make -C scripts lint'
7275
step_name: 'Run shellcheck on scripts'

Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -821,3 +821,16 @@ help: ## Display available make targets
821821
@echo " CTLPTL_CONFIG_FILE=$(CTLPTL_CONFIG_FILE), REGISTRY_PORT=$(REGISTRY_PORT)"
822822
@echo ""
823823
@echo "Sub-Makefiles: health-monitors/, docker/, distros/kubernetes/, tests/"
824+
825+
#==============================================================================
826+
# PostgreSQL Schema Management
827+
#==============================================================================
828+
829+
.PHONY: validate-postgres-schema
830+
validate-postgres-schema: ## Validate PostgreSQL schema consistency between docs and Helm values
831+
@./scripts/validate-postgres-schema.sh
832+
833+
.PHONY: update-helm-postgres-schema
834+
update-helm-postgres-schema: ## Update Helm values file with schema from docs/postgresql-schema.sql
835+
@./scripts/update-helm-postgres-schema.sh
836+

distros/kubernetes/nvsentinel/templates/configmap.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ data:
2424
"enableK8sPlatformConnector": "{{ .Values.platformConnector.k8sConnector.enabled }}",
2525
"K8sConnectorQps": {{ printf "%.2f" .Values.platformConnector.k8sConnector.qps }},
2626
"K8sConnectorBurst": {{ .Values.platformConnector.k8sConnector.burst }},
27-
"enableMongoDBStorePlatformConnector": "{{ .Values.global.mongodbStore.enabled }}"
27+
"enableMongoDBStorePlatformConnector": "{{ .Values.global.mongodbStore.enabled }}",
28+
"enablePostgresDBStorePlatformConnector": {{ if and .Values.global.datastore .Values.global.datastore.provider }}{{ eq .Values.global.datastore.provider "postgresql" | quote }}{{ else }}"false"{{ end }},
2829
{{- if .Values.platformConnector.nodeMetadata }}
2930
,"nodeMetadataAugmentationEnabled": "{{ .Values.platformConnector.nodeMetadata.enabled }}"
3031
,"nodeMetadataCacheSize": {{ .Values.platformConnector.nodeMetadata.cacheSize }}

distros/kubernetes/nvsentinel/templates/daemonset.yaml

Lines changed: 60 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,42 @@ spec:
4141
{{- toYaml . | nindent 8 }}
4242
{{- end }}
4343
serviceAccountName: {{ include "nvsentinel.serviceAccountName" . }}
44+
{{- if and .Values.global.datastore (eq .Values.global.datastore.provider "postgresql") }}
45+
initContainers:
46+
- name: fix-cert-permissions
47+
image: "docker.io/bitnamilegacy/os-shell:12-debian-12-r30"
48+
imagePullPolicy: IfNotPresent
49+
securityContext:
50+
runAsUser: 0
51+
command:
52+
- sh
53+
- -c
54+
- |
55+
echo "Copying PostgreSQL client certificates with correct permissions..."
56+
cp /etc/ssl/client-certs-original/tls.crt /etc/ssl/client-certs-fixed/
57+
cp /etc/ssl/client-certs-original/ca.crt /etc/ssl/client-certs-fixed/
58+
cp /etc/ssl/client-certs-original/tls.key /etc/ssl/client-certs-fixed/
59+
chmod 644 /etc/ssl/client-certs-fixed/tls.crt
60+
chmod 644 /etc/ssl/client-certs-fixed/ca.crt
61+
chmod 600 /etc/ssl/client-certs-fixed/tls.key
62+
echo "Certificate permissions fixed:"
63+
ls -la /etc/ssl/client-certs-fixed/
64+
volumeMounts:
65+
- name: postgresql-client-cert-original
66+
mountPath: /etc/ssl/client-certs-original
67+
readOnly: true
68+
- name: client-certs-fixed
69+
mountPath: /etc/ssl/client-certs-fixed
70+
{{- end }}
4471
containers:
4572
- name: platform-connector
73+
image: "{{ .Values.platformConnector.image.repository }}:{{ .Values.platformConnector.image.tag | default .Values.global.image.tag | default .Chart.AppVersion }}"
74+
imagePullPolicy: {{ .Values.platformConnector.image.pullPolicy }}
75+
securityContext:
76+
runAsUser: 0
77+
capabilities:
78+
drop:
79+
- ALL
4680
ports:
4781
- name: metrics
4882
containerPort: {{ .Values.global.metricsPort }}
@@ -62,17 +96,14 @@ spec:
6296
periodSeconds: 10
6397
timeoutSeconds: 3
6498
failureThreshold: 3
65-
securityContext:
66-
runAsUser: 0
67-
capabilities:
68-
drop:
69-
- ALL
70-
image: "{{ .Values.platformConnector.image.repository }}:{{ .Values.platformConnector.image.tag | default .Values.global.image.tag | default .Chart.AppVersion }}"
71-
imagePullPolicy: {{ .Values.platformConnector.image.pullPolicy }}
7299
args:
73100
- "--config=/etc/config/config.json"
74101
- "--metrics-port={{ .Values.global.metricsPort }}"
75-
- "--mongo-client-cert-mount-path=/etc/ssl/mongo-client"
102+
{{- if and .Values.global.datastore (eq .Values.global.datastore.provider "postgresql") }}
103+
- "--database-client-cert-mount-path={{ .Values.platformConnector.postgresqlStore.clientCertMountPath }}"
104+
{{- else }}
105+
- "--mongo-client-cert-mount-path={{ .Values.platformConnector.mongodbStore.clientCertMountPath }}"
106+
{{- end }}
76107
- "--socket={{ .Values.socketPath }}"
77108
resources:
78109
{{- toYaml .Values.platformConnector.resources | nindent 12 }}
@@ -81,9 +112,15 @@ spec:
81112
mountPath: /var/run
82113
- name: platform-connector-configmap
83114
mountPath: /etc/config/
115+
{{- if and .Values.global.datastore (eq .Values.global.datastore.provider "postgresql") }}
116+
- name: client-certs-fixed
117+
mountPath: {{ .Values.platformConnector.postgresqlStore.clientCertMountPath }}
118+
readOnly: true
119+
{{- else }}
84120
- name: mongo-app-client-cert
85-
mountPath: /etc/ssl/mongo-client
121+
mountPath: {{ .Values.platformConnector.mongodbStore.clientCertMountPath }}
86122
readOnly: true
123+
{{- end }}
87124
env:
88125
- name: NODE_NAME
89126
valueFrom:
@@ -92,8 +129,13 @@ spec:
92129
fieldPath: spec.nodeName
93130
- name: LOG_LEVEL
94131
value: "{{ .Values.platformConnector.logLevel }}"
132+
{{- if and .Values.global.datastore (eq .Values.global.datastore.provider "postgresql") }}
133+
- name: POSTGRESQL_CLIENT_CERT_MOUNT_PATH
134+
value: {{ .Values.platformConnector.postgresqlStore.clientCertMountPath }}
135+
{{- else }}
95136
- name: MONGODB_CLIENT_CERT_MOUNT_PATH
96137
value: {{ .Values.platformConnector.mongodbStore.clientCertMountPath }}
138+
{{- end }}
97139
envFrom:
98140
- configMapRef:
99141
name: {{ if .Values.global.datastore }}{{ .Release.Name }}-datastore-config{{ else }}mongodb-config{{ end }}
@@ -106,10 +148,19 @@ spec:
106148
- name: platform-connector-configmap
107149
configMap:
108150
name: {{ include "nvsentinel.fullname" . }}
151+
{{- if and .Values.global.datastore (eq .Values.global.datastore.provider "postgresql") }}
152+
- name: postgresql-client-cert-original
153+
secret:
154+
secretName: postgresql-client-cert
155+
optional: false
156+
- name: client-certs-fixed
157+
emptyDir: {}
158+
{{- else }}
109159
- name: mongo-app-client-cert
110160
secret:
111161
secretName: mongo-app-client-cert-secret
112162
optional: true
163+
{{- end }}
113164
{{- with (.Values.global.tolerations | default .Values.platformConnector.tolerations) }}
114165
tolerations:
115166
{{- toYaml . | nindent 8 }}

0 commit comments

Comments
 (0)