From ce32b0dac7e88db0d26289b44d85c8a71a3dbe04 Mon Sep 17 00:00:00 2001 From: "Javier J. Salmeron Garcia" Date: Mon, 4 Mar 2019 12:01:06 +0100 Subject: [PATCH 1/3] [bitnami/etcd] Allow custom configuration via file or env vars --- bitnami/etcd/Chart.yaml | 2 +- bitnami/etcd/README.md | 34 +++++++- bitnami/etcd/templates/_helpers.tpl | 14 +++ bitnami/etcd/templates/configmap.yaml | 108 ------------------------ bitnami/etcd/templates/statefulset.yaml | 11 ++- bitnami/etcd/values-production.yaml | 9 +- bitnami/etcd/values.yaml | 9 +- 7 files changed, 68 insertions(+), 119 deletions(-) delete mode 100644 bitnami/etcd/templates/configmap.yaml diff --git a/bitnami/etcd/Chart.yaml b/bitnami/etcd/Chart.yaml index 48f0f2326..d75f7a6db 100644 --- a/bitnami/etcd/Chart.yaml +++ b/bitnami/etcd/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v1 name: etcd -version: 1.5.6 +version: 2.0.0 appVersion: 3.3.12 description: etcd is a distributed key value store that provides a reliable way to store data across a cluster of machines keywords: diff --git a/bitnami/etcd/README.md b/bitnami/etcd/README.md index d4816acbf..97a8581c9 100644 --- a/bitnami/etcd/README.md +++ b/bitnami/etcd/README.md @@ -58,7 +58,8 @@ The following tables lists the configurable parameters of the etcd chart and the | `statefulset.rollingUpdatePartition` | Partition for Rolling Update strategy | `nil` | | `statefulset.podManagementPolicy` | Pod management policy for the stateful set | `OrderedReady` | | `statefulset.replicaCount` | Number of etcd nodes | `1` | -| `useConfigmap` | Switch to use the config map for etcd | `false` | +| `configFileConfigMap` | ConfigMap that contains a etcd.conf.yaml to be mounted | `` | +| `envVarsConfigMap` | ConfigMap that contains environment variables to be set in the container | `` | | `allowNoneAuthentication` | Allow to use etcd without configuring RBAC authentication | `true` | | `auth.rbac.enabled` | Switch to enable the etcd authentication. | `true` | | `auth.rbac.rootPassword` | Password for the root user | `nil` | @@ -125,6 +126,37 @@ $ helm install --name my-release -f values.yaml bitnami/etcd > **Tip**: You can use the default [values.yaml](values.yaml) +### Using custom configuration + +In order to use custom configuration parameters, two options are available: + + - Using environment variables: etcd allows setting environment variables that map to configuration settings. In order to set extra environment variables, use the `envVarsConfigMap` value to point to a ConfigMap that contains them. Example: + +```console +$ cat << EOF > /tmp/configurationEnvVars.yaml +apiVersion: v1 +kind: ConfigMap +metadata: + name: etcd-env-vars + namespace: default +data: + ETCD_AUTO_COMPACTION_RETENTION: "0" + ETCD_HEARTBEAT_INTERVAL: "150" +EOF + +$ kubectl create -f /tmp/configurationEnvVars.yaml + +$ helm install bitnami/etcd --set envVarsConfigMap=etcd-env-vars +``` + + - Using a custom etcd.conf.yml: The etcd chart allows mounting a custom etcd.conf.yml file using the `configFileConfigMap` value. Example: + +```console +$ kubectl create configmap etcd-conf --from-file=etcd.conf.yml + +$ helm install bitnami/etcd --set configFileConfigMap=etcd-conf +``` + ## Production and horizontal scaling The following repo contains the recommended production settings for etcd server in an alternative [values file](values-production.yaml). Please read carefully the comments in the values-production.yaml file to set up your environment. diff --git a/bitnami/etcd/templates/_helpers.tpl b/bitnami/etcd/templates/_helpers.tpl index 7477526cb..a632d6188 100644 --- a/bitnami/etcd/templates/_helpers.tpl +++ b/bitnami/etcd/templates/_helpers.tpl @@ -95,3 +95,17 @@ Return the proper etcdctl authentication options {{- printf "%s" $caOption -}} {{- end -}} {{- end -}} + +{{/* +Return the etcd env vars ConfigMap name +*/}} +{{- define "etcd.envVarsCM" -}} +{{- printf "%s" .Values.envVarsConfigMap -}} +{{- end -}} + +{{/* +Return the etcd env vars ConfigMap name +*/}} +{{- define "etcd.configFileCM" -}} +{{- printf "%s" .Values.configFileConfigMap -}} +{{- end -}} diff --git a/bitnami/etcd/templates/configmap.yaml b/bitnami/etcd/templates/configmap.yaml deleted file mode 100644 index cbe95fb00..000000000 --- a/bitnami/etcd/templates/configmap.yaml +++ /dev/null @@ -1,108 +0,0 @@ -{{- if .Values.useConfigmap }} -apiVersion: v1 -kind: ConfigMap -metadata: - name: {{ template "etcd.fullname" . }}-configuration - labels: - app: "{{ template "etcd.name" . }}" - chart: {{ template "etcd.chart" . }} - release: {{ .Release.Name | quote }} - heritage: {{ .Release.Service | quote }} -data: - etcd.conf.yml: |- - # This is the configuration file for the etcd server. - # Human-readable name for this member. - name: 'default' - # Path to the data directory. - data-dir: - # Path to the dedicated wal directory. - wal-dir: - # Number of committed transactions to trigger a snapshot to disk. - snapshot-count: 10000 - # Time (in milliseconds) of a heartbeat interval. - heartbeat-interval: 100 - # Time (in milliseconds) for an election to timeout. - election-timeout: 1000 - # Raise alarms when backend size exceeds the given quota. 0 means use the - # default quota. - quota-backend-bytes: 0 - # List of comma separated URLs to listen on for peer traffic. - listen-peer-urls: http://0.0.0.0:2380 - # List of comma separated URLs to listen on for client traffic. - listen-client-urls: http://0.0.0.0:2379 - # Maximum number of snapshot files to retain (0 is unlimited). - max-snapshots: 5 - # Maximum number of wal files to retain (0 is unlimited). - max-wals: 5 - # Comma-separated white list of origins for CORS (cross-origin resource sharing). - cors: - # List of this member's peer URLs to advertise to the rest of the cluster. - # The URLs needed to be a comma-separated list. - initial-advertise-peer-urls: http://localhost:2380 - # List of this member's client URLs to advertise to the public. - # The URLs needed to be a comma-separated list. - advertise-client-urls: http://localhost:2379 - # Discovery URL used to bootstrap the cluster. - discovery: - # Valid values include 'exit', 'proxy' - discovery-fallback: 'proxy' - # HTTP proxy to use for traffic to discovery service. - discovery-proxy: - # DNS domain used to bootstrap initial cluster. - discovery-srv: - # Initial cluster configuration for bootstrapping. - initial-cluster: - # Initial cluster token for the etcd cluster during bootstrap. - initial-cluster-token: 'etcd-cluster' - # Initial cluster state ('new' or 'existing'). - initial-cluster-state: 'new' - # Reject reconfiguration requests that would cause quorum loss. - strict-reconfig-check: false - # Accept etcd V2 client requests - enable-v2: true - # Enable runtime profiling data via HTTP server - enable-pprof: true - # Valid values include 'on', 'readonly', 'off' - proxy: 'off' - # Time (in milliseconds) an endpoint will be held in a failed state. - proxy-failure-wait: 5000 - # Time (in milliseconds) of the endpoints refresh interval. - proxy-refresh-interval: 30000 - # Time (in milliseconds) for a dial to timeout. - proxy-dial-timeout: 1000 - # Time (in milliseconds) for a write to timeout. - proxy-write-timeout: 5000 - # Time (in milliseconds) for a read to timeout. - proxy-read-timeout: 0 - client-transport-security: - # Path to the client server TLS cert file. - cert-file: - # Path to the client server TLS key file. - key-file: - # Enable client cert authentication. - client-cert-auth: false - # Path to the client server TLS trusted CA cert file. - trusted-ca-file: - # Client TLS using generated certificates - auto-tls: false - peer-transport-security: - # Path to the peer server TLS cert file. - cert-file: - # Path to the peer server TLS key file. - key-file: - # Enable peer client cert authentication. - peer-client-cert-auth: false - # Path to the peer server TLS trusted CA cert file. - trusted-ca-file: - # Peer TLS using generated certificates. - auto-tls: false - # Enable debug-level logging for etcd. - debug: false - logger: zap - # Specify 'stdout' or 'stderr' to skip journald logging even when running under systemd. - log-outputs: [stderr] - # Force to create a new one member cluster. - force-new-cluster: false - auto-compaction-mode: periodic - auto-compaction-retention: "1" -{{- end -}} \ No newline at end of file diff --git a/bitnami/etcd/templates/statefulset.yaml b/bitnami/etcd/templates/statefulset.yaml index 2d39ca964..902716981 100644 --- a/bitnami/etcd/templates/statefulset.yaml +++ b/bitnami/etcd/templates/statefulset.yaml @@ -145,6 +145,11 @@ spec: {{- end }} resources: {{ toYaml .Values.resources | indent 10 }} + {{- if .Values.envVarsConfigMap }} + envFrom: + - configMapRef: + name: {{ template "etcd.envVarsCM" . }} + {{- end }} env: {{- if .Values.image.debug }} - name: BASH_DEBUG @@ -284,7 +289,7 @@ spec: - name: data mountPath: /bitnami/etcd {{ end }} - {{ if .Values.useConfigmap }} + {{ if .Values.configFileConfigMap }} - name: etcd-config mountPath: /opt/bitnami/etcd/conf/ {{ end }} @@ -299,10 +304,10 @@ spec: readOnly: true {{ end }} volumes: - {{ if .Values.useConfigmap }} + {{ if .Values.configFileConfigMap }} - name: etcd-config configMap: - name: {{ template "etcd.fullname" . }}-configuration + name: {{ template "etcd.configFileCM" . }} {{ end }} {{ if or .Values.auth.client.enableAuthentication (and .Values.auth.client.secureTransport (not .Values.auth.client.useAutoTLS ) ) }} - name: etcd-client-certs diff --git a/bitnami/etcd/values-production.yaml b/bitnami/etcd/values-production.yaml index 21ae13343..746de08e2 100644 --- a/bitnami/etcd/values-production.yaml +++ b/bitnami/etcd/values-production.yaml @@ -46,10 +46,13 @@ statefulset: ## replicaCount: 3 -## Take into account that if you use a config map you need to provide the whole configuration -## as the env vars defined in the statefulset.yaml will not be applied +## ConfigMap that includes the etcd.conf.yml file ## -useConfigmap: false +configFileConfigMap: + +## ConfigMap that includes extra environment variables +## +envVarsConfigMap: ## etcd docker image available customizations ## https://github.com/bitnami/bitnami-docker-etcd#configuration diff --git a/bitnami/etcd/values.yaml b/bitnami/etcd/values.yaml index 6d0acd302..cfc6df6f3 100644 --- a/bitnami/etcd/values.yaml +++ b/bitnami/etcd/values.yaml @@ -46,10 +46,13 @@ statefulset: ## replicaCount: 1 -## Take into account that if you use a config map you need to provide the whole configuration -## as the env vars defined in the statefulset.yaml will not be applied +## ConfigMap that includes the etcd.conf.yml file ## -useConfigmap: false +configFileConfigMap: + +## ConfigMap that includes extra environment variables +## +envVarsConfigMap: ## etcd docker image available customizations ## https://github.com/bitnami/bitnami-docker-etcd#configuration From 7cf14c332aa0081c64561aa92e7430b30aebdd9d Mon Sep 17 00:00:00 2001 From: "Javier J. Salmeron Garcia" Date: Mon, 4 Mar 2019 12:25:22 +0100 Subject: [PATCH 2/3] Get rid of useConfigMap missing value --- bitnami/etcd/templates/statefulset.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bitnami/etcd/templates/statefulset.yaml b/bitnami/etcd/templates/statefulset.yaml index 902716981..2b8b4c13b 100644 --- a/bitnami/etcd/templates/statefulset.yaml +++ b/bitnami/etcd/templates/statefulset.yaml @@ -138,7 +138,7 @@ spec: fi fi - {{- if .Values.useConfigmap }} + {{- if .Values.configFileConfigMap }} exec /opt/bitnami/etcd/bin/etcd --config-file /opt/bitnami/etcd/conf/etcd.conf.yml {{ else }} exec /opt/bitnami/etcd/bin/etcd From 94114819e1ec39397eb74ddb4492570efb399cda Mon Sep 17 00:00:00 2001 From: "Javier J. Salmeron Garcia" Date: Mon, 4 Mar 2019 12:34:44 +0100 Subject: [PATCH 3/3] Apply requested changes --- bitnami/etcd/README.md | 4 ++-- bitnami/etcd/values-production.yaml | 4 ++-- bitnami/etcd/values.yaml | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bitnami/etcd/README.md b/bitnami/etcd/README.md index 97a8581c9..3965838c0 100644 --- a/bitnami/etcd/README.md +++ b/bitnami/etcd/README.md @@ -58,8 +58,8 @@ The following tables lists the configurable parameters of the etcd chart and the | `statefulset.rollingUpdatePartition` | Partition for Rolling Update strategy | `nil` | | `statefulset.podManagementPolicy` | Pod management policy for the stateful set | `OrderedReady` | | `statefulset.replicaCount` | Number of etcd nodes | `1` | -| `configFileConfigMap` | ConfigMap that contains a etcd.conf.yaml to be mounted | `` | -| `envVarsConfigMap` | ConfigMap that contains environment variables to be set in the container | `` | +| `configFileConfigMap` | ConfigMap that contains a etcd.conf.yaml to be mounted | `nil` | +| `envVarsConfigMap` | ConfigMap that contains environment variables to be set in the container | `nil` | | `allowNoneAuthentication` | Allow to use etcd without configuring RBAC authentication | `true` | | `auth.rbac.enabled` | Switch to enable the etcd authentication. | `true` | | `auth.rbac.rootPassword` | Password for the root user | `nil` | diff --git a/bitnami/etcd/values-production.yaml b/bitnami/etcd/values-production.yaml index 746de08e2..9c064a03f 100644 --- a/bitnami/etcd/values-production.yaml +++ b/bitnami/etcd/values-production.yaml @@ -48,11 +48,11 @@ statefulset: ## ConfigMap that includes the etcd.conf.yml file ## -configFileConfigMap: +# configFileConfigMap: ## ConfigMap that includes extra environment variables ## -envVarsConfigMap: +# envVarsConfigMap: ## etcd docker image available customizations ## https://github.com/bitnami/bitnami-docker-etcd#configuration diff --git a/bitnami/etcd/values.yaml b/bitnami/etcd/values.yaml index cfc6df6f3..2b35a2a01 100644 --- a/bitnami/etcd/values.yaml +++ b/bitnami/etcd/values.yaml @@ -48,11 +48,11 @@ statefulset: ## ConfigMap that includes the etcd.conf.yml file ## -configFileConfigMap: +# configFileConfigMap: ## ConfigMap that includes extra environment variables ## -envVarsConfigMap: +# envVarsConfigMap: ## etcd docker image available customizations ## https://github.com/bitnami/bitnami-docker-etcd#configuration