From 0e61f4f5812b7db3b040c071fcc624c708cc5601 Mon Sep 17 00:00:00 2001 From: Clint Shryock Date: Mon, 3 Dec 2018 11:30:50 -0600 Subject: [PATCH] add/update how disruption budget works --- templates/_helpers.tpl | 5 ++++- templates/server-ha-statefulset.yaml | 5 ++++- values.yaml | 16 +++++++++++++++- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/templates/_helpers.tpl b/templates/_helpers.tpl index f8c9c4f..7a3b69c 100644 --- a/templates/_helpers.tpl +++ b/templates/_helpers.tpl @@ -34,9 +34,12 @@ Expand the name of the chart. {{/* Compute the maximum number of unavailable replicas for the PodDisruptionBudget. This defaults to (n/2)-1 where n is the number of members of the server cluster. +Add a special case for replicas=1, where it should default to 0 as well. */}} {{- define "vault.pdb.maxUnavailable" -}} -{{- if .Values.serverHA.disruptionBudget.maxUnavailable -}} +{{- if eq (int .Values.serverHA.replicas) 1 -}} +{{ 0 }} +{{- else if .Values.serverHA.disruptionBudget.maxUnavailable -}} {{ .Values.serverHA.disruptionBudget.maxUnavailable -}} {{- else -}} {{- ceil (sub (div (int .Values.serverHA.replicas) 2) 1) -}} diff --git a/templates/server-ha-statefulset.yaml b/templates/server-ha-statefulset.yaml index 6039eae..9ba8652 100644 --- a/templates/server-ha-statefulset.yaml +++ b/templates/server-ha-statefulset.yaml @@ -34,7 +34,10 @@ spec: release: {{ .Release.Name }} component: server spec: - #TODO: look at how Consul exposes affinity + {{- if .Values.server.affinity }} + affinity: + {{ tpl .Values.server.affinity . | nindent 8 | trim }} + {{- end }} terminationGracePeriodSeconds: 10 volumes: - name: config diff --git a/values.yaml b/values.yaml index 298a6f7..0bd51b9 100644 --- a/values.yaml +++ b/values.yaml @@ -128,7 +128,7 @@ serverHA: # - type: secret (or "configMap") # name: my-secret # load: false # if true, will add to `-config` to load by Vault - + disruptionBudget: enabled: true @@ -136,6 +136,20 @@ serverHA: # replicas. If you'd like a custom value, you can specify an override here. maxUnavailable: null + # Affinity Settings + # Commenting out or setting as empty the affinity variable, will allow + # deployment to single node services such as Minikube + affinity: | + podAntiAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + - labelSelector: + matchLabels: + app: {{ template "vault.name" . }} + release: "{{ .Release.Name }}" + component: server + topologyKey: kubernetes.io/hostname + + # Configuration for DNS configuration within the Kubernetes cluster. # This creates a service that routes to all agents (client or server) # for serving DNS requests. This DOES NOT automatically configure kube-dns