Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bitnami/opensearch] Enable automated setup of snapshot policies #29796

Merged
merged 24 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
e935d4f
[bitnami/opensearch] Conditionally create PVC for snapshots
lindhe Oct 4, 2024
0bade28
[bitnami/opensearch] Create volumes for snapshots
lindhe Oct 4, 2024
2e41cf6
[bitnami/opensearch] Create snapshots post-install hook
lindhe Oct 4, 2024
c29ade4
[bitnami/opensearch] Bump chart version
lindhe Oct 7, 2024
a137a1f
Merge branch 'main' into lindhe/os-snapshot-init
Oct 7, 2024
1b744f4
Merge branch 'main' into lindhe/os-snapshot-init
lindhe Oct 18, 2024
efedb9d
[bitnami/opensearch] Remove reundant comment in values
lindhe Oct 28, 2024
a65f57c
[bitnami/opensearch] Remove another reundant comment
lindhe Oct 28, 2024
a99b834
Add defaults for documented image values
lindhe Oct 29, 2024
085e9ef
Update CHANGELOG.md
bitnami-bot Oct 29, 2024
c63321a
Update README.md with readme-generator-for-helm
bitnami-bot Oct 29, 2024
125aef8
[bitnami/opensearch] Fix typo in nindent
lindhe Oct 31, 2024
c364a0c
Update CHANGELOG.md
bitnami-bot Oct 31, 2024
6e560e0
[bitnami/opensearch] Add `--show-error` to curl
lindhe Oct 31, 2024
a19c8fb
[bitnami/opensearch] Allow UDP/53 in NetworkPolicy
lindhe Oct 31, 2024
d5054b7
Merge branch 'main' into lindhe/os-snapshot-init
lindhe Nov 7, 2024
0a50c9e
Update CHANGELOG.md
bitnami-bot Nov 7, 2024
b22febf
Add snapshots.image to warnings list
lindhe Nov 7, 2024
5b1e08d
Merge branch 'main' into lindhe/os-snapshot-init
lindhe Nov 13, 2024
3917b13
Update CHANGELOG.md
bitnami-bot Nov 13, 2024
1c80e37
Move `snapshots.enabled` to the top
lindhe Nov 15, 2024
3c85e0c
Move `snapshots.persistence.enabled` to the top
lindhe Nov 15, 2024
7749789
Update CHANGELOG.md
bitnami-bot Nov 15, 2024
d519da7
Update README.md with readme-generator-for-helm
bitnami-bot Nov 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions bitnami/opensearch/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# Changelog

## 1.3.14 (2024-11-08)
## 1.4.0 (2024-11-15)

