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/etcd] Add pre-upgrade hook #31161

Merged
merged 23 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
fe2ddf2
[bitnami/etcd] Add pre-upgrade hook
pckhoi Dec 26, 2024
aa3cd2e
[bitnami/common] Bump chart version
pckhoi Dec 26, 2024
739317f
Merge branch 'bitnami:main' into main
pckhoi Dec 26, 2024
7c33cea
Update Chart.yaml
Dec 27, 2024
17ed446
Update _capabilities.tpl
Dec 27, 2024
6c55876
Update CHANGELOG.md
bitnami-bot Dec 27, 2024
4fda19c
Merge branch 'bitnami:main' into main
pckhoi Jan 4, 2025
70b56d6
Update CHANGELOG.md
bitnami-bot Jan 4, 2025
8d9c349
[bitnami/etcd] Remove ETCD_ADVERTISE_CLIENT_URLS env var from preupgr…
pckhoi Jan 4, 2025
10399a6
Merge branch 'main' of github.com:pckhoi/charts
pckhoi Jan 4, 2025
ca834ff
[bitnami/etcd] Fix typo in README
pckhoi Jan 4, 2025
9d153ed
[bitnami/etcd] Update dependency
pckhoi Jan 4, 2025
154e2c3
[bitnami/etcd] Remove unused env var from preupgrade hook
pckhoi Jan 14, 2025
d8a04ae
[bitnami/etcd] Added back support for autoTLS
pckhoi Jan 14, 2025
73d8912
Update CHANGELOG.md
bitnami-bot Jan 14, 2025
f4937d3
Merge remote-tracking branch 'bitnami/main'
pckhoi Jan 14, 2025
5117597
Merge branch 'main' of github.com:pckhoi/charts
pckhoi Jan 14, 2025
3a63f49
[bitnami/etcd] Refactor preupgrade hook annotations
pckhoi Jan 16, 2025
a5a6dea
Update CHANGELOG.md
bitnami-bot Jan 16, 2025
67410ef
Merge remote-tracking branch 'bitnami/main'
pckhoi Jan 20, 2025
20a9c40
Update CHANGELOG.md
bitnami-bot Jan 20, 2025
c88f243
[bitnami/etcd] Update image tag
pckhoi Jan 20, 2025
dd7bdc6
Merge branch 'main' of github.com:pckhoi/charts
pckhoi Jan 20, 2025
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/etcd/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# Changelog

## 10.7.3 (2025-01-17)
## 11.0.0 (2025-01-20)

* [bitnami/etcd] Release 10.7.3 ([#31419](https://github.com/bitnami/charts/pull/31419))
* [bitnami/etcd] Add pre-upgrade hook ([#31161](https://github.com/bitnami/charts/pull/31161))

## <small>10.7.3 (2025-01-17)</small>

* [bitnami/etcd] Release 10.7.3 (#31419) ([7ef8d56](https://github.com/bitnami/charts/commit/7ef8d562ec9953460d675b02cfbce336ab66bceb)), closes [#31419](https://github.com/bitnami/charts/issues/31419)

## <small>10.7.2 (2025-01-12)</small>

Expand Down
4 changes: 2 additions & 2 deletions bitnami/etcd/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ annotations:
licenses: Apache-2.0
images: |
- name: etcd
image: docker.io/bitnami/etcd:3.5.17-debian-12-r3
image: docker.io/bitnami/etcd:3.5.17-debian-12-r4
- name: os-shell
image: docker.io/bitnami/os-shell:12-debian-12-r35
apiVersion: v2
Expand All @@ -32,4 +32,4 @@ maintainers:
name: etcd
sources:
- https://github.com/bitnami/charts/tree/main/bitnami/etcd
version: 10.7.3
version: 11.0.0
11 changes: 8 additions & 3 deletions bitnami/etcd/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ Here is an example of the environment configuration bootstrapping an etcd cluste
| 2 | ETCD_NAME | etcd-2 |
| 2 | ETCD_INITIAL_ADVERTISE_PEER_URLS | <http://etcd-2.etcd-headless.default.svc.cluster.local:2380> |
|---------|----------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| * | ETCD_INITIAL_CLUSTER_STATE | new |
| * | ETCD_INITIAL_CLUSTER_TOKEN | etcd-cluster-k8s |
| * | ETCD_INITIAL_CLUSTER | etcd-0=<http://etcd-0.etcd-headless.default.svc.cluster.local:2380>,etcd-1=<http://etcd-1.etcd-headless.default.svc.cluster.local:2380>,etcd-2=<http://etcd-2.etcd-headless.default.svc.cluster.local:2380> |

Expand Down Expand Up @@ -405,11 +404,9 @@ If you encounter errors when working with persistent volumes, refer to our [trou
| `auth.peer.caFilename` | Name of the file containing the peer CA certificate | `""` |
| `autoCompactionMode` | Auto compaction mode, by default periodic. Valid values: "periodic", "revision". | `""` |
| `autoCompactionRetention` | Auto compaction retention for mvcc key value store in hour, by default 0, means disabled | `""` |
| `initialClusterState` | Initial cluster state. Allowed values: 'new' or 'existing' | `""` |
| `initialClusterToken` | Initial cluster token. Can be used to protect etcd from cross-cluster-interaction, which might corrupt the clusters. | `etcd-cluster-k8s` |
| `logLevel` | Sets the log level for the etcd process. Allowed values: 'debug', 'info', 'warn', 'error', 'panic', 'fatal' | `info` |
| `maxProcs` | Limits the number of operating system threads that can execute user-level | `""` |
| `removeMemberOnContainerTermination` | Use a PreStop hook to remove the etcd members from the etcd cluster on container termination | `true` |
| `configuration` | etcd configuration. Specify content for etcd.conf.yml | `""` |
| `existingConfigmap` | Existing ConfigMap with etcd configuration | `""` |
| `extraEnvVars` | Extra environment variables to be set on etcd container | `[]` |
Expand Down Expand Up @@ -704,6 +701,14 @@ Find more information about how to deal with common errors related to Bitnami's

## Upgrading

### To 11.0.0

This version introduces the following breaking changes:

- Remove `initialClusterState` which was unreliable at detecting cluster state. From now on, each node will contact other members to determine cluster state. If no members are available and the data dir is empty, then it bootstraps a new cluster.
- Remove `removeMemberOnContainerTermination` which was unreliable at removing stale members during replica count updates. Instead, a pre-upgrade hook is added to check and remove stale members.
juan131 marked this conversation as resolved.
Show resolved Hide resolved
- Remove support for manual scaling with `kubectl` or autoscaler. Upgrading of any kind including increasing replica count must be done with `helm upgrade` exclusively. CD automation tools that respect Helm hooks such as ArgoCD can also be used.

### To 10.7.0

This version introduces image verification for security purposes. To disable it, set `global.security.allowInsecureImages` to `true`. More details at [GitHub issue](https://github.com/bitnami/charts/issues/30850).
Expand Down
173 changes: 173 additions & 0 deletions bitnami/etcd/templates/preupgrade-hook-job.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
{{- /*
Copyright Broadcom, Inc. All Rights Reserved.
SPDX-License-Identifier: APACHE-2.0
*/}}
apiVersion: {{ include "common.capabilities.job.apiVersion" . }}
kind: Job
metadata:
name: {{ include "common.names.fullname" . }}-pre-upgrade
namespace: {{ .Release.Namespace | quote }}
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
app.kubernetes.io/component: etcd-pre-upgrade-job
{{- $defaultAnnotations := dict "helm.sh/hook" "pre-upgrade" "helm.sh/hook-delete-policy" "before-hook-creation" }}
{{- $annotations := include "common.tplvalues.merge" ( dict "values" ( list .Values.commonAnnotations $defaultAnnotations ) "context" . ) }}
annotations: {{- include "common.tplvalues.render" ( dict "value" $annotations "context" $ ) | nindent 4 }}
spec:
{{- $podLabels := include "common.tplvalues.merge" ( dict "values" ( list .Values.podLabels .Values.commonLabels ) "context" . ) }}
template:
metadata:
labels: {{- include "common.labels.standard" ( dict "customLabels" $podLabels "context" $ ) | nindent 8 }}
app.kubernetes.io/component: etcd-pre-upgrade-job
annotations:
{{- if .Values.podAnnotations }}
{{- include "common.tplvalues.render" ( dict "value" .Values.podAnnotations "context" $) | nindent 8 }}
{{- end }}
{{- if (include "etcd.createConfigmap" .) }}
checksum/configuration: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
{{- end }}
{{- if (include "etcd.token.createSecret" .) }}
checksum/token-secret: {{ include (print $.Template.BasePath "/token-secrets.yaml") . | sha256sum }}
{{- end }}
spec:
{{- include "etcd.imagePullSecrets" . | nindent 6 }}
automountServiceAccountToken: {{ .Values.automountServiceAccountToken }}
{{- if .Values.affinity }}
affinity: {{- include "common.tplvalues.render" (dict "value" .Values.affinity "context" $) | nindent 8 }}
{{- else }}
affinity:
podAffinity: {{- include "common.affinities.pods" (dict "type" .Values.podAffinityPreset "component" "etcd-pre-upgrade-job" "customLabels" $podLabels "context" $) | nindent 10 }}
podAntiAffinity: {{- include "common.affinities.pods" (dict "type" .Values.podAntiAffinityPreset "component" "etcd-pre-upgrade-job" "customLabels" $podLabels "context" $) | nindent 10 }}
nodeAffinity: {{- include "common.affinities.nodes" (dict "type" .Values.nodeAffinityPreset.type "key" .Values.nodeAffinityPreset.key "values" .Values.nodeAffinityPreset.values) | nindent 10 }}
{{- end }}
{{- if .Values.nodeSelector }}
nodeSelector: {{- include "common.tplvalues.render" (dict "value" .Values.nodeSelector "context" $) | nindent 8 }}
{{- end }}
{{- if .Values.tolerations }}
tolerations: {{- include "common.tplvalues.render" (dict "value" .Values.tolerations "context" $) | nindent 8 }}
{{- end }}
{{- if .Values.terminationGracePeriodSeconds }}
terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }}
{{- end }}
{{- if .Values.schedulerName }}
schedulerName: {{ .Values.schedulerName }}
{{- end }}
{{- if .Values.topologySpreadConstraints }}
topologySpreadConstraints: {{- include "common.tplvalues.render" (dict "value" .Values.topologySpreadConstraints "context" .) | nindent 8 }}
{{- end }}
restartPolicy: Never
containers:
{{- $replicaCount := int .Values.replicaCount }}
{{- $peerPort := int .Values.containerPorts.peer }}
{{- $etcdFullname := include "common.names.fullname" . }}
{{- $releaseNamespace := .Release.Namespace }}
{{- $etcdHeadlessServiceName := (printf "%s-%s" $etcdFullname "headless" | trunc 63 | trimSuffix "-") }}
{{- $clusterDomain := .Values.clusterDomain }}
{{- $etcdPeerProtocol := include "etcd.peerProtocol" . }}
- name: pre-upgrade-job
image: {{ include "etcd.image" . }}
imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
{{- if .Values.containerSecurityContext.enabled }}
securityContext: {{- include "common.compatibility.renderSecurityContext" (dict "secContext" .Values.containerSecurityContext "context" $) | nindent 12 }}
{{- end }}
command: [ "/opt/bitnami/scripts/etcd/entrypoint.sh" ]
args: [ "/opt/bitnami/scripts/etcd/preupgrade.sh" ]
env:
- name: BITNAMI_DEBUG
value: {{ ternary "true" "false" (or .Values.image.debug .Values.diagnosticMode.enabled) | quote }}
- name: ETCD_ON_K8S
value: "yes"
- name: ETCD_DATA_DIR
value: "/bitnami/etcd/data"
{{- if or .Values.auth.rbac.create .Values.auth.rbac.enabled }}
- name: ETCD_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "etcd.secretName" . }}
key: {{ include "etcd.secretPasswordKey" . }}
{{- end }}
{{- if gt $replicaCount 1 }}
{{- $initialCluster := list }}
{{- range $e, $i := until $replicaCount }}
{{- $initialCluster = append $initialCluster (printf "%s-%d=%s://%s-%d.%s.%s.svc.%s:%d" $etcdFullname $i $etcdPeerProtocol $etcdFullname $i $etcdHeadlessServiceName $releaseNamespace $clusterDomain $peerPort) }}
{{- end }}
- name: ETCD_INITIAL_CLUSTER
value: {{ join "," $initialCluster | quote }}
{{- end }}
{{- if and .Values.auth.client.secureTransport .Values.auth.client.useAutoTLS }}
- name: ETCD_AUTO_TLS
value: "true"
{{- else if .Values.auth.client.secureTransport }}
- name: ETCD_CERT_FILE
value: "/opt/bitnami/etcd/certs/client/{{ .Values.auth.client.certFilename }}"
- name: ETCD_KEY_FILE
value: "/opt/bitnami/etcd/certs/client/{{ .Values.auth.client.certKeyFilename }}"
{{- if .Values.auth.client.enableAuthentication }}
- name: ETCD_CLIENT_CERT_AUTH
value: "true"
- name: ETCD_TRUSTED_CA_FILE
value: "/opt/bitnami/etcd/certs/client/{{ .Values.auth.client.caFilename | default "ca.crt" }}"
{{- else if .Values.auth.client.caFilename }}
- name: ETCD_TRUSTED_CA_FILE
value: "/opt/bitnami/etcd/certs/client/{{ .Values.auth.client.caFilename | default "ca.crt" }}"
{{- end }}
{{- end }}
{{- if .Values.extraEnvVars }}
{{- include "common.tplvalues.render" (dict "value" .Values.extraEnvVars "context" $) | nindent 12 }}
{{- end }}
envFrom:
{{- if .Values.extraEnvVarsCM }}
- configMapRef:
name: {{ include "common.tplvalues.render" (dict "value" .Values.extraEnvVarsCM "context" $) }}
{{- end }}
{{- if .Values.extraEnvVarsSecret }}
- secretRef:
name: {{ include "common.tplvalues.render" (dict "value" .Values.extraEnvVarsSecret "context" $) }}
{{- end }}
volumeMounts:
{{- if or .Values.configuration .Values.existingConfigmap }}
- name: configuration
mountPath: /opt/bitnami/etcd/conf/
{{- else }}
- name: empty-dir
mountPath: /opt/bitnami/etcd/conf/
subPath: app-conf-dir
{{- end }}
- name: empty-dir
mountPath: /tmp
subPath: tmp-dir
{{- if and (eq .Values.auth.token.enabled true) (eq .Values.auth.token.type "jwt") }}
- name: etcd-jwt-token
mountPath: /opt/bitnami/etcd/certs/token/
readOnly: true
{{- end }}
{{- if or .Values.auth.client.enableAuthentication (and .Values.auth.client.secureTransport (not .Values.auth.client.useAutoTLS )) }}
- name: etcd-client-certs
mountPath: /opt/bitnami/etcd/certs/client/
readOnly: true
{{- end }}
{{- if .Values.extraVolumeMounts }}
{{- include "common.tplvalues.render" (dict "value" .Values.extraVolumeMounts "context" $) | nindent 12 }}
{{- end }}
volumes:
- name: empty-dir
emptyDir: {}
{{- if or .Values.configuration .Values.existingConfigmap }}
- name: configuration
configMap:
name: {{ include "etcd.configmapName" . }}
{{- end }}
{{- if and (eq .Values.auth.token.enabled true) (eq .Values.auth.token.type "jwt") }}
- name: etcd-jwt-token
secret:
secretName: {{ include "etcd.token.secretName" . }}
defaultMode: 256
{{- end }}
{{- if or .Values.auth.client.enableAuthentication (and .Values.auth.client.secureTransport (not .Values.auth.client.useAutoTLS )) }}
- name: etcd-client-certs
secret:
secretName: {{ required "A secret containing the client certificates is required" (tpl .Values.auth.client.existingSecret .) }}
defaultMode: 256
{{- end }}
{{- if .Values.extraVolumes }}
{{- include "common.tplvalues.render" (dict "value" .Values.extraVolumes "context" $) | nindent 8 }}
{{- end }}
8 changes: 0 additions & 8 deletions bitnami/etcd/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,6 @@ spec:
{{- if gt $replicaCount 1 }}
- name: ETCD_INITIAL_CLUSTER_TOKEN
value: {{ .Values.initialClusterToken | quote }}
- name: ETCD_INITIAL_CLUSTER_STATE
value: {{ default (ternary "new" "existing" .Release.IsInstall) .Values.initialClusterState | quote }}
{{- $initialCluster := list }}
{{- range $e, $i := until $replicaCount }}
{{- $initialCluster = append $initialCluster (printf "%s-%d=%s://%s-%d.%s.%s.svc.%s:%d" $etcdFullname $i $etcdPeerProtocol $etcdFullname $i $etcdHeadlessServiceName $releaseNamespace $clusterDomain $peerPort) }}
Expand Down Expand Up @@ -326,12 +324,6 @@ spec:
{{- end }}
{{- if .Values.lifecycleHooks }}
lifecycle: {{- include "common.tplvalues.render" (dict "value" .Values.lifecycleHooks "context" $) | nindent 12 }}
{{- else if and (gt $replicaCount 1) .Values.removeMemberOnContainerTermination }}
lifecycle:
preStop:
exec:
command:
- /opt/bitnami/scripts/etcd/prestop.sh
{{- end }}
{{- end }}
{{- if .Values.resources }}
Expand Down
13 changes: 1 addition & 12 deletions bitnami/etcd/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ diagnosticMode:
image:
registry: docker.io
repository: bitnami/etcd
tag: 3.5.17-debian-12-r3
tag: 3.5.17-debian-12-r4
digest: ""
## @param image.pullPolicy etcd image pull policy
## Specify a imagePullPolicy
Expand Down Expand Up @@ -215,12 +215,6 @@ autoCompactionMode: ""
## @param autoCompactionRetention Auto compaction retention for mvcc key value store in hour, by default 0, means disabled
##
autoCompactionRetention: ""
## @param initialClusterState Initial cluster state. Allowed values: 'new' or 'existing'
## If this values is not set, the default values below are set:
## - 'new': when installing the chart ('helm install ...')
## - 'existing': when upgrading the chart ('helm upgrade ...')
##
initialClusterState: ""
## @param initialClusterToken Initial cluster token. Can be used to protect etcd from cross-cluster-interaction, which might corrupt the clusters.
## If spinning up multiple clusters (or creating and destroying a single cluster)
## with same configuration for testing purpose, it is highly recommended that each cluster is given a unique initial-cluster-token.
Expand All @@ -235,11 +229,6 @@ logLevel: "info"
## ref: https://golang.org/pkg/runtime
##
maxProcs: ""
## @param removeMemberOnContainerTermination Use a PreStop hook to remove the etcd members from the etcd cluster on container termination
## they the containers are terminated. Set to 'false' if appears an error-related member ID wasn't properly stored.
## NOTE: Ignored if lifecycleHooks is set or replicaCount=1
##
removeMemberOnContainerTermination: true
## @param configuration etcd configuration. Specify content for etcd.conf.yml
## e.g:
## configuration: |-
Expand Down
Loading