diff --git a/etcd/templates/bin/_etcd.sh.tpl b/etcd/templates/bin/_etcd.sh.tpl new file mode 100644 index 0000000000..17320a1965 --- /dev/null +++ b/etcd/templates/bin/_etcd.sh.tpl @@ -0,0 +1,23 @@ +#!/bin/sh + +{{/* +Copyright 2017 The Openstack-Helm Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/}} + +set -ex + +exec etcd \ + --listen-client-urls http://0.0.0.0:{{ tuple "etcd" "internal" "client" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }} \ + --advertise-client-urls {{ tuple "etcd" "internal" "client" . | include "helm-toolkit.endpoints.keystone_endpoint_uri_lookup" | trimSuffix "/" }} diff --git a/etcd/templates/configmap-bin.yaml b/etcd/templates/configmap-bin.yaml new file mode 100644 index 0000000000..14d37a52a6 --- /dev/null +++ b/etcd/templates/configmap-bin.yaml @@ -0,0 +1,28 @@ +{{/* +Copyright 2017 The Openstack-Helm Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/}} + +{{- if .Values.manifests.configmap_bin }} +{{- $envAll := . }} +{{- $configMapBinName := printf "%s-%s" $envAll.Release.Name "etcd-bin" }} +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ $configMapBinName }} +data: + etcd.sh: | +{{ tuple "bin/_etcd.sh.tpl" . | include "helm-toolkit.utils.template" | indent 4 }} +{{- end }} diff --git a/etcd/templates/deployment.yaml b/etcd/templates/deployment.yaml index f1ae96ca3a..1824cff648 100644 --- a/etcd/templates/deployment.yaml +++ b/etcd/templates/deployment.yaml @@ -12,16 +12,20 @@ # See the License for the specific language governing permissions and # limitations under the License. +{{- if .Values.manifests.deployment }} {{- $envAll := . }} + {{- $dependencies := .Values.dependencies.etcd }} -{{- $serviceAccountName := "etcd" }} -{{ tuple $envAll $dependencies $serviceAccountName | include "helm-toolkit.snippets.kubernetes_pod_rbac_serviceaccount" }} +{{- $rcControllerName := printf "%s-%s" $envAll.Release.Name "etcd" }} +{{- $configMapBinName := printf "%s-%s" $envAll.Release.Name "etcd-bin" }} + +{{ tuple $envAll $dependencies $rcControllerName | include "helm-toolkit.snippets.kubernetes_pod_rbac_serviceaccount" }} --- apiVersion: apps/v1beta1 kind: Deployment metadata: - name: etcd + name: {{ $rcControllerName | quote }} spec: replicas: {{ .Values.pod.replicas.etcd }} {{ tuple $envAll | include "helm-toolkit.snippets.kubernetes_upgrades_deployment" | indent 2 }} @@ -30,7 +34,7 @@ spec: labels: {{ tuple $envAll "etcd" "server" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 8 }} spec: - serviceAccountName: {{ $serviceAccountName }} + serviceAccountName: {{ $rcControllerName | quote }} affinity: {{ tuple $envAll "etcd" "server" | include "helm-toolkit.snippets.kubernetes_pod_anti_affinity" | indent 8 }} nodeSelector: @@ -42,13 +46,20 @@ spec: image: {{ .Values.images.tags.etcd }} imagePullPolicy: {{ .Values.images.pull_policy }} command: - - etcd - - --listen-client-urls - - http://0.0.0.0:{{ .Values.network.port }} - - --advertise-client-urls - - http://{{ .Values.network.host }}:{{ .Values.network.port }} + - /tmp/etcd.sh ports: - - containerPort: {{ .Values.network.port }} + - containerPort: {{ tuple "etcd" "internal" "client" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }} readinessProbe: tcpSocket: - port: {{ .Values.network.port }} + port: {{ tuple "etcd" "internal" "client" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }} + volumeMounts: + - name: etcd-bin + mountPath: /tmp/etcd.sh + subPath: etcd.sh + readOnly: true + volumes: + - name: etcd-bin + configMap: + name: {{ $configMapBinName | quote }} + defaultMode: 0555 +{{- end }} diff --git a/etcd/templates/service.yaml b/etcd/templates/service.yaml index 5b676715de..1c65ac99bf 100644 --- a/etcd/templates/service.yaml +++ b/etcd/templates/service.yaml @@ -12,15 +12,17 @@ # See the License for the specific language governing permissions and # limitations under the License. +{{- if .Values.manifests.service }} {{- $envAll := . }} --- apiVersion: v1 kind: Service metadata: - name: {{ .Values.network.host }} + name: {{ tuple "etcd" "internal" . | include "helm-toolkit.endpoints.hostname_short_endpoint_lookup" }} spec: sessionAffinity: ClientIP ports: - - port: {{ .Values.network.port }} + - port: {{ tuple "etcd" "internal" "client" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }} selector: {{ tuple $envAll "etcd" "server" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }} +{{- end }} diff --git a/etcd/values.yaml b/etcd/values.yaml index c447033448..2811944abb 100644 --- a/etcd/values.yaml +++ b/etcd/values.yaml @@ -28,21 +28,17 @@ labels: node_selector_key: openstack-control-plane node_selector_value: enabled -network: - host: etcd - port: 2379 - dependencies: etcd: jobs: null pod: affinity: - anti: - type: - default: preferredDuringSchedulingIgnoredDuringExecution - topologyKey: - default: kubernetes.io/hostname + anti: + type: + default: preferredDuringSchedulingIgnoredDuringExecution + topologyKey: + default: kubernetes.io/hostname replicas: etcd: 1 lifecycle: @@ -53,3 +49,24 @@ pod: rolling_update: max_surge: 3 max_unavailable: 1 + +endpoints: + cluster_domain_suffix: cluster.local + etcd: + name: etcd + hosts: + default: etcd + host_fqdn_override: + default: null + path: + default: null + scheme: + default: 'http' + port: + client: + default: 2379 + +manifests: + configmap_bin: true + deployment: true + service: true