* [bitnami/opensearch] Unify seLinuxOptions default value ([#30336](https://github.com/bitnami/charts/pull/30336))
* [bitnami/opensearch] Enable automated setup of snapshot policies ([#29796](https://github.com/bitnami/charts/pull/29796))

## <small>1.3.14 (2024-11-08)</small>

* [bitnami/opensearch] Unify seLinuxOptions default value (#30336) ([2b670fc](https://github.com/bitnami/charts/commit/2b670fc5c17e0dd5ddafef2c062c1a474d07eb21)), closes [#30336](https://github.com/bitnami/charts/issues/30336)

## <small>1.3.13 (2024-11-06)</small>

Expand Down
2 changes: 1 addition & 1 deletion bitnami/opensearch/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ maintainers:
name: opensearch
sources:
- https://github.com/bitnami/charts/tree/main/bitnami/opensearch
version: 1.3.14
version: 1.4.0
61 changes: 52 additions & 9 deletions bitnami/opensearch/README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bitnami/opensearch/templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,4 @@ In order to replicate the container startup scripts execute this command:
{{- end }}
{{ include "opensearch.validateValues" . }}
{{- include "common.warnings.resources" (dict "sections" (list "coordinating" "dashboards" "data" "ingest" "master" "sysctlImage" "volumePermissions") "context" $) }}
{{- include "common.warnings.modifiedImages" (dict "images" (list .Values.image .Values.volumePermissions.image .Values.sysctlImage .Values.dashboards.image) "context" $) }}
{{- include "common.warnings.modifiedImages" (dict "images" (list .Values.image .Values.volumePermissions.image .Values.sysctlImage .Values.dashboards.image .Values.snapshots.image) "context" $) }}
41 changes: 41 additions & 0 deletions bitnami/opensearch/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -822,3 +822,44 @@ Return true if a TLS credentials secret object should be created
{{- true -}}
{{- end -}}
{{- end -}}

{{/*
Create a default fully qualified snapshots name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "opensearch.snapshots.fullname" -}}
{{- $name := default "snapshots" .Values.snapshots.nameOverride -}}
{{- if .Values.snapshots.fullnameOverride -}}
{{- .Values.snapshots.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" (include "common.names.fullname" .) $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}

{{/*
Create a global mount path for snapshots volume based on repo path
*/}}
{{- define "opensearch.snapshots.mountPath" -}}
{{- required "Value snapshotRepoPath must be set!" $.Values.snapshotRepoPath -}}
{{- end -}}

{{/*
Create name for snapshot API repo data ConfigMap
*/}}
{{- define "opensearch.snapshots.repoDataConfigMap" -}}
{{- printf "%s-repo-data" (include "opensearch.snapshots.fullname" $) -}}
lindhe marked this conversation as resolved.
Show resolved Hide resolved
{{- end -}}

{{/*
Create name for snapshot API policy data ConfigMap
*/}}
{{- define "opensearch.snapshots.policyDataConfigMap" -}}
{{- printf "%s-policy-data" (include "opensearch.snapshots.fullname" $) -}}
{{- end -}}

{{/*
Return the proper Opensearch Snapshots image name
*/}}
{{- define "opensearch.snapshots.image" -}}
{{ include "common.images.image" (dict "imageRoot" .Values.snapshots.image "global" .Values.global) }}
{{- end -}}
9 changes: 9 additions & 0 deletions bitnami/opensearch/templates/coordinating/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,10 @@ spec:
- name: custom-init-scripts-secret
mountPath: /docker-entrypoint-initdb.d/init-scripts-secret
{{- end }}
{{- if .Values.snapshots.persistence.enabled }}
- name: snapshots
mountPath: {{ include "opensearch.snapshots.mountPath" . }}
{{- end }}
{{- if .Values.coordinating.extraVolumeMounts }}
{{- include "common.tplvalues.render" (dict "value" .Values.coordinating.extraVolumeMounts "context" $) | nindent 12 }}
{{- end }}
Expand Down Expand Up @@ -308,6 +312,11 @@ spec:
secretName: {{ template "opensearch.initScriptsSecret" . }}
defaultMode: 0755
{{- end }}
{{- if .Values.snapshots.persistence.enabled }}
- name: snapshots
persistentVolumeClaim:
claimName: {{ include "opensearch.snapshots.fullname" . }}
{{- end }}
{{- if .Values.coordinating.extraVolumes }}
{{- include "common.tplvalues.render" (dict "value" .Values.coordinating.extraVolumes "context" $) | nindent 8 }}
{{- end }}
Expand Down
9 changes: 9 additions & 0 deletions bitnami/opensearch/templates/data/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,10 @@ spec:
- name: custom-init-scripts-secret
mountPath: /docker-entrypoint-initdb.d/init-scripts-secret
{{- end }}
{{- if .Values.snapshots.persistence.enabled }}
- name: snapshots
mountPath: {{ include "opensearch.snapshots.mountPath" . }}
{{- end }}
{{- if .Values.data.extraVolumeMounts }}
{{- include "common.tplvalues.render" (dict "value" .Values.data.extraVolumeMounts "context" $) | nindent 12 }}
{{- end }}
Expand Down Expand Up @@ -332,6 +336,11 @@ spec:
secretName: {{ template "opensearch.initScriptsSecret" . }}
defaultMode: 0755
{{- end }}
{{- if .Values.snapshots.persistence.enabled }}
- name: snapshots
persistentVolumeClaim:
claimName: {{ include "opensearch.snapshots.fullname" . }}
{{- end }}
{{- if .Values.data.extraVolumes }}
{{- include "common.tplvalues.render" (dict "value" .Values.data.extraVolumes "context" $) | nindent 8 }}
{{- end }}
Expand Down
9 changes: 9 additions & 0 deletions bitnami/opensearch/templates/ingest/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,10 @@ spec:
- name: custom-init-scripts-secret
mountPath: /docker-entrypoint-initdb.d/init-scripts-secret
{{- end }}
{{- if .Values.snapshots.persistence.enabled }}
- name: snapshots
mountPath: {{ include "opensearch.snapshots.mountPath" . }}
{{- end }}
{{- if .Values.ingest.extraVolumeMounts }}
{{- include "common.tplvalues.render" (dict "value" .Values.ingest.extraVolumeMounts "context" $) | nindent 12 }}
{{- end }}
Expand Down Expand Up @@ -308,6 +312,11 @@ spec:
secretName: {{ template "opensearch.initScriptsSecret" . }}
defaultMode: 0755
{{- end }}
{{- if .Values.snapshots.persistence.enabled }}
- name: snapshots
persistentVolumeClaim:
claimName: {{ include "opensearch.snapshots.fullname" . }}
{{- end }}
{{- if .Values.ingest.extraVolumes }}
{{- include "common.tplvalues.render" (dict "value" .Values.ingest.extraVolumes "context" $) | nindent 8 }}
{{- end }}
Expand Down
9 changes: 9 additions & 0 deletions bitnami/opensearch/templates/master/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,10 @@ spec:
- name: custom-init-scripts-secret
mountPath: /docker-entrypoint-initdb.d/init-scripts-secret
{{- end }}
{{- if .Values.snapshots.persistence.enabled }}
- name: snapshots
mountPath: {{ include "opensearch.snapshots.mountPath" . }}
{{- end }}
{{- if .Values.master.extraVolumeMounts }}
{{- include "common.tplvalues.render" (dict "value" .Values.master.extraVolumeMounts "context" $) | nindent 12 }}
{{- end }}
Expand Down Expand Up @@ -344,6 +348,11 @@ spec:
secretName: {{ template "opensearch.initScriptsSecret" . }}
defaultMode: 0755
{{- end }}
{{- if .Values.snapshots.persistence.enabled }}
- name: snapshots
persistentVolumeClaim:
claimName: {{ include "opensearch.snapshots.fullname" . }}
{{- end }}
{{- if .Values.master.extraVolumes }}
{{- include "common.tplvalues.render" (dict "value" .Values.master.extraVolumes "context" $) | nindent 8 }}
{{- end }}
Expand Down
90 changes: 90 additions & 0 deletions bitnami/opensearch/templates/snapshots/init-job.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
{{- /*
Copyright Broadcom, Inc. All Rights Reserved.
SPDX-License-Identifier: APACHE-2.0
*/}}

{{- if $.Values.snapshots.enabled -}}
{{- $host := (include "opensearch.service.name" $) -}}
{{- $port := (include "opensearch.service.ports.restAPI" $) -}}
apiVersion: batch/v1
kind: Job
metadata:
annotations:
helm.sh/hook: post-install
{{- if .Values.commonAnnotations }}
{{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
app.kubernetes.io/component: snapshots
name: {{ include "opensearch.snapshots.fullname" . }}
namespace: {{ include "common.names.namespace" . | quote }}
spec:
template:
spec:
automountServiceAccountToken: false
containers:
- args:
- --silent
- --show-error
- "file:///dev/null" # Starting with curl 8, a URL is required before the first `--next`
{{- range $name, $_ := $.Values.snapshots.repositories }}
# Register snapshot repository:
- --next
- -w
- '\n'
- -XPUT
- -H
- "Content-Type: application/json"
- -d
- "@/run/repo-data/{{ $name }}"
- http://{{ $host }}:{{ $port }}/_snapshot/{{ $name }}
{{- end }}
{{- range $name, $_ := $.Values.snapshots.policies }}
# Register snapshot policy:
- --next
- -w
- '\n'
- -H
- "Content-Type: application/json"
- -d
- "@/run/policy-data/{{ $name }}"
- http://{{ $host }}:{{ $port }}/_plugins/_sm/policies/{{ $name }}
{{- end }}
command: {{- include "common.tplvalues.render" (dict "value" .Values.snapshots.command "context" $) | nindent 12 }}
env:
- name: BITNAMI_DEBUG
value: {{ ternary "true" "false" (or .Values.snapshots.image.debug .Values.diagnosticMode.enabled) | quote }}
image: {{ template "opensearch.snapshots.image" . }}
imagePullPolicy: {{ .Values.snapshots.image.pullPolicy }}
name: {{ include "opensearch.snapshots.fullname" . }}
{{- if .Values.snapshots.containerSecurityContext.enabled }}
securityContext: {{- include "common.compatibility.renderSecurityContext" (dict "secContext" .Values.snapshots.containerSecurityContext "context" $) | nindent 12 }}
{{- end }}
{{- if .Values.snapshots.resources }}
resources: {{- toYaml .Values.snapshots.resources | nindent 12 }}
{{- else if ne .Values.snapshots.resourcesPreset "none" }}
resources: {{- include "common.resources.preset" (dict "type" .Values.snapshots.resourcesPreset) | nindent 12 }}
{{- end }}
volumeMounts:
- name: repo-data
mountPath: /run/repo-data/
- name: policy-data
mountPath: /run/policy-data/
{{- with .Values.snapshots.image.pullSecrets }}
imagePullPolicy:
{{- range . }}
- name: {{ . }}
{{- end }}
{{- end }}
restartPolicy: Never
{{- if .Values.dashboards.podSecurityContext.enabled }}
securityContext: {{- include "common.compatibility.renderSecurityContext" (dict "secContext" .Values.dashboards.podSecurityContext "context" $) | nindent 8 }}
{{- end }}
volumes:
- name: policy-data
configMap:
name: {{ include "opensearch.snapshots.policyDataConfigMap" . }}
- name: repo-data
configMap:
name: {{ include "opensearch.snapshots.repoDataConfigMap" . }}
{{- end -}}
50 changes: 50 additions & 0 deletions bitnami/opensearch/templates/snapshots/networkpolicy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{{- /*
Copyright Broadcom, Inc. All Rights Reserved.
SPDX-License-Identifier: APACHE-2.0
*/}}

{{- if .Values.snapshots.enabled }}
---
apiVersion: {{ include "common.capabilities.networkPolicy.apiVersion" . }}
kind: NetworkPolicy
metadata:
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
app.kubernetes.io/part-of: opensearch
app.kubernetes.io/component: snapshots
name: {{ template "opensearch.snapshots.fullname" . }}
namespace: {{ include "common.names.namespace" . | quote }}
spec:
podSelector:
matchLabels:
batch.kubernetes.io/job-name: {{ template "opensearch.snapshots.fullname" . }}
policyTypes:
- Ingress
- Egress
ingress: []
egress:
- to:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: kube-system
podSelector:
matchLabels:
k8s-app: kube-dns
ports:
- port: 53
protocol: TCP
- port: 53
protocol: UDP
- to:
- podSelector:
matchLabels: {{- include "common.labels.matchLabels" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 14 }}
{{- if (include "opensearch.coordinating.enabled" .) }}
app.kubernetes.io/component: coordinating-only
{{- else }}
app.kubernetes.io/component: master
{{- end }}
ports:
- port: {{ include "opensearch.service.ports.restAPI" $ }}
{{- end }}
27 changes: 27 additions & 0 deletions bitnami/opensearch/templates/snapshots/policies-cm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{{- /*
Copyright Broadcom, Inc. All Rights Reserved.
SPDX-License-Identifier: APACHE-2.0
*/}}

{{- if $.Values.snapshots.enabled -}}
apiVersion: v1
kind: ConfigMap
metadata:
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
app.kubernetes.io/component: snapshots
name: {{ include "opensearch.snapshots.policyDataConfigMap" . }}
namespace: {{ include "common.names.namespace" . | quote }}
data:
{{- range $name, $policy := $.Values.snapshots.policies }}
{{- $repo := $policy.snapshot_config.repository -}}
{{- if (hasKey $.Values.snapshots.repositories $repo) -}}
{{- $name | nindent 2 }}: |
{{- $policy | mustToPrettyJson | nindent 4 }}
{{- else -}}
{{- fail (printf "Repository `%s` is not defined in .snapshots.repositories" $repo) -}}
{{- end -}}
{{- end -}}
{{- end -}}
36 changes: 36 additions & 0 deletions bitnami/opensearch/templates/snapshots/pvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{{- /*
Copyright Broadcom, Inc. All Rights Reserved.
SPDX-License-Identifier: APACHE-2.0
*/}}

{{- if and .Values.snapshots.persistence.enabled (not .Values.snapshots.persistence.existingClaim) -}}
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: {{ include "opensearch.snapshots.fullname" . }}
namespace: {{ include "common.names.namespace" . | quote }}
{{- $labels := include "common.tplvalues.merge" ( dict "values" ( list .Values.commonLabels .Values.snapshots.persistence.labels ) "context" . ) }}
labels: {{- include "common.labels.standard" ( dict "customLabels" $labels "context" $ ) | nindent 4 }}
app.kubernetes.io/component: snapshots
annotations:
helm.sh/resource-policy: keep
{{- if or .Values.snapshots.persistence.annotations .Values.commonAnnotations }}
{{- $annotations := include "common.tplvalues.merge" ( dict "values" ( list .Values.snapshots.persistence.annotations .Values.commonAnnotations ) "context" . ) }}
{{- include "common.tplvalues.render" ( dict "value" $annotations "context" $) | nindent 4 }}
{{- end }}
spec:
accessModes:
{{- range .Values.snapshots.persistence.accessModes }}
- {{ . | quote }}
{{- end }}
resources:
requests:
storage: {{ .Values.snapshots.persistence.size | quote }}
{{- if .Values.snapshots.persistence.selector }}
selector: {{- include "common.tplvalues.render" (dict "value" .Values.snapshots.persistence.selector "context" $) | nindent 4 }}
{{- end }}
{{- if .Values.snapshots.persistence.dataSource }}
dataSource: {{- include "common.tplvalues.render" (dict "value" .Values.snapshots.persistence.dataSource "context" $) | nindent 4 }}
{{- end }}
{{- include "common.storage.class" (dict "persistence" .Values.snapshots.persistence "global" .Values.global) | nindent 2 }}
{{- end -}}
Loading
Loading