-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[bitnami/opensearch] Enable automated setup of snapshot policies (#29796
) * [bitnami/opensearch] Conditionally create PVC for snapshots I've borrowowed most of the config from the dashboards PVC. Signed-off-by: Andreas Lindhé <[email protected]> * [bitnami/opensearch] Create volumes for snapshots Signed-off-by: Andreas Lindhé <[email protected]> * [bitnami/opensearch] Create snapshots post-install hook This change creates a new job to be run as an optional post-install hook for creating initial snapshot policies in OpenSearch, along with relvant ConfigMaps and NetworkPolicies. I have tried to follow most of Bitnami's conventions for the templates, but it's hard to tell if everything is 100% aligned with best practices. Signed-off-by: Andreas Lindhé <[email protected]> * [bitnami/opensearch] Bump chart version Signed-off-by: Andreas Lindhé <[email protected]> * [bitnami/opensearch] Remove reundant comment in values Co-authored-by: Juan José Martos <[email protected]> Signed-off-by: Andreas Lindhé <[email protected]> * [bitnami/opensearch] Remove another reundant comment Signed-off-by: Andreas Lindhé <[email protected]> * Add defaults for documented image values Co-authored-by: Juan José Martos <[email protected]> Signed-off-by: Andreas Lindhé <[email protected]> * Update CHANGELOG.md Signed-off-by: Bitnami Containers <[email protected]> * Update README.md with readme-generator-for-helm Signed-off-by: Bitnami Containers <[email protected]> * [bitnami/opensearch] Fix typo in nindent Signed-off-by: Andreas Lindhé <[email protected]> * Update CHANGELOG.md Signed-off-by: Bitnami Containers <[email protected]> * [bitnami/opensearch] Add `--show-error` to curl This drastically improves debugging things when `curl` returns errors. Signed-off-by: Andreas Lindhé <[email protected]> * [bitnami/opensearch] Allow UDP/53 in NetworkPolicy Signed-off-by: Andreas Lindhé <[email protected]> * Update CHANGELOG.md Signed-off-by: Bitnami Containers <[email protected]> * Add snapshots.image to warnings list Signed-off-by: Andreas Lindhé <[email protected]> * Update CHANGELOG.md Signed-off-by: Bitnami Containers <[email protected]> * Move `snapshots.enabled` to the top Signed-off-by: Andreas Lindhé <[email protected]> * Move `snapshots.persistence.enabled` to the top Signed-off-by: Andreas Lindhé <[email protected]> * Update CHANGELOG.md Signed-off-by: Bitnami Containers <[email protected]> * Update README.md with readme-generator-for-helm Signed-off-by: Bitnami Containers <[email protected]> --------- Signed-off-by: Andreas Lindhé <[email protected]> Signed-off-by: Carlos Rodríguez Hernández <[email protected]> Signed-off-by: Bitnami Containers <[email protected]> Co-authored-by: Carlos Rodríguez Hernández <[email protected]> Co-authored-by: Juan José Martos <[email protected]> Co-authored-by: Bitnami Containers <[email protected]>
- Loading branch information
1 parent
c9c33f8
commit 39322b9
Showing
15 changed files
with
546 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 -}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 -}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 -}} |
Oops, something went wrong.