In some cases, you may need to deploy pods on a specified node to meet your business
requirements. You may also need to deploy pods on nodes that use standard SSDs. This
topic describes how to schedule a pod to a specific node in the Container Service
for Kubernetes (ACK) console. You can configure node labels or pod templates to schedule
pods to specific nodes.
Background information
You can configure node labels and set nodeSelector
to schedule a pod to a specific node. For more information about how to set nodeSelector,
see nodeSelector.
Step 1: Configure node labels
- Log on to the ACK console.
- In the left-side navigation pane of the ACK console, click Clusters.
- On the Clusters page, find the cluster that you want to manage and click the name of the cluster
or click Details in the Actions column. The details page of the cluster appears.
- 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 nodes that you want to manage and click Add Label.
- In the Add dialog box, specify Name and Value, and then click OK.
- Name: the name of the label. The name can contain letters, digits, hyphens (-), underscores
(_), and periods (.).The name must start and end with a letter or a digit.
- Value: the value of the label. The value can contain letters, digits, hyphens (-), underscores
(_), and periods (.).The label value must start and end with a letter or a digit.
You can leave this parameter empty.
Step 2: Schedule a pod to a specific node
- In the left-side navigation pane of the ACK console, click Clusters.
- On the Clusters page, find the cluster that you want to manage and click the name of the cluster
or click Details in the Actions column. The details page of the cluster appears.
- In the left-side navigation pane of the details page, choose .
- On the Deployments page, click Create from Template in the upper-right corner.
- Configure the template and use the template to deploy a pod.
- Namespace: Select the namespace to which the pod belongs. In this example, the default namespace is selected.
- Sample Template: In this example, Custom is selected.
The following YAML template is used to deploy the pod:
apiVersion: v1
kind: Pod
metadata:
labels:
name: hello-pod
name: hello-pod
spec:
containers:
- image: nginx
imagePullPolicy: IfNotPresent
name: hello-pod
ports:
- containerPort: 8080
protocol: TCP
resources: {}
securityContext:
capabilities: {}
privileged: false
terminationMessagePath: /dev/termination-log
dnsPolicy: ClusterFirst
restartPolicy: Always
nodeSelector:
group: worker ##This value must be the same as the node label that is added in Step 1.
status: {}
- Click Create. A message that indicates the deployment status appears.
Verify the result
You can use one of the following methods to check whether the pod is deployed on the
specified node:
Method 1: Click the pod name after the pod is deployed
- After the pod is deployed, click the pod name in the notification at the bottom of
the page to go to the Pods page.
- On the Pods page, click the pod name to go to the details page of the pod.
You can view the labels of the pod and the ID of the node to which the pod is scheduled.
The following figure indicates that the pod is scheduled to the node with the
group:worker
label.
Method 2: Check the containers on the Pods page
- In the left-side navigation pane of the ACK console, click Clusters.
- On the Clusters page, find the cluster that you want to manage and click the name of the cluster
or click Details in the Actions column. The details page of the cluster appears.
- In the left-side navigation pane of the details page, choose .
- On the Pods page, click the pod name to go to the details page of the pod.
You can view the labels of the pod and the ID of the node to which the pod is scheduled.
The following figure indicates that the pod is scheduled to the node with the group:worker
label.