diff --git a/helm/kamaji/README.md b/helm/kamaji/README.md index 8ba382c..7790486 100644 --- a/helm/kamaji/README.md +++ b/helm/kamaji/README.md @@ -76,10 +76,12 @@ Here the values you can override: | etcd.overrides.caSecret.namespace | string | `"kamaji-system"` | Namespace of the secret which contains CA's certificate and private key. (default: "kamaji-system") | | etcd.overrides.clientSecret.name | string | `"root-client-certs"` | Name of the secret which contains ETCD client certificates. (default: "root-client-certs") | | etcd.overrides.clientSecret.namespace | string | `"kamaji-system"` | Name of the namespace where the secret which contains ETCD client certificates is. (default: "kamaji-system") | -| etcd.overrides.endpoints | string | `"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"` | (string) Comma-separated list of the endpoints of the etcd cluster's members. | +| etcd.overrides.endpoints | object | `{"etcd-0":"https://etcd-0.etcd.kamaji-system.svc.cluster.local","etcd-1":"https://etcd-1.etcd.kamaji-system.svc.cluster.local","etcd-2":"https://etcd-2.etcd.kamaji-system.svc.cluster.local"}` | (map) Dictionary of the endpoints for the etcd cluster's members, key is the name of the etcd server. Don't define any port, inflected from .etcd.peerApiPort value. | +| etcd.peerApiPort | int | `2380` | The peer API port which servers are listening to. | | etcd.persistence.accessModes[0] | string | `"ReadWriteOnce"` | | | etcd.persistence.size | string | `"10Gi"` | | | etcd.persistence.storageClass | string | `""` | | +| etcd.port | int | `2379` | The client request port. | | etcd.serviceAccount.create | bool | `true` | Create a ServiceAccount, required to install and provision the etcd backing storage (default: true) | | etcd.serviceAccount.name | string | `""` | Define the ServiceAccount name to use during the setup and provision of the etcd backing storage (default: "") | | extraArgs | list | `[]` | A list of extra arguments to add to the kamaji controller default ones | diff --git a/helm/kamaji/templates/_helpers_etcd.tpl b/helm/kamaji/templates/_helpers_etcd.tpl index 91af2cd..2ff98b2 100644 --- a/helm/kamaji/templates/_helpers_etcd.tpl +++ b/helm/kamaji/templates/_helpers_etcd.tpl @@ -93,19 +93,41 @@ Namespace of the etcd root-client secret. {{- end }} {{/* -List the declared etcd endpoints, using the overrides in case of unmanaged etcd. +Comma separated list of 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 $count := until 3 -}} + {{- $list = append $list (printf "https://%s-%d.%s.%s.svc.cluster.local:%d" "etcd" $count ( include "etcd.serviceName" . ) $.Release.Namespace (int $.Values.etcd.port) ) -}} + {{- end }} +{{- else if .Values.etcd.overrides.endpoints }} + {{- range $v := .Values.etcd.overrides.endpoints -}} + {{- $list = append $list (printf "%s:%d" $v (int $.Values.etcd.peerApiPort) ) -}} {{- 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 }} +{{- join "," $list -}} {{- end }} + +{{/* +Key-value of the etcd peers, using the overrides in case of unmanaged etcd. +*/}} +{{- define "etcd.initialCluster" }} +{{- $list := list -}} +{{- if .Values.etcd.deploy }} + {{- range $i, $count := until 3 -}} + {{- $list = append $list ( printf "etcd-%d=https://%s-%d.%s.%s.svc.cluster.local:%d" $i "etcd" $count ( include "etcd.serviceName" . ) $.Release.Namespace (int $.Values.etcd.peerApiPort) ) -}} + {{- end }} +{{- else if .Values.etcd.overrides.endpoints }} + {{- range $k, $v := .Values.etcd.overrides.endpoints -}} + {{- $list = append $list ( printf "%s=%s:%d" $k $v (int $.Values.etcd.peerApiPort) ) -}} + {{- end -}} +{{- else if not .Values.etcd.overrides.endpoints }} + {{- fail "A valid .Values.etcd.overrides.endpoints required!" }} +{{- end }} +{{- join "," $list -}} {{- end }} {{/* diff --git a/helm/kamaji/templates/etcd_service.yaml b/helm/kamaji/templates/etcd_service.yaml index b0f5fe2..9634242 100644 --- a/helm/kamaji/templates/etcd_service.yaml +++ b/helm/kamaji/templates/etcd_service.yaml @@ -9,9 +9,9 @@ metadata: spec: clusterIP: None ports: - - port: 2379 + - port: {{ .Values.etcd.port }} name: client - - port: 2380 + - port: {{ .Values.etcd.peerApiPort }} name: peer selector: {{- include "etcd.selectorLabels" . | nindent 4 }} diff --git a/helm/kamaji/templates/etcd_sts.yaml b/helm/kamaji/templates/etcd_sts.yaml index fcfd136..42bfbed 100644 --- a/helm/kamaji/templates/etcd_sts.yaml +++ b/helm/kamaji/templates/etcd_sts.yaml @@ -41,7 +41,7 @@ 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.initialCluster" . }} - --initial-advertise-peer-urls=https://$(POD_NAME).etcd.$(POD_NAMESPACE).svc.cluster.local:2380 - --advertise-client-urls=https://$(POD_NAME).etcd.$(POD_NAMESPACE).svc.cluster.local:2379 - --initial-cluster-token=kamaji diff --git a/helm/kamaji/values.yaml b/helm/kamaji/values.yaml index 5e4d01f..d3b49aa 100644 --- a/helm/kamaji/values.yaml +++ b/helm/kamaji/values.yaml @@ -22,6 +22,12 @@ etcd: # -- Install an etcd with enabled multi-tenancy along with Kamaji deploy: true + # -- The peer API port which servers are listening to. + peerApiPort: 2380 + + # -- The client request port. + port: 2379 + # -- Install specific etcd image image: repository: quay.io/coreos/etcd @@ -61,8 +67,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. Don't define any port, inflected from .etcd.peerApiPort value. + endpoints: + etcd-0: https://etcd-0.etcd.kamaji-system.svc.cluster.local + etcd-1: https://etcd-1.etcd.kamaji-system.svc.cluster.local + etcd-2: https://etcd-2.etcd.kamaji-system.svc.cluster.local # -- ETCD Compaction interval (e.g. "5m0s"). (default: "0" (disabled)) compactionInterval: 0