All Products
Search
Document Center

Container Service for Kubernetes:Schedule an application to a specified node

Last Updated:Mar 26, 2026

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:

Step 1: Label a node

  1. Log on to the ACK console. In the left navigation pane, click Clusters.

  2. On the Clusters page, click the name of your cluster. In the left navigation pane, choose Nodes > Nodes.

  3. 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 pod and Value to nginx. For more information, see Create and manage node labels.

Step 2: Deploy with a nodeSelector

  1. Log on to the ACK console. In the left navigation pane, click Clusters.

  2. On the Clusters page, click the name of your cluster. In the left navigation pane, choose Workloads > Deployments.

  3. On the Deployments page, click Create from YAML and apply the following manifest. The nodeSelector field restricts the pods to nodes that carry the pod: nginx label.

    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
  4. 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: nginx label. If a pod shows a different node, verify that the node label was applied correctly in Step 1.

What's next