Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
2 changes: 1 addition & 1 deletion bitnami/etcd/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v1
name: etcd
version: 4.4.14
version: 4.5.0
appVersion: 3.4.3
description: etcd is a distributed key value store that provides a reliable way to store data across a cluster of machines
keywords:
Expand Down
1 change: 1 addition & 0 deletions bitnami/etcd/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ The following tables lists the configurable parameters of the etcd chart and the
| `startFromSnapshot.existingClaim` | PVC containing the existing snapshot | `nil` |
| `startFromSnapshot.snapshotFilename` | Snapshot filename | `nil` |
| `disasterRecovery.enabled` | Enable auto disaster recovery by periodically snapshotting the keyspace | `false` |
| `disasterRecovery.debug` | Enable debug logging for snapshots | `false` |
| `disasterRecovery.cronjob.schedule` | Schedule in Cron format to save snapshots | `*/30 * * * *` |
| `disasterRecovery.cronjob.historyLimit` | Number of successful finished jobs to retain | `1` |
| `disasterRecovery.cronjob.podAnnotations` | Pod annotations for cronjob pods | `{}` |
Expand Down
2 changes: 2 additions & 0 deletions bitnami/etcd/templates/cronjob.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ spec:
command:
- /scripts/save-snapshot.sh
env:
- name: BITNAMI_SNAPSHOT_DEBUG
value: {{ ternary "true" "false" .Values.disasterRecovery.debug | quote }}
- name: ETCDCTL_API
value: "3"
{{- if .Values.auth.client.secureTransport }}
Expand Down
29 changes: 20 additions & 9 deletions bitnami/etcd/templates/scripts-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,9 @@ data:
exec 3>&1
exec 4>&2

if [ "${BITNAMI_DEBUG}" = true ]; then
if [ "${BITNAMI_SNAPSHOT_DEBUG}" = true ]; then

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see why do you need to change this, do you want to enable debug only in the snapshot script?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, @dani8art asked for this in #1922 so I thought I would add it here. :)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case I would allow both env vars:

- if [ "${BITNAMI_SNAPSHOT_DEBUG}" = true ]; then
+ if [ "${BITNAMI_SNAPSHOT_DEBUG}" = true || "${BITNAMI_DEBUG}" = true ]; then

echo "==> Bash debug is on"
set -x
else
echo "==> Bash debug is off"
exec 1>/dev/null
Expand All @@ -257,14 +258,24 @@ data:
AUTH_OPTIONS="{{ $etcdAuthOptions }}"
ETCDCTL_ENDPOINTS="{{range $i, $e := until $replicaCount }}{{ $etcdClientProtocol }}://{{ $etcdFullname }}-{{ $e }}.{{ $etcdHeadlessServiceName }}.{{ $releaseNamespace }}.svc.{{ $clusterDomain }}:{{ $clientPort }},{{ end }}"
# Remove the last comma "," introduced in the string
export ETCDCTL_ENDPOINTS="$(sed 's/,/ /g' <<< $ETCDCTL_ENDPOINTS | awk '{$1=$1};1' | sed 's/ /,/g')"
export ETCDCTL_ENDPOINTS="${ETCDCTL_ENDPOINTS%%,}"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not me, thank @nvtkaszpir!


mkdir -p "/snapshots" 1>&3 2>&4
if etcdctl $AUTH_OPTIONS endpoint health; then
echo "Snapshotting the keyspace..." 1>&3 2>&4
etcdctl $AUTH_OPTIONS snapshot save "/snapshots/db" 1>&3 2>&4
else
echo "Cluster isn't responding!!" 1>&3 2>&4
exit 1
fi

# walk over each node in the list, check if node healthy make snapshot and exit, otherwise try another node
while read -d, ETCDCTL_ENDPOINTS; do
echo "Using endpoint ${ETCDCTL_ENDPOINTS}" 1>&3 2>&4
if etcdctl $AUTH_OPTIONS endpoint health; then
echo "Snapshotting the keyspace..." 1>&3 2>&4
etcdctl $AUTH_OPTIONS snapshot save "/snapshots/db" 1>&3 2>&4
exit 0
else
echo "Warning - etcd endpoint ${ETCDCTL_ENDPOINTS} not healthy" 1>&3 2>&4
echo "Trying another endpoint." 1>&3 2>&4
fi
done <<< "$ETCDCTL_ENDPOINTS"

# exit with error if all endpoints are bad
echo "Error - all etcd endpoints are unhealthy!" 1>&3 2>&4
exit 1
{{- end }}
2 changes: 2 additions & 0 deletions bitnami/etcd/values-production.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,8 @@ startFromSnapshot:
##
disasterRecovery:
enabled: false
## Set to true if you would like to see extra information on logs for snapshotting
debug: false
cronjob:
## Schedule in Cron format to save snapshots
## See https://en.wikipedia.org/wiki/Cron
Expand Down
2 changes: 2 additions & 0 deletions bitnami/etcd/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,8 @@ startFromSnapshot:
##
disasterRecovery:
enabled: false
## Set to true if you would like to see extra information on logs for snapshotting
debug: true
cronjob:
## Schedule in Cron format to save snapshots
## See https://en.wikipedia.org/wiki/Cron
Expand Down