Skip to content

Commit

Permalink
fix(helm): etcd initial-cluster value was hard-coded
Browse files Browse the repository at this point in the history
  • Loading branch information
prometherion committed Aug 12, 2022
1 parent d1871cf commit 44274b9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
17 changes: 10 additions & 7 deletions helm/kamaji/templates/_helpers_etcd.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,19 @@ Namespace of the etcd root-client secret.
List the declared etcd endpoints, using the overrides in case of unmanaged etcd.
*/}}
{{- define "etcd.endpoints" }}
{{- $list := list -}}
{{- if .Values.etcd.deploy }}
{{- range $count := until 3 -}}
{{- printf "https://%s-%d.%s.%s.svc.cluster.local:2379" "etcd" $count ( include "etcd.serviceName" . ) $.Release.Namespace -}}
{{- if lt $count ( sub 3 1 ) -}}
{{- printf "," -}}
{{- range $i, $count := until 3 -}}
{{- $list = append $list (printf "etcd-%d=https://%s-%d.%s.%s.svc.cluster.local:2379" $i "etcd" $count ( include "etcd.serviceName" . ) $.Release.Namespace) -}}
{{- end }}
{{- else if .Values.etcd.overrides.endpoints }}
{{- range $k, $v := .Values.etcd.overrides.endpoints -}}
{{- $list = append $list (printf "%s=%s" $k $v) -}}
{{- end -}}
{{- else if not .Values.etcd.overrides.endpoints }}
{{- fail "A valid .Values.etcd.overrides.endpoints required!" }}
{{- end }}
{{- else }}
{{- required "A valid .Values.etcd.overrides.endpoints required!" .Values.etcd.overrides.endpoints }}
{{- end }}
{{- join "," $list -}}
{{- end }}

{{/*
Expand Down
4 changes: 2 additions & 2 deletions helm/kamaji/templates/etcd_sts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ spec:
- --data-dir=/var/run/etcd
- --name=$(POD_NAME)
- --initial-cluster-state=new
- --initial-cluster=etcd-0=https://etcd-0.etcd.$(POD_NAMESPACE).svc.cluster.local:2380,etcd-1=https://etcd-1.etcd.$(POD_NAMESPACE).svc.cluster.local:2380,etcd-2=https://etcd-2.etcd.$(POD_NAMESPACE).svc.cluster.local:2380
- --initial-cluster={{ include "etcd.endpoints" . }}
- --initial-advertise-peer-urls=https://$(POD_NAME).etcd.$(POD_NAMESPACE).svc.cluster.local:2380
- --initial-cluster-token=kamaji
- --listen-client-urls=https://0.0.0.0:2379
- --advertise-client-urls={{ include "etcd.endpoints" . }}
- --advertise-client-urls=https://$(POD_NAME).etcd.$(POD_NAMESPACE).svc.cluster.local:2379
- --client-cert-auth=true
- --trusted-ca-file=/etc/etcd/pki/ca.crt
- --cert-file=/etc/etcd/pki/server.pem
Expand Down
7 changes: 5 additions & 2 deletions helm/kamaji/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ etcd:
name: root-client-certs
# -- Name of the namespace where the secret which contains ETCD client certificates is. (default: "kamaji-system")
namespace: kamaji-system
# -- (string) Comma-separated list of the endpoints of the etcd cluster's members.
endpoints: "https://etcd-0.etcd.kamaji-system.svc.cluster.local:2379,https://etcd-1.etcd.kamaji-system.svc.cluster.local:2379,https://etcd-2.etcd.kamaji-system.svc.cluster.local:2379"
# -- (map) Dictionary of the endpoints for the etcd cluster's members, key is the name of the etcd server
endpoints:
etcd-0: https://etcd-0.etcd.kamaji-system.svc.cluster.local:2379
etcd-1: https://etcd-1.etcd.kamaji-system.svc.cluster.local:2379
etcd-2: https://etcd-2.etcd.kamaji-system.svc.cluster.local:2379
# -- ETCD Compaction interval (e.g. "5m0s"). (default: "0" (disabled))
compactionInterval: 0

Expand Down

0 comments on commit 44274b9

Please sign in to comment.