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

Allow customization of snapshot agent interval #1235

Merged
merged 5 commits into from
May 25, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ spec:
{{- with .Values.client.snapshotAgent.configSecret }}
"vault.hashicorp.com/agent-inject-secret-snapshot-agent-config.json": "{{ .secretName }}"
"vault.hashicorp.com/agent-inject-template-snapshot-agent-config.json": {{ template "consul.vaultSecretTemplate" . }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
spec:
Expand Down Expand Up @@ -159,6 +159,7 @@ spec:
EOF
{{- end }}
exec /bin/consul snapshot agent \
-interval={{ .Values.client.snapshotAgent.interval }} \
{{- if (and .Values.client.snapshotAgent.configSecret.secretName .Values.client.snapshotAgent.configSecret.secretKey) }}
{{- if .Values.global.secretsBackend.vault.enabled }}
-config-file=/vault/secrets/snapshot-agent-config.json \
Expand Down
21 changes: 21 additions & 0 deletions charts/consul/test/unit/client-snapshot-agent-deployment.bats
Original file line number Diff line number Diff line change
Expand Up @@ -1071,3 +1071,24 @@ MIICFjCCAZsCCQCdwLtdjbzlYzAKBggqhkjOPQQDAjB0MQswCQYDVQQGEwJDQTEL' \
actual=$(echo $object | jq -r '.metadata.annotations["vault.hashicorp.com/role"]' | tee /dev/stderr)
[ "${actual}" = "sa-role" ]
}

@test "client/SnapshotAgentDeployment: interval defaults to 1h" {
cd `chart_dir`
local actual=$(helm template \
-s templates/client-snapshot-agent-deployment.yaml \
--set 'client.snapshotAgent.enabled=true' \
. | tee /dev/stderr |
yq -r '.spec.template.spec.containers[0].command[2] | contains("-interval=1h")' | tee /dev/stderr)
[ "${actual}" = "true" ]
}

@test "client/SnapshotAgentDeployment: interval can be set" {
cd `chart_dir`
local actual=$(helm template \
-s templates/client-snapshot-agent-deployment.yaml \
--set 'client.snapshotAgent.enabled=true' \
--set 'client.snapshotAgent.interval=10h34m5s' \
. | tee /dev/stderr |
yq -r '.spec.template.spec.containers[0].command[2] | contains("-interval=10h34m5s")' | tee /dev/stderr)
[ "${actual}" = "true" ]
}
5 changes: 5 additions & 0 deletions charts/consul/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1296,6 +1296,11 @@ client:
# The number of snapshot agents to run.
replicas: 2

# Interval at which to perform snapshots.
# See https://www.consul.io/commands/snapshot/agent#interval
# @type: string
interval: 1h

# A Kubernetes or Vault secret that should be manually created to contain the entire
# config to be used on the snapshot agent.
# This is the preferred method of configuration since there are usually storage
Expand Down