All Products
Search
Document Center

Container Service for Kubernetes:Schedule application pods to the specified node

Last Updated:Jul 08, 2025

You can configure node labels and a node selector to schedule application pods to a specified node.

Prerequisites

Step 1: Configure node labels

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

  2. On the Clusters page, click the name of the one you want to change. In the navigation pane on the left, 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 node according to the instructions on the page.

    In this example, the label name is pod and the value is nginx.

    For more information, see Create and manage node labels.

Step 2: Schedule application pods to the specified node

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

  2. On the Clusters page, find the cluster you want to manage and click its name. In the left-side pane, choose Workloads > Deployments.

  3. On the Deployments page, click Create from YAML and use the following sample template to add nodeSelector for the application:

    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      # Specify the node label to ensure that the application runs only on this node. Specify the actual label that you added.
          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 nodes to which the pods are scheduled.

    If all pods are scheduled to nodes with the pod: nginx label, the scheduling is successful.

References

  • For more information about nodeSelector, see Assigning Pods to Nodes.

  • When you release or scale out an application, you can configure a ResourcePolicy to specify the scheduling order and remove pods from nodes based on the priorities of the nodes in ascending order. For more information, see Configure priority-based resource scheduling.