From 9403c03a6401cdcc44a0a191972a140792791f1b Mon Sep 17 00:00:00 2001 From: Alexey Zhokhov Date: Thu, 9 Jan 2020 00:22:56 +0800 Subject: [PATCH] More flexible affinity configuration. --- .../elasticsearch/es-client-deploy.yaml | 16 ++------ .../templates/elasticsearch/es-data-sts.yaml | 16 ++------ .../elasticsearch/es-master-sts.yaml | 14 ++----- .../templates/kibana/kibana-deployment.yaml | 4 ++ helm/opendistro-es/values.yaml | 38 ++++++++++++++++--- 5 files changed, 45 insertions(+), 43 deletions(-) diff --git a/helm/opendistro-es/templates/elasticsearch/es-client-deploy.yaml b/helm/opendistro-es/templates/elasticsearch/es-client-deploy.yaml index a17be8cfc..af62bc907 100755 --- a/helm/opendistro-es/templates/elasticsearch/es-client-deploy.yaml +++ b/helm/opendistro-es/templates/elasticsearch/es-client-deploy.yaml @@ -51,20 +51,10 @@ spec: nodeSelector: {{ toYaml . | indent 8 }} {{- end }} - # Weighted anti-affinity to disallow deploying client node to the same worker node as master node + {{- with .Values.elasticsearch.client.affinity }} affinity: - podAntiAffinity: - preferredDuringSchedulingIgnoredDuringExecution: - - weight: 1 - podAffinityTerm: - topologyKey: "kubernetes.io/hostname" - labelSelector: - matchLabels: - role: client - {{- with .Values.elasticsearch.client.nodeAffinity }} - nodeAffinity: -{{ toYaml . | indent 10 }} - {{- end }} +{{- toYaml . | nindent 8 }} + {{- end }} initContainers: - name: init-sysctl image: {{ .Values.elasticsearch.initContainer.image }}:{{ .Values.elasticsearch.initContainer.imageTag }} diff --git a/helm/opendistro-es/templates/elasticsearch/es-data-sts.yaml b/helm/opendistro-es/templates/elasticsearch/es-data-sts.yaml index 163cf36be..61d3db5d7 100755 --- a/helm/opendistro-es/templates/elasticsearch/es-data-sts.yaml +++ b/helm/opendistro-es/templates/elasticsearch/es-data-sts.yaml @@ -69,20 +69,10 @@ spec: - mountPath: /usr/share/elasticsearch/data name: data subPath: {{ .Values.elasticsearch.data.persistence.subPath }} - # Weighted anti-affinity to disallow deploying client node to the same worker node as master node + {{- with .Values.elasticsearch.data.affinity }} affinity: - podAntiAffinity: - preferredDuringSchedulingIgnoredDuringExecution: - - weight: 1 - podAffinityTerm: - topologyKey: "kubernetes.io/hostname" - labelSelector: - matchLabels: - role: data - {{- with .Values.elasticsearch.data.nodeAffinity }} - nodeAffinity: -{{ toYaml . | indent 10 }} - {{- end }} +{{- toYaml . | nindent 8 }} + {{- end }} serviceAccountName: {{ template "opendistro-es.elasticsearch.serviceAccountName" . }} containers: - name: elasticsearch diff --git a/helm/opendistro-es/templates/elasticsearch/es-master-sts.yaml b/helm/opendistro-es/templates/elasticsearch/es-master-sts.yaml index 85db5a727..3332148ff 100755 --- a/helm/opendistro-es/templates/elasticsearch/es-master-sts.yaml +++ b/helm/opendistro-es/templates/elasticsearch/es-master-sts.yaml @@ -54,18 +54,10 @@ spec: nodeSelector: {{ toYaml . | indent 8 }} {{- end }} - # Anti-affinity to disallow deploying client and master nodes on the same worker node + {{- with .Values.elasticsearch.master.affinity }} affinity: - podAntiAffinity: - requiredDuringSchedulingIgnoredDuringExecution: - - topologyKey: "kubernetes.io/hostname" - labelSelector: - matchLabels: - role: master - {{- with .Values.elasticsearch.master.nodeAffinity }} - nodeAffinity: -{{ toYaml . | indent 10 }} - {{- end }} +{{- toYaml . | nindent 8 }} + {{- end }} initContainers: - name: init-sysctl image: {{ .Values.elasticsearch.initContainer.image }}:{{ .Values.elasticsearch.initContainer.imageTag }} diff --git a/helm/opendistro-es/templates/kibana/kibana-deployment.yaml b/helm/opendistro-es/templates/kibana/kibana-deployment.yaml index 773efde93..0cdd91193 100755 --- a/helm/opendistro-es/templates/kibana/kibana-deployment.yaml +++ b/helm/opendistro-es/templates/kibana/kibana-deployment.yaml @@ -137,6 +137,10 @@ spec: {{- with .Values.kibana.nodeSelector }} nodeSelector: {{ toYaml . | indent 8 }} + {{- end }} + {{- with .Values.elasticsearch.client.affinity }} + affinity: +{{- toYaml . | nindent 8 }} {{- end }} {{- with .Values.kibana.tolerations }} tolerations: diff --git a/helm/opendistro-es/values.yaml b/helm/opendistro-es/values.yaml index 85eb828cc..2744ce4b8 100755 --- a/helm/opendistro-es/values.yaml +++ b/helm/opendistro-es/values.yaml @@ -96,6 +96,7 @@ kibana: ## tolerations: [] + affinity: {} serviceAccount: # Specifies whether a ServiceAccount should be created @@ -154,7 +155,6 @@ elasticsearch: enabled: true replicas: 3 updateStrategy: "RollingUpdate" - nodeAffinity: {} ## Enable persistence using Persistent Volume Claims ## ref: http://kubernetes.io/docs/user-guide/persistent-volumes/ @@ -196,7 +196,6 @@ elasticsearch: podDisruptionBudget: enabled: false minAvailable: 1 - tolerations: [] readinessProbe: [] livenessProbe: tcpSocket: @@ -204,13 +203,21 @@ elasticsearch: initialDelaySeconds: 60 periodSeconds: 10 nodeSelector: {} + tolerations: [] + # Anti-affinity to disallow deploying client and master nodes on the same worker node + affinity: {} + # podAntiAffinity: + # requiredDuringSchedulingIgnoredDuringExecution: + # - topologyKey: "kubernetes.io/hostname" + # labelSelector: + # matchLabels: + # role: master podAnnotations: {} data: enabled: true replicas: 3 updateStrategy: "RollingUpdate" - nodeAffinity: {} ## Enable persistence using Persistent Volume Claims ## ref: http://kubernetes.io/docs/user-guide/persistent-volumes/ @@ -252,7 +259,6 @@ elasticsearch: podDisruptionBudget: enabled: false minAvailable: 1 - tolerations: [] readinessProbe: [] livenessProbe: tcpSocket: @@ -260,6 +266,17 @@ elasticsearch: initialDelaySeconds: 60 periodSeconds: 10 nodeSelector: {} + tolerations: [] + # Anti-affinity to disallow deploying client and master nodes on the same worker node + affinity: {} + # podAntiAffinity: + # preferredDuringSchedulingIgnoredDuringExecution: + # - weight: 1 + # podAffinityTerm: + # topologyKey: "kubernetes.io/hostname" + # labelSelector: + # matchLabels: + # role: data podAnnotations: {} client: @@ -283,7 +300,6 @@ elasticsearch: # service.beta.kubernetes.io/aws-load-balancer-internal: 0.0.0.0/0 replicas: 2 javaOpts: "-Xms512m -Xmx512m" - nodeAffinity: {} ingress: enabled: true annotations: {} @@ -307,7 +323,6 @@ elasticsearch: podDisruptionBudget: enabled: false minAvailable: 1 - tolerations: [] readinessProbe: [] livenessProbe: tcpSocket: @@ -315,6 +330,17 @@ elasticsearch: initialDelaySeconds: 60 periodSeconds: 10 nodeSelector: {} + tolerations: [] + # Weighted anti-affinity to disallow deploying client node to the same worker node as master node + affinity: {} + # podAntiAffinity: + # preferredDuringSchedulingIgnoredDuringExecution: + # - weight: 1 + # podAffinityTerm: + # topologyKey: "kubernetes.io/hostname" + # labelSelector: + # matchLabels: + # role: client podAnnotations: {} config: {}