From dea940600730497cf59b3c97b9b5f55ff76018ad Mon Sep 17 00:00:00 2001 From: Markus Lehtonen Date: Mon, 3 Sep 2018 11:37:47 +0300 Subject: [PATCH] Use pod anti-affinity in the worker Job template spec Use pod anti-affinity to explicitly indicate that pods should be scheduled on separate nodes. And, remove the obscure and non-obvious ports definition whose only purpose was to reach the same effect. --- label-nodes.sh | 2 -- nfd-worker-job.yaml.template | 13 ++++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/label-nodes.sh b/label-nodes.sh index 0af6f7da8..c1acfd03d 100755 --- a/label-nodes.sh +++ b/label-nodes.sh @@ -26,8 +26,6 @@ fi NumNodes=$(kubectl get nodes | grep -i ' ready ' | wc -l) # We set the .spec.completions and .spec.parallelism to the node count -# We request a specific hostPort in the job spec to limit the number of pods -# that run on a node to one. As a result, one pod runs on each node in parallel # We set the NODE_NAME environment variable to get the Kubernetes node object. sed -e "s/completions:.*$/completions: $NumNodes/" \ -e "s/parallelism:.*$/parallelism: $NumNodes/" \ diff --git a/nfd-worker-job.yaml.template b/nfd-worker-job.yaml.template index 924cab5db..2d6e90974 100644 --- a/nfd-worker-job.yaml.template +++ b/nfd-worker-job.yaml.template @@ -15,6 +15,16 @@ spec: spec: hostNetwork: true dnsPolicy: ClusterFirstWithHostNet + affinity: + podAntiAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + - topologyKey: kubernetes.io/hostname + labelSelector: + matchExpressions: + - key: app + operator: In + values: + - node-feature-discovery containers: - env: - name: NODE_NAME @@ -28,9 +38,6 @@ spec: args: - "--oneshot" - "--server=nfd-master:8080" - ports: - - containerPort: 7156 - hostPort: 7156 volumeMounts: - name: host-boot mountPath: "/host-boot"