kubernetes 实战5_命令_Configure Pods and Containers

Assign Pods to Nodes

how to assign a Kubernetes Pod to a particular node in a Kubernetes cluster.

Add a label to a node

#List the nodes in your cluster:
kubectl get nodes

#The output is similar to this:
NAME      STATUS    AGE     VERSION
worker0   Ready     1d      v1.6.0+fff5156
worker1   Ready     1d      v1.6.0+fff5156
worker2   Ready     1d      v1.6.0+fff5156

#chose one of your nodes, and add a label to it:
#where <your-node-name> is the name of your chosen node.
kubectl label nodes <your-node-name> disktype=ssd


#Verify that your chosen node has a disktype=ssd label:
kubectl get nodes –show-labels

#The output is similar to this:
#In the preceding output, you can see that the worker0 node has a disktype=ssd label.
NAME      STATUS    AGE     VERSION            LABELS
worker0   Ready     1d      v1.6.0+fff5156     ...,disktype=ssd,kubernetes.io/hostname=worker0
worker1   Ready     1d      v1.6.0+fff5156     ...,kubernetes.io/hostname=worker1
worker2   Ready     1d      v1.6.0+fff5156     ...,kubernetes.io/hostname=worker2

Create a pod that gets scheduled to your chosen node

猜你喜欢

转载自www.cnblogs.com/panpanwelcome/p/9122666.html