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"
pod:
affinity:
anti:
type:
default: preferredDuringSchedulingIgnoredDuringExecution
topologyKey:
default: kubernetes.io/hostname
mounts:
barbican_api:
init_container: null

View File

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

View File

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

View File

@ -28,9 +28,11 @@ spec:
labels:
{{ tuple $envAll "ceph" "rgw" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 8 }}
spec:
affinity:
{{ tuple $envAll "ceph" "rgw" | include "helm-toolkit.snippets.kubernetes_pod_anti_affinity" | indent 8 }}
nodeSelector:
{{ .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 }}
serviceAccount: default
containers:

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -16,8 +16,10 @@
{{- $envAll := index . 0 -}}
{{- $application := index . 1 -}}
{{- $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:
preferredDuringSchedulingIgnoredDuringExecution:
{{ $antiAffinityType }}:
- podAffinityTerm:
labelSelector:
matchExpressions:
@ -33,6 +35,6 @@ podAntiAffinity:
operator: In
values:
- {{ $component }}
topologyKey: kubernetes.io/hostname
topologyKey: {{ $antiAffinityKey }}
weight: 10
{{- end -}}

View File

@ -17,8 +17,6 @@
# Declare name/value pairs to be passed into your templates.
# name: value
images:
db_init: 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
pod:
affinity:
anti:
type:
default: preferredDuringSchedulingIgnoredDuringExecution
topologyKey:
default: kubernetes.io/hostname
mounts:
horizon_db_init:
init_container: null

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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