Use node labels and a nodeSelector to direct pods to specific nodes in your ACK cluster. By default, the Kubernetes scheduler places pods automatically. Use nodeSelector when workloads have specific hardware requirements — for example, GPU-equipped nodes for machine learning tasks, SSD-backed nodes for I/O-intensive databases, or dedicated nodes for co-locating latency-sensitive services.
nodeSelector is the simplest scheduling constraint. Unlike taints and tolerations, it does not prevent other pods from running on the same node — it only controls where the pods it targets can land. For stronger isolation or more expressive rules, use node affinity or inter-pod affinity instead.
Prerequisites
Before you begin, ensure that you have:
-
An ACK managed cluster or an ACK dedicated cluster (ACK dedicated clusters can no longer be newly created)
-
A stateless workload (Deployment) or a stateful workload (StatefulSet) to deploy
Step 1: Label a node
-
Log on to the ACK console. In the left navigation pane, click Clusters.
-
On the Clusters page, click the name of your cluster. In the left navigation pane, choose Nodes > Nodes.
-
In the upper-right corner of the page, click Manage Labels and Taints. On the Labels tab, add a label to the target node. In this example, set Name to
podand Value tonginx. For more information, see Create and manage node labels.
Step 2: Deploy with a nodeSelector
-
Log on to the ACK console. In the left navigation pane, click Clusters.
-
On the Clusters page, click the name of your cluster. In the left navigation pane, choose Workloads > Deployments.
-
On the Deployments page, click Create from YAML and apply the following manifest. The
nodeSelectorfield restricts the pods to nodes that carry thepod: nginxlabel.apiVersion: apps/v1 kind: Deployment metadata: name: nginx-deployment-basic labels: app: nginx spec: replicas: 2 selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: nodeSelector: pod: nginx # Pods are scheduled only to nodes with this label. containers: - name: nginx image: anolis-registry.cn-zhangjiakou.cr.aliyuncs.com/openanolis/nginx:1.14.1-8.6 ports: - containerPort: 80 -
On the Deployments page, click the name of the Deployment. On the Pods tab, check the node column for each pod. All pods should be running on nodes that carry the
pod: nginxlabel. If a pod shows a different node, verify that the node label was applied correctly in Step 1.
What's next
-
For a full reference on
nodeSelectorand other node-assignment methods, see Assigning Pods to Nodes. -
To control pod scheduling order and configure reverse scale-in during deployments and scale-out operations, see Customize elastic resource priority scheduling.