All Products
Search
Document Center

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

Last Updated:Jun 10, 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 left-side navigation pane, click Clusters.

  2. On the Clusters page, click the name of the one you want to change. In the left-side 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 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 left-side navigation pane, 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. In the Actions column of the application that you want to manage, select image > Edit YAML to configure the nodeSelector parameter for the application, and then click Update.

    In this topic, the Deployment named nginx-deployment-basic is used as an example.

    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.