mirror of
https://github.com/helm/charts.git
synced 2026-08-23 22:37:45 +00:00
[incubator/cassandra] Add backup CronJob (#7549)
* [incubator/cassandra] Add backup cronjob using cain Signed-off-by: Maor Friedman <maor.friedman@nuvo-group.com> Signed-off-by: Maor <maor.friedman@nuvo-group.com> * [incubator/cassandra] Add backup cronjob disabled Signed-off-by: Maor Friedman <maor.friedman@nuvo-group.com> Signed-off-by: Maor <maor.friedman@nuvo-group.com> * [incubator/cassandra] bump chart version to 0.5.4 Signed-off-by: Maor Friedman <maor.friedman@nuvo-group.com> Signed-off-by: Maor <maor.friedman@nuvo-group.com> * [incubator/cassandra] remove trailing whitespace Signed-off-by: Maor Friedman <maor.friedman@nuvo-group.com> Signed-off-by: Maor <maor.friedman@nuvo-group.com> * remove redundant whitespaces Signed-off-by: Maor <maor.friedman@nuvo-group.com> * remove history section to take defaults Signed-off-by: Maor <maor.friedman@nuvo-group.com> * bump chart version to 0.6.0 Signed-off-by: Maor <maor.friedman@nuvo-group.com> * pin image tag to 0.1.0 Signed-off-by: Maor <maor.friedman@nuvo-group.com> * Add comments for env section Signed-off-by: Maor <maor.friedman@nuvo-group.com> * add rbac conditional creation and custon service account name Signed-off-by: Maor <maor.friedman@nuvo-group.com> * remove empty line Signed-off-by: Maor <maor.friedman@nuvo-group.com> * [incubator/cassandra] backup default to false Signed-off-by: Maor <maor.friedman@nuvo-group.com>
This commit is contained in:
committed by
k8s-ci-robot
parent
f4cf35b5f3
commit
932b79de7e
@@ -1,5 +1,5 @@
|
||||
name: cassandra
|
||||
version: 0.5.3
|
||||
version: 0.6.0
|
||||
appVersion: 3
|
||||
description: Apache Cassandra is a free and open-source distributed database management
|
||||
system designed to handle large amounts of data across many commodity servers, providing
|
||||
|
||||
@@ -115,6 +115,17 @@ The following table lists the configurable parameters of the Cassandra chart and
|
||||
| `readinessProbe.timeoutSeconds` | When the probe times out | `5` |
|
||||
| `readinessProbe.successThreshold` | Minimum consecutive successes for the probe to be considered successful after having failed. | `1` |
|
||||
| `readinessProbe.failureThreshold` | Minimum consecutive failures for the probe to be considered failed after having succeeded. | `3` |
|
||||
| `rbac.create` | Specifies whether RBAC resources should be created | `true` |
|
||||
| `serviceAccount.create` | Specifies whether a ServiceAccount should be created | `false` |
|
||||
| `serviceAccount.name` | The name of the ServiceAccount to use | |
|
||||
| `backup.enabled` | Enable backup on chart installation | `false` |
|
||||
| `backup.schedule` | Keyspaces to backup, each with cron time | |
|
||||
| `backup.annotations` | Backup pod annotations | iam.amazonaws.com/role: `cain` |
|
||||
| `backup.image.repo` | Backup image repository | `maorfr/cain` |
|
||||
| `backup.image.tag` | Backup image tag | `0.1.0` |
|
||||
| `backup.env` | Backup environment variables | AWS_REGION: `us-east-1` |
|
||||
| `backup.resources` | Backup CPU/Memory resource requests/limits | Memory: `1Gi`, CPU: `1` |
|
||||
| `backup.destination` | Destination to store backup artifacts | `s3://bucket/cassandra` |
|
||||
|
||||
## Scale cassandra
|
||||
When you want to change the cluster size of your cassandra, you can use the helm upgrade command.
|
||||
|
||||
@@ -30,3 +30,14 @@ Create chart name and version as used by the chart label.
|
||||
{{- define "cassandra.chart" -}}
|
||||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Create the name of the service account to use
|
||||
*/}}
|
||||
{{- define "cassandra.serviceAccountName" -}}
|
||||
{{- if .Values.serviceAccount.create -}}
|
||||
{{ default (include "cassandra.fullname" .) .Values.serviceAccount.name }}
|
||||
{{- else -}}
|
||||
{{ default "default" .Values.serviceAccount.name }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
{{- if .Values.backup.enabled }}
|
||||
{{- $release := .Release }}
|
||||
{{- $values := .Values }}
|
||||
{{- $backup := $values.backup }}
|
||||
{{- range $index, $schedule := $backup.schedule }}
|
||||
---
|
||||
apiVersion: batch/v1beta1
|
||||
kind: CronJob
|
||||
metadata:
|
||||
name: {{ template "cassandra.fullname" $ }}-backup-{{ $schedule.keyspace }}
|
||||
labels:
|
||||
app: {{ template "cassandra.name" $ }}
|
||||
chart: {{ template "cassandra.chart" $ }}
|
||||
release: "{{ $release.Name }}"
|
||||
heritage: "{{ $release.Service }}"
|
||||
spec:
|
||||
schedule: {{ $schedule.cron | quote }}
|
||||
concurrencyPolicy: Forbid
|
||||
startingDeadlineSeconds: 120
|
||||
jobTemplate:
|
||||
spec:
|
||||
template:
|
||||
metadata:
|
||||
annotations:
|
||||
{{ toYaml $backup.annotations }}
|
||||
spec:
|
||||
restartPolicy: OnFailure
|
||||
serviceAccountName: {{ template "cassandra.fullname" $ }}-backup
|
||||
containers:
|
||||
- name: cassandra-backup
|
||||
image: "{{ $backup.image.repos }}:{{ $backup.image.tag }}"
|
||||
command: ["cain"]
|
||||
args:
|
||||
- backup
|
||||
- --namespace
|
||||
- {{ $release.Namespace }}
|
||||
- --selector
|
||||
- release={{ $release.Name }}
|
||||
- --keyspace
|
||||
- {{ $schedule.keyspace }}
|
||||
- --dst
|
||||
- {{ $backup.destination }}
|
||||
- --parallel
|
||||
- "0"
|
||||
{{- with $backup.env }}
|
||||
env:
|
||||
{{ toYaml . | indent 12 }}
|
||||
{{- end }}
|
||||
{{- with $backup.resources }}
|
||||
resources:
|
||||
{{ toYaml . | indent 14 }}
|
||||
{{- end }}
|
||||
affinity:
|
||||
podAffinity:
|
||||
preferredDuringSchedulingIgnoredDuringExecution:
|
||||
- labelSelector:
|
||||
matchExpressions:
|
||||
- key: app
|
||||
operator: In
|
||||
values:
|
||||
- {{ template "cassandra.fullname" $ }}
|
||||
- key: release
|
||||
operator: In
|
||||
values:
|
||||
- {{ $release.Name }}
|
||||
topologyKey: "kubernetes.io/hostname"
|
||||
{{- with $values.tolerations }}
|
||||
tolerations:
|
||||
{{ toYaml . | indent 10 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,50 @@
|
||||
{{- if .Values.backup.enabled }}
|
||||
{{- if .Values.serviceAccount.create }}
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: {{ template "cassandra.serviceAccountName" . }}
|
||||
labels:
|
||||
app: {{ template "cassandra.name" . }}
|
||||
chart: {{ template "cassandra.chart" . }}
|
||||
release: "{{ .Release.Name }}"
|
||||
heritage: "{{ .Release.Service }}"
|
||||
---
|
||||
{{- end }}
|
||||
{{- if .Values.rbac.create }}
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: Role
|
||||
metadata:
|
||||
name: {{ template "cassandra.fullname" . }}-backup
|
||||
labels:
|
||||
app: {{ template "cassandra.name" . }}
|
||||
chart: {{ template "cassandra.chart" . }}
|
||||
release: "{{ .Release.Name }}"
|
||||
heritage: "{{ .Release.Service }}"
|
||||
rules:
|
||||
- apiGroups: [""]
|
||||
resources: ["pods", "pods/log"]
|
||||
verbs: ["get", "list"]
|
||||
- apiGroups: [""]
|
||||
resources: ["pods/exec"]
|
||||
verbs: ["create"]
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: RoleBinding
|
||||
metadata:
|
||||
name: {{ template "cassandra.fullname" . }}-backup
|
||||
labels:
|
||||
app: {{ template "cassandra.name" . }}
|
||||
chart: {{ template "cassandra.chart" . }}
|
||||
release: "{{ .Release.Name }}"
|
||||
heritage: "{{ .Release.Service }}"
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: Role
|
||||
name: {{ template "cassandra.fullname" . }}-backup
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: {{ template "cassandra.serviceAccountName" . }}
|
||||
namespace: {{ .Release.Namespace }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
@@ -109,3 +109,56 @@ securityContext:
|
||||
## Affinity for pod assignment
|
||||
## Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity
|
||||
affinity: {}
|
||||
|
||||
rbac:
|
||||
# Specifies whether RBAC resources should be created
|
||||
create: true
|
||||
|
||||
serviceAccount:
|
||||
# Specifies whether a ServiceAccount should be created
|
||||
create: true
|
||||
# The name of the ServiceAccount to use.
|
||||
# If not set and create is true, a name is generated using the fullname template
|
||||
# name:
|
||||
|
||||
## Backup cronjob configuration
|
||||
## Ref: https://github.com/maorfr/cain
|
||||
backup:
|
||||
enabled: false
|
||||
|
||||
# Schedule to run jobs. Must be in cron time format
|
||||
# Ref: https://crontab.guru/
|
||||
schedule:
|
||||
- keyspace: keyspace1
|
||||
cron: "0 7 * * *"
|
||||
- keyspace: keyspace2
|
||||
cron: "30 7 * * *"
|
||||
|
||||
annotations:
|
||||
# Example for authorization using kube2iam
|
||||
# Can also be done using environment variables
|
||||
iam.amazonaws.com/role: cain
|
||||
|
||||
image:
|
||||
repos: maorfr/cain
|
||||
tag: 0.1.0
|
||||
|
||||
# Add additional environment variables
|
||||
env:
|
||||
# Example environment variable required for AWS credentials chain
|
||||
- name: AWS_REGION
|
||||
value: us-east-1
|
||||
|
||||
resources:
|
||||
requests:
|
||||
memory: 1Gi
|
||||
cpu: 1
|
||||
limits:
|
||||
memory: 1Gi
|
||||
cpu: 1
|
||||
|
||||
# Destination to store the backup artifacts
|
||||
# Currently only s3 is supported
|
||||
# Additional support can added.
|
||||
# Ref: https://github.com/maorfr/skbn
|
||||
destination: s3://bucket/cassandra
|
||||
|
||||
Reference in New Issue
Block a user