HTK: Update kubernetes_pod_anti_affinity function

Currently the weight value is hardcoded for anti-affinity type
preferredDuringSchedulingIgnoredDuringExecution.  This ps updates
the htk function to retrieve the weight value from the configured
setting if it exists, or default to use the original hardcoded
value of 10 if it is not set (for backward compatibility).

Change-Id: I98c8b05ed7861c9c17e9c32569f53bde6ac2579d
This commit is contained in:
Roy Tang (rt7380) 2019-05-14 17:08:52 -05:00
parent 93ae58c6d1
commit 576a5510f9

View File

@ -27,6 +27,8 @@ values: |
default: kubernetes.io/hostname
type:
default: requiredDuringSchedulingIgnoredDuringExecution
weight:
default: 10
usage: |
{{ tuple . "appliction_x" "component_y" | include "helm-toolkit.snippets.kubernetes_pod_anti_affinity" }}
return: |
@ -74,7 +76,11 @@ podAntiAffinity:
matchExpressions:
{{ $matchExpressions | indent 10 }}
topologyKey: {{ $antiAffinityKey }}
{{- if $envAll.Values.pod.affinity.anti.weight }}
weight: {{ index $envAll.Values.pod.affinity.anti.weight $component | default $envAll.Values.pod.affinity.anti.weight.default }}
{{- else }}
weight: 10
{{- end -}}
{{- else if eq $antiAffinityType "requiredDuringSchedulingIgnoredDuringExecution" }}
{{ $antiAffinityType }}:
- labelSelector: