Update pod affinity to allow customisation

This PS updates the pod affinity function to allow customisation by
operators at the point of deployment.

Change-Id: I8b7b2f584e990e068051d9a6d5cc7b1e1adb5aa5
This commit is contained in:
Pete Birley 2017-07-27 16:15:46 -05:00
parent 95d58a2f22
commit f30cbcf108
23 changed files with 119 additions and 5 deletions

View File

@ -26,6 +26,12 @@ images:
pull_policy: "IfNotPresent" pull_policy: "IfNotPresent"
pod: pod:
affinity:
anti:
type:
default: preferredDuringSchedulingIgnoredDuringExecution
topologyKey:
default: kubernetes.io/hostname
mounts: mounts:
barbican_api: barbican_api:
init_container: null init_container: null

View File

@ -28,6 +28,8 @@ spec:
labels: labels:
{{ tuple $envAll "ceph" "mds" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 8 }} {{ tuple $envAll "ceph" "mds" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 8 }}
spec: spec:
affinity:
{{ tuple $envAll "ceph" "mds" | include "helm-toolkit.snippets.kubernetes_pod_anti_affinity" | indent 8 }}
nodeSelector: nodeSelector:
{{ .Values.labels.mds.node_selector_key }}: {{ .Values.labels.mds.node_selector_value }} {{ .Values.labels.mds.node_selector_key }}: {{ .Values.labels.mds.node_selector_value }}
initContainers: initContainers:

View File

@ -27,6 +27,8 @@ spec:
labels: labels:
{{ tuple $envAll "ceph" "moncheck" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 8 }} {{ tuple $envAll "ceph" "moncheck" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 8 }}
spec: spec:
affinity:
{{ tuple $envAll "ceph" "moncheck" | include "helm-toolkit.snippets.kubernetes_pod_anti_affinity" | indent 8 }}
nodeSelector: nodeSelector:
{{ .Values.labels.mon.node_selector_key }}: {{ .Values.labels.mon.node_selector_value }} {{ .Values.labels.mon.node_selector_key }}: {{ .Values.labels.mon.node_selector_value }}
initContainers: initContainers:

View File

@ -28,9 +28,11 @@ spec:
labels: labels:
{{ tuple $envAll "ceph" "rgw" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 8 }} {{ tuple $envAll "ceph" "rgw" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 8 }}
spec: spec:
affinity:
{{ tuple $envAll "ceph" "rgw" | include "helm-toolkit.snippets.kubernetes_pod_anti_affinity" | indent 8 }}
nodeSelector: nodeSelector:
{{ .Values.labels.rgw.node_selector_key }}: {{ .Values.labels.rgw.node_selector_value }} {{ .Values.labels.rgw.node_selector_key }}: {{ .Values.labels.rgw.node_selector_value }}
initContainers: initContainers:
{{ tuple $envAll $dependencies "" | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 8 }} {{ tuple $envAll $dependencies "" | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 8 }}
serviceAccount: default serviceAccount: default
containers: containers:

View File

@ -50,6 +50,12 @@ labels:
node_selector_value: enabled node_selector_value: enabled
pod: pod:
affinity:
anti:
type:
default: preferredDuringSchedulingIgnoredDuringExecution
topologyKey:
default: kubernetes.io/hostname
resources: resources:
enabled: false enabled: false
osd: osd:

View File

@ -39,6 +39,12 @@ images:
pull_policy: "IfNotPresent" pull_policy: "IfNotPresent"
pod: pod:
affinity:
anti:
type:
default: preferredDuringSchedulingIgnoredDuringExecution
topologyKey:
default: kubernetes.io/hostname
mounts: mounts:
cinder_api: cinder_api:
init_container: null init_container: null

View File

@ -26,6 +26,8 @@ spec:
labels: labels:
{{ tuple $envAll "etcd" "server" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 8 }} {{ tuple $envAll "etcd" "server" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 8 }}
spec: spec:
affinity:
{{ tuple $envAll "etcd" "server" | include "helm-toolkit.snippets.kubernetes_pod_anti_affinity" | indent 8 }}
nodeSelector: nodeSelector:
{{ .Values.labels.node_selector_key }}: {{ .Values.labels.node_selector_value }} {{ .Values.labels.node_selector_key }}: {{ .Values.labels.node_selector_value }}
containers: containers:

View File

@ -30,6 +30,12 @@ network:
port: 2379 port: 2379
pod: pod:
affinity:
anti:
type:
default: preferredDuringSchedulingIgnoredDuringExecution
topologyKey:
default: kubernetes.io/hostname
replicas: replicas:
etcd: 1 etcd: 1
lifecycle: lifecycle:

View File

@ -305,6 +305,12 @@ endpoints:
default: 5672 default: 5672
pod: pod:
affinity:
anti:
type:
default: preferredDuringSchedulingIgnoredDuringExecution
topologyKey:
default: kubernetes.io/hostname
mounts: mounts:
glance_api: glance_api:
init_container: null init_container: null

View File

@ -325,6 +325,12 @@ endpoints:
default: 5672 default: 5672
pod: pod:
affinity:
anti:
type:
default: preferredDuringSchedulingIgnoredDuringExecution
topologyKey:
default: kubernetes.io/hostname
mounts: mounts:
heat_api: heat_api:
init_container: null init_container: null

View File

@ -16,8 +16,10 @@
{{- $envAll := index . 0 -}} {{- $envAll := index . 0 -}}
{{- $application := index . 1 -}} {{- $application := index . 1 -}}
{{- $component := index . 2 -}} {{- $component := index . 2 -}}
{{- $antiAffinityType := index $envAll.Values.pod.affinity.anti.type $component | default $envAll.Values.pod.affinity.anti.type.default }}
{{- $antiAffinityKey := index $envAll.Values.pod.affinity.anti.topologyKey $component | default $envAll.Values.pod.affinity.anti.topologyKey.default }}
podAntiAffinity: podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution: {{ $antiAffinityType }}:
- podAffinityTerm: - podAffinityTerm:
labelSelector: labelSelector:
matchExpressions: matchExpressions:
@ -33,6 +35,6 @@ podAntiAffinity:
operator: In operator: In
values: values:
- {{ $component }} - {{ $component }}
topologyKey: kubernetes.io/hostname topologyKey: {{ $antiAffinityKey }}
weight: 10 weight: 10
{{- end -}} {{- end -}}

View File

@ -17,8 +17,6 @@
# Declare name/value pairs to be passed into your templates. # Declare name/value pairs to be passed into your templates.
# name: value # name: value
images: images:
db_init: docker.io/kolla/ubuntu-source-horizon:4.0.0 db_init: docker.io/kolla/ubuntu-source-horizon:4.0.0
db_sync: docker.io/kolla/ubuntu-source-horizon:4.0.0 db_sync: docker.io/kolla/ubuntu-source-horizon:4.0.0
@ -62,6 +60,12 @@ dependencies:
endpoint: internal endpoint: internal
pod: pod:
affinity:
anti:
type:
default: preferredDuringSchedulingIgnoredDuringExecution
topologyKey:
default: kubernetes.io/hostname
mounts: mounts:
horizon_db_init: horizon_db_init:
init_container: null init_container: null

View File

@ -35,6 +35,10 @@ spec:
labels: labels:
app: ingress-api app: ingress-api
spec: spec:
{{- if eq .Values.deployment_type "Deployment" }}
affinity:
{{ tuple $envAll "ingress" "server" | include "helm-toolkit.snippets.kubernetes_pod_anti_affinity" | indent 8 }}
{{- end }}
nodeSelector: nodeSelector:
{{ .Values.labels.node_selector_key }}: {{ .Values.labels.node_selector_value }} {{ .Values.labels.node_selector_key }}: {{ .Values.labels.node_selector_value }}
{{- if .Values.network.host_namespace }} {{- if .Values.network.host_namespace }}

View File

@ -25,6 +25,12 @@ images:
pull_policy: "IfNotPresent" pull_policy: "IfNotPresent"
pod: pod:
affinity:
anti:
type:
default: preferredDuringSchedulingIgnoredDuringExecution
topologyKey:
default: kubernetes.io/hostname
replicas: replicas:
ingress: 1 ingress: 1
error_page: 1 error_page: 1

View File

@ -83,6 +83,12 @@ dependencies:
endpoint: internal endpoint: internal
pod: pod:
affinity:
anti:
type:
default: preferredDuringSchedulingIgnoredDuringExecution
topologyKey:
default: kubernetes.io/hostname
mounts: mounts:
keystone_db_init: keystone_db_init:
init_container: null init_container: null

View File

@ -206,6 +206,12 @@ endpoints:
default: 5672 default: 5672
pod: pod:
affinity:
anti:
type:
default: preferredDuringSchedulingIgnoredDuringExecution
topologyKey:
default: kubernetes.io/hostname
mounts: mounts:
magnum_api: magnum_api:
init_container: null init_container: null

View File

@ -15,6 +15,12 @@
force_bootstrap: false force_bootstrap: false
pod: pod:
affinity:
anti:
type:
default: preferredDuringSchedulingIgnoredDuringExecution
topologyKey:
default: kubernetes.io/hostname
replicas: replicas:
server: 3 server: 3
lifecycle: lifecycle:

View File

@ -22,6 +22,12 @@ images:
pull_policy: "IfNotPresent" pull_policy: "IfNotPresent"
pod: pod:
affinity:
anti:
type:
default: preferredDuringSchedulingIgnoredDuringExecution
topologyKey:
default: kubernetes.io/hostname
replicas: replicas:
server: 1 server: 1
lifecycle: lifecycle:

View File

@ -237,6 +237,12 @@ conf:
auth_version: v3 auth_version: v3
pod: pod:
affinity:
anti:
type:
default: preferredDuringSchedulingIgnoredDuringExecution
topologyKey:
default: kubernetes.io/hostname
mounts: mounts:
mistral_api: mistral_api:
init_container: null init_container: null

View File

@ -184,6 +184,12 @@ dependencies:
endpoint: internal endpoint: internal
pod: pod:
affinity:
anti:
type:
default: preferredDuringSchedulingIgnoredDuringExecution
topologyKey:
default: kubernetes.io/hostname
mounts: mounts:
neutron_server: neutron_server:
init_container: null init_container: null

View File

@ -516,6 +516,12 @@ endpoints:
public: 80 public: 80
pod: pod:
affinity:
anti:
type:
default: preferredDuringSchedulingIgnoredDuringExecution
topologyKey:
default: kubernetes.io/hostname
mounts: mounts:
nova_compute: nova_compute:
init_container: null init_container: null

View File

@ -22,6 +22,12 @@ labels:
node_selector_value: enabled node_selector_value: enabled
pod: pod:
affinity:
anti:
type:
default: preferredDuringSchedulingIgnoredDuringExecution
topologyKey:
default: kubernetes.io/hostname
replicas: replicas:
server: 3 server: 3
lifecycle: lifecycle:

View File

@ -206,6 +206,12 @@ endpoints:
default: 5672 default: 5672
pod: pod:
affinity:
anti:
type:
default: preferredDuringSchedulingIgnoredDuringExecution
topologyKey:
default: kubernetes.io/hostname
mounts: mounts:
senlin_api: senlin_api:
init_container: null init_container: null