forked from docs/doc-exports
Reviewed-by: Eotvos, Oliver <oliver.eotvos@t-systems.com> Co-authored-by: Dong, Qiu Jian <qiujiandong1@huawei.com> Co-committed-by: Dong, Qiu Jian <qiujiandong1@huawei.com>
55 lines
2.9 KiB
HTML
55 lines
2.9 KiB
HTML
<a name="cce_faq_00260"></a><a name="cce_faq_00260"></a>
|
|
|
|
<h1 class="topictitle1">How Do I Evenly Distribute Multiple Pods to Each Node?</h1>
|
|
<div id="body1586937106616"><p id="cce_faq_00260__p8060118">The kube-scheduler component in Kubernetes is responsible pod scheduling. For each newly created pod or other unscheduled pods, kube-scheduler selects an optimal node from them to run on. kube-scheduler selects a node for a pod in a 2-step operation: filtering and scoring. In the filtering step, all nodes where it is feasible to schedule the pod are filtered out. In the scoring step, kube-scheduler ranks the remaining nodes to choose the most suitable pod placement. Finally, kube-scheduler schedules the pod to the node with the highest score. If there is more than one node with the equal scores, kube-scheduler selects one of them at random.</p>
|
|
<p id="cce_faq_00260__p18910144214453">BalancedResourceAllocation is only one of the scoring priorities. Other scoring items may also cause uneven distribution. For details about scheduling, see <a href="https://kubernetes.io/docs/concepts/scheduling-eviction/kube-scheduler/" target="_blank" rel="noopener noreferrer">Kubernetes Scheduler</a> and <a href="https://kubernetes.io/docs/reference/scheduling/policies/" target="_blank" rel="noopener noreferrer">Scheduling Policies</a>.</p>
|
|
<p id="cce_faq_00260__p73041848154719">You can configure pod anti-affinity policies to evenly distribute pods onto different nodes.</p>
|
|
<p id="cce_faq_00260__p14603163635314">Example:</p>
|
|
<pre class="screen" id="cce_faq_00260__screen6767131210242">kind: Deployment
|
|
apiVersion: apps/v1
|
|
metadata:
|
|
name: nginx
|
|
namespace: default
|
|
spec:
|
|
replicas: 2
|
|
selector:
|
|
matchLabels:
|
|
app: nginx
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app: nginx
|
|
spec:
|
|
containers:
|
|
- name: container-0
|
|
image: nginx:alpine
|
|
resources:
|
|
limits:
|
|
cpu: 250m
|
|
memory: 512Mi
|
|
requests:
|
|
cpu: 250m
|
|
memory: 512Mi
|
|
affinity:
|
|
podAntiAffinity: # Workload anti-affinity
|
|
preferredDuringSchedulingIgnoredDuringExecution: # Ensure that the following conditions are met:
|
|
- podAffinityTerm:
|
|
labelSelector: # Select the label of the pod, which is anti-affinity with the workload.
|
|
matchExpressions:
|
|
- key: app
|
|
operator: In
|
|
values:
|
|
- nginx
|
|
namespaces:
|
|
- default
|
|
topologyKey: kubernetes.io/hostname # It takes effect on the node.
|
|
imagePullSecrets:
|
|
- name: default-secret</pre>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="cce_faq_00284.html">Scheduling Policies</a></div>
|
|
</div>
|
|
</div>
|
|
|