Skip to content

Commit 6d0bbf8

Browse files
committed
Deploy: updated charts.
1 parent 1abca2f commit 6d0bbf8

File tree

10 files changed

+144
-42
lines changed

10 files changed

+144
-42
lines changed

deploy/charts/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,4 @@ helm upgrade --install cogstack-opensearch ./deploy/charts/opensearch \
4343
```
4444

4545
The OpenSearch and Dashboards config files should come from `services/`, and the security files from `security/`, so Docker and Kubernetes use the same source files.
46-
Only keys in `envFile.includeKeys` and `usersEnvFile.includeKeys` are imported.
46+
Only keys in `envFile.includeKeys`, `usersEnvFile.includeKeys`, and `certificatesEnvFile.includeKeys` are imported.

deploy/charts/opensearch/README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ Helm chart for deploying OpenSearch and/or OpenSearch Dashboards using the CogSt
1212
- `log4j2.properties` (when `opensearch.enabled=true`)
1313
- OpenSearch Security files (`config.yml`, `internal_users.yml`, `roles.yml`, `roles_mapping.yml`) (when `opensearch.enabled=true`)
1414
- `opensearch_dashboards.yml`
15+
- PVC-backed `data`, `logs`, and performance-analyzer storage for OpenSearch by default
1516

1617
## Prerequisites
1718

1819
1. Kubernetes cluster with dynamic PV provisioning (if `opensearch.enabled=true` and `persistence.enabled=true`).
1920
2. Kubernetes Secrets containing TLS materials for enabled components.
2021
3. If `credentials.create=false`, an existing Secret with:
21-
- `OPENSEARCH_INITIAL_ADMIN_PASSWORD`
22-
- `KIBANA_USER`
23-
- `KIBANA_PASSWORD`
22+
- `OPENSEARCH_INITIAL_ADMIN_PASSWORD` when `opensearch.enabled=true`
23+
- `KIBANA_USER` and `KIBANA_PASSWORD` when `dashboards.enabled=true`
2424

2525
## Required certificate secrets
2626

@@ -120,14 +120,15 @@ helm template cogstack-opensearch ./deploy/charts/opensearch \
120120
- In this repo, the chart `files/` entries are symlinked to the shared `services/` and `security/` sources so Docker and Kubernetes stay aligned.
121121
- The standard install/render commands still use `--set-file` explicitly to make the source-of-truth paths obvious at invocation time.
122122
- If you run Helm from `deploy/charts/opensearch`, the equivalent relative paths are `../../../services/...` and `../../../security/...`.
123-
- `envFile.raw` can be set from `deploy/elasticsearch.env` and is loaded via `envFrom` into OpenSearch and Dashboards.
124-
- `usersEnvFile.raw` can be set from `security/env/users_elasticsearch.env` and feeds the credentials Secret (`OPENSEARCH_INITIAL_ADMIN_PASSWORD`, `KIBANA_USER`, `KIBANA_PASSWORD`).
123+
- `envFile.raw` can be set from `deploy/elasticsearch.env`; the chart reads shared values from it (`ELASTICSEARCH_CLUSTER_NAME`, `ELASTICSEARCH_JAVA_OPTS` / `OPENSEARCH_JAVA_OPTS`, `KIBANA_SERVER_NAME`) and still generates Kubernetes-specific discovery and publish-host settings itself.
124+
- `usersEnvFile.raw` can be set from `security/env/users_elasticsearch.env` and feeds only the credential keys required by the enabled components.
125125
- `certificatesEnvFile.raw` can be set from `security/env/certificates_elasticsearch.env`; currently `ES_CLIENT_CERT_NAME` is used to resolve Dashboards cert secret keys (`<name>.pem` / `<name>.key`).
126-
- `deploy/elasticsearch.env` shared values are used where they make sense on Kubernetes (`ELASTICSEARCH_CLUSTER_NAME`, `OPENSEARCH_JAVA_OPTS`, `KIBANA_SERVER_NAME`), while pod IP and discovery hosts remain Kubernetes-specific.
126+
- `deploy/elasticsearch.env` shared values are used where they make sense on Kubernetes (`ELASTICSEARCH_CLUSTER_NAME`, `ELASTICSEARCH_JAVA_OPTS` / `OPENSEARCH_JAVA_OPTS`, `KIBANA_SERVER_NAME`), while pod IP and discovery hosts remain Kubernetes-specific.
127127
- By default, `certificates.opensearchNodeFiles[*]` maps pod ordinals `0/1/2` to repo-style node cert keys `elasticsearch-1/2/3`.
128+
- `opensearch.logPersistence` and `opensearch.performanceAnalyzerPersistence` default to PVC-backed storage to stay closer to the Docker Compose deployment.
129+
- `opensearch.snapshotBackups` adds shared PVC-backed mounts for `/mnt/es_data_backups` and `/mnt/es_config_backups`; use RWX storage or set `existingClaim` values, and still set `path.repo` in the shared OpenSearch config if you want the cluster to use them.
128130
- `configFiles.opensearchRaw` can be set from `services/elasticsearch/config/opensearch.yml`.
129131
- `configFiles.log4jRaw` can be set from `services/elasticsearch/config/log4j2_opensearch.properties`.
130132
- `configFiles.dashboardsRaw` can be set from `services/kibana/config/opensearch.yml`.
131133
- `securityFiles.*Raw` can be set from `security/es_roles/opensearch/*.yml` and overrides the chart-bundled OpenSearch security files.
132-
- Only keys listed in `envFile.includeKeys` are imported (to avoid leaking secrets from env files into ConfigMaps).
133134
- Review security and certificate settings before production use.

deploy/charts/opensearch/templates/_helpers.tpl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,13 @@ app.kubernetes.io/component: dashboards
6464
{{- end -}}
6565
{{- end -}}
6666

67-
{{/* Env ConfigMap name */}}
68-
{{- define "cogstack-opensearch.envConfigMapName" -}}
69-
{{- printf "%s-elasticsearch-env" (include "cogstack-opensearch.fullname" .) -}}
67+
{{/* Snapshot backup PVC names */}}
68+
{{- define "cogstack-opensearch.snapshotBackupDataPvcName" -}}
69+
{{- printf "%s-snapshot-backup-data" (include "cogstack-opensearch.fullname" .) -}}
70+
{{- end -}}
71+
72+
{{- define "cogstack-opensearch.snapshotBackupConfigPvcName" -}}
73+
{{- printf "%s-snapshot-backup-config" (include "cogstack-opensearch.fullname" .) -}}
7074
{{- end -}}
7175

7276
{{/* Parse deploy/elasticsearch.env into a filtered YAML map */}}

deploy/charts/opensearch/templates/configmap-elasticsearch-env.yaml

Lines changed: 0 additions & 11 deletions
This file was deleted.

deploy/charts/opensearch/templates/deployment-dashboards.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,6 @@ spec:
4444
- name: http
4545
containerPort: {{ .Values.dashboards.service.port }}
4646
protocol: TCP
47-
{{- if .Values.envFile.raw }}
48-
envFrom:
49-
- configMapRef:
50-
name: {{ include "cogstack-opensearch.envConfigMapName" . }}
51-
{{- end }}
5247
env:
5348
- name: KIBANA_SERVER_NAME
5449
value: {{ $serverName | quote }}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{{- if and .Values.opensearch.enabled .Values.opensearch.snapshotBackups.enabled }}
2+
{{- if not .Values.opensearch.snapshotBackups.data.existingClaim }}
3+
apiVersion: v1
4+
kind: PersistentVolumeClaim
5+
metadata:
6+
name: {{ include "cogstack-opensearch.snapshotBackupDataPvcName" . }}
7+
labels:
8+
{{- include "cogstack-opensearch.labels" . | nindent 4 }}
9+
app.kubernetes.io/component: opensearch
10+
spec:
11+
accessModes:
12+
{{- toYaml .Values.opensearch.snapshotBackups.data.accessModes | nindent 4 }}
13+
resources:
14+
requests:
15+
storage: {{ .Values.opensearch.snapshotBackups.data.size }}
16+
{{- if .Values.opensearch.snapshotBackups.data.storageClassName }}
17+
storageClassName: {{ .Values.opensearch.snapshotBackups.data.storageClassName | quote }}
18+
{{- end }}
19+
{{- end }}
20+
{{- if and (not .Values.opensearch.snapshotBackups.data.existingClaim) (not .Values.opensearch.snapshotBackups.config.existingClaim) }}
21+
---
22+
{{- end }}
23+
{{- if not .Values.opensearch.snapshotBackups.config.existingClaim }}
24+
apiVersion: v1
25+
kind: PersistentVolumeClaim
26+
metadata:
27+
name: {{ include "cogstack-opensearch.snapshotBackupConfigPvcName" . }}
28+
labels:
29+
{{- include "cogstack-opensearch.labels" . | nindent 4 }}
30+
app.kubernetes.io/component: opensearch
31+
spec:
32+
accessModes:
33+
{{- toYaml .Values.opensearch.snapshotBackups.config.accessModes | nindent 4 }}
34+
resources:
35+
requests:
36+
storage: {{ .Values.opensearch.snapshotBackups.config.size }}
37+
{{- if .Values.opensearch.snapshotBackups.config.storageClassName }}
38+
storageClassName: {{ .Values.opensearch.snapshotBackups.config.storageClassName | quote }}
39+
{{- end }}
40+
{{- end }}
41+
{{- end }}

deploy/charts/opensearch/templates/secret-credentials.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{- if and .Values.credentials.create (not .Values.credentials.existingSecret) }}
1+
{{- if and .Values.credentials.create (not .Values.credentials.existingSecret) (or .Values.opensearch.enabled .Values.dashboards.enabled) }}
22
{{- $usersData := include "cogstack-opensearch.parsedUsersEnvFile" . | fromYaml | default (dict) -}}
33
{{- $adminPassword := .Values.credentials.adminPassword -}}
44
{{- if hasKey $usersData "OPENSEARCH_INITIAL_ADMIN_PASSWORD" -}}
@@ -20,7 +20,11 @@ metadata:
2020
{{- include "cogstack-opensearch.labels" . | nindent 4 }}
2121
type: Opaque
2222
stringData:
23+
{{- if .Values.opensearch.enabled }}
2324
OPENSEARCH_INITIAL_ADMIN_PASSWORD: {{ $adminPassword | quote }}
25+
{{- end }}
26+
{{- if .Values.dashboards.enabled }}
2427
KIBANA_USER: {{ $kibanaUser | quote }}
2528
KIBANA_PASSWORD: {{ $kibanaPassword | quote }}
29+
{{- end }}
2630
{{- end }}

deploy/charts/opensearch/templates/statefulset-opensearch.yaml

Lines changed: 47 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,6 @@ spec:
9292
- name: analyzer
9393
containerPort: {{ .Values.opensearch.service.analyzerPort }}
9494
protocol: TCP
95-
{{- if .Values.envFile.raw }}
96-
envFrom:
97-
- configMapRef:
98-
name: {{ include "cogstack-opensearch.envConfigMapName" . }}
99-
{{- end }}
10095
env:
10196
- name: POD_IP
10297
valueFrom:
@@ -212,6 +207,12 @@ spec:
212207
mountPath: /usr/share/opensearch/logs
213208
- name: performance-analyzer
214209
mountPath: /usr/share/opensearch/config/opensearch-performance-analyzer/plugins-stats-metadata
210+
{{- if .Values.opensearch.snapshotBackups.enabled }}
211+
- name: snapshot-backup-data
212+
mountPath: {{ .Values.opensearch.snapshotBackups.data.mountPath }}
213+
- name: snapshot-backup-config
214+
mountPath: {{ .Values.opensearch.snapshotBackups.config.mountPath }}
215+
{{- end }}
215216
volumes:
216217
- name: opensearch-config
217218
configMap:
@@ -230,14 +231,26 @@ spec:
230231
secret:
231232
secretName: {{ .Values.certificates.opensearchSecretName }}
232233
{{- end }}
234+
{{- if .Values.opensearch.snapshotBackups.enabled }}
235+
- name: snapshot-backup-data
236+
persistentVolumeClaim:
237+
claimName: {{ default (include "cogstack-opensearch.snapshotBackupDataPvcName" .) .Values.opensearch.snapshotBackups.data.existingClaim }}
238+
- name: snapshot-backup-config
239+
persistentVolumeClaim:
240+
claimName: {{ default (include "cogstack-opensearch.snapshotBackupConfigPvcName" .) .Values.opensearch.snapshotBackups.config.existingClaim }}
241+
{{- end }}
233242
{{- if not .Values.opensearch.persistence.enabled }}
234243
- name: data
235244
emptyDir: {}
236245
{{- end }}
246+
{{- if not .Values.opensearch.logPersistence.enabled }}
237247
- name: logs
238248
emptyDir: {}
249+
{{- end }}
250+
{{- if not .Values.opensearch.performanceAnalyzerPersistence.enabled }}
239251
- name: performance-analyzer
240252
emptyDir: {}
253+
{{- end }}
241254
{{- with .Values.opensearch.nodeSelector }}
242255
nodeSelector:
243256
{{- toYaml . | nindent 8 }}
@@ -250,8 +263,9 @@ spec:
250263
tolerations:
251264
{{- toYaml . | nindent 8 }}
252265
{{- end }}
253-
{{- if .Values.opensearch.persistence.enabled }}
266+
{{- if or .Values.opensearch.persistence.enabled .Values.opensearch.logPersistence.enabled .Values.opensearch.performanceAnalyzerPersistence.enabled }}
254267
volumeClaimTemplates:
268+
{{- if .Values.opensearch.persistence.enabled }}
255269
- metadata:
256270
name: data
257271
spec:
@@ -263,5 +277,32 @@ spec:
263277
{{- if .Values.opensearch.persistence.storageClassName }}
264278
storageClassName: {{ .Values.opensearch.persistence.storageClassName | quote }}
265279
{{- end }}
280+
{{- end }}
281+
{{- if .Values.opensearch.logPersistence.enabled }}
282+
- metadata:
283+
name: logs
284+
spec:
285+
accessModes:
286+
{{- toYaml .Values.opensearch.logPersistence.accessModes | nindent 10 }}
287+
resources:
288+
requests:
289+
storage: {{ .Values.opensearch.logPersistence.size }}
290+
{{- if .Values.opensearch.logPersistence.storageClassName }}
291+
storageClassName: {{ .Values.opensearch.logPersistence.storageClassName | quote }}
292+
{{- end }}
293+
{{- end }}
294+
{{- if .Values.opensearch.performanceAnalyzerPersistence.enabled }}
295+
- metadata:
296+
name: performance-analyzer
297+
spec:
298+
accessModes:
299+
{{- toYaml .Values.opensearch.performanceAnalyzerPersistence.accessModes | nindent 10 }}
300+
resources:
301+
requests:
302+
storage: {{ .Values.opensearch.performanceAnalyzerPersistence.size }}
303+
{{- if .Values.opensearch.performanceAnalyzerPersistence.storageClassName }}
304+
storageClassName: {{ .Values.opensearch.performanceAnalyzerPersistence.storageClassName | quote }}
305+
{{- end }}
306+
{{- end }}
266307
{{- end }}
267308
{{- end }}

deploy/charts/opensearch/values.yaml

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,10 @@ envFile:
1515
# Pass deploy/elasticsearch.env via:
1616
# --set-file envFile.raw=./deploy/elasticsearch.env
1717
raw: ""
18-
# Only these keys are imported into a ConfigMap (avoid leaking secrets from env files).
18+
# Only these shared values are read from deploy/elasticsearch.env.
19+
# Kubernetes-specific discovery and publish-host values are generated by the chart.
1920
includeKeys:
20-
- ELASTICSEARCH_NETWORK_HOST
21-
- ELASTICSEARCH_NETWORK_PUBLISH_HOST
2221
- ELASTICSEARCH_CLUSTER_NAME
23-
- ELASTICSEARCH_SEED_HOSTS
24-
- ELASTICSEARCH_INITIAL_CLUSTER_MANAGER_NODES
25-
- ELASTICSEARCH_HOSTS
2622
- ELASTICSEARCH_JAVA_OPTS
2723
- OPENSEARCH_JAVA_OPTS
2824
- KIBANA_SERVER_NAME
@@ -67,6 +63,37 @@ opensearch:
6763
- ReadWriteOnce
6864
size: 20Gi
6965
storageClassName: ""
66+
logPersistence:
67+
enabled: true
68+
accessModes:
69+
- ReadWriteOnce
70+
size: 10Gi
71+
storageClassName: ""
72+
performanceAnalyzerPersistence:
73+
enabled: true
74+
accessModes:
75+
- ReadWriteOnce
76+
size: 1Gi
77+
storageClassName: ""
78+
snapshotBackups:
79+
# Optional parity mounts for Docker's shared backup paths.
80+
# These should use shared storage accessible from all OpenSearch pods.
81+
# Note: OpenSearch will only use these if path.repo is also configured in opensearch.yml.
82+
enabled: false
83+
data:
84+
mountPath: /mnt/es_data_backups
85+
existingClaim: ""
86+
accessModes:
87+
- ReadWriteMany
88+
size: 20Gi
89+
storageClassName: ""
90+
config:
91+
mountPath: /mnt/es_config_backups
92+
existingClaim: ""
93+
accessModes:
94+
- ReadWriteMany
95+
size: 5Gi
96+
storageClassName: ""
7097
service:
7198
type: ClusterIP
7299
httpPort: 9200

docs/deploy/deployment.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ helm upgrade --install cogstack-opensearch ./deploy/charts/opensearch \
9898

9999
> The chart expects pre-created Kubernetes Secrets for TLS materials (see the chart README).
100100
> The `--set-file configFiles.*Raw=...` flags point Helm at the same OpenSearch and Dashboards config files used by Docker Compose.
101-
> The `--set-file envFile.raw=...` flag injects values from `deploy/elasticsearch.env` into pod environment variables.
102-
> The `--set-file usersEnvFile.raw=...` flag feeds credentials (`OPENSEARCH_INITIAL_ADMIN_PASSWORD`, `KIBANA_USER`, `KIBANA_PASSWORD`) into the chart Secret.
101+
> The `--set-file envFile.raw=...` flag lets the chart read shared values from `deploy/elasticsearch.env` while still generating Kubernetes-specific discovery and publish-host settings itself.
102+
> The `--set-file usersEnvFile.raw=...` flag feeds only the credential keys required by the enabled chart components into the chart Secret.
103103
> The `--set-file certificatesEnvFile.raw=...` flag loads certificate metadata from `security/env/certificates_elasticsearch.env` (`ES_CLIENT_CERT_NAME` currently).
104104
> The `--set-file securityFiles.*Raw=...` flags use `security/es_roles/opensearch/*.yml` as the source of OpenSearch security config.
105105

0 commit comments

Comments
 (0)