You can set node labels and a nodeSelector policy to schedule an application to a specified node.
Prerequisites
Step 1: Set node labels
Log on to the ACK console. In the left navigation pane, click Clusters.
On the Clusters page, click the name of the one you want to change. In the left navigation pane, choose .
-
In the upper-right corner of the page, click Manage Labels and Taints. On the Labels tab, add a label to the destination node.
In this example, the Name is pod and the Value is nginx.
For more information, see Create and manage node labels.
Step 2: Schedule the application to a specified node
Log on to the ACK console. In the left navigation pane, click Clusters.
On the Clusters page, click the name of the destination cluster. In the navigation pane on the left, choose .
-
On the Deployments page, click Create from YAML to create an application using the following sample content, which includes a
nodeSelector.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 # Add the node label to run the application only on the destination node. Use the actual value. 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, verify the nodes to which the pods are scheduled.
If all pods are scheduled to nodes that have the
pod: nginxlabel, the scheduling is successful.
References
-
For more information about
nodeSelector, see Assigning Pods to Nodes. -
You can customize a resource policy (ResourcePolicy) to specify the pod scheduling order and implement reverse scale-in when you publish or scale out an application. For more information, see Customize elastic resource priority scheduling.