You can configure node labels and a node selector to schedule application pods to the specified node.
Prerequisites
Step 1: Configure node labels
Log on to the ACK console. In the left-side navigation pane, click Clusters.
In the left-side navigation pane of the details page, choose .
On the Nodes page, click Manage Labels and Taints in the upper-right corner to go to the Manage Labels and Taints page.
On the Labels tab, select the node that you want to use and click Add Label.
In the Add dialog box, specify Name and Value of the label and click OK.
Name: The label key can contain letters, digits, underscores (_), hyphens (-), and periods (.). It must start and end with a letter or digit. In this example, the label key is pod.
Value: The label value can be an empty string or contain letters, digits, underscores (_), hyphens (-), and periods (.). It must start and end with a letter or digit. In this example, the label value is nginx.
Step 2: Schedule application pods to the specified node
Log on to the ACK console. In the left-side navigation pane, click Clusters.
In the left-side navigation pane of the details page, choose .
Click View in YAML in the Actions column of the Deployment that you want to manage and configure a node selector. 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 label of the node that you added to ensure that the application pods run only on this node. Specify the actual label that you added. containers: - name: nginx image: nginx:1.7.9 ports: - containerPort: 80
Click Update. The system prompts the deployment information.
Verify the configuration
Click the name of the Deployment to go to the details page and click the Pods tab. The tab shows that the application pods are scheduled to the node xxx.xxx.33.88. The node has the pod: nginx label.
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 priorities of different node types to which application pods are scheduled. When the system scales in application pods, pods are removed from nodes based on the priorities of the nodes in ascending order. For more information, see Configure priority-based resource scheduling.