首页 > > > K8S 将 pod 调度到指定 nodes 上运行
vim text.yaml
nodeName: worker01 #添加节点名参数apiVersion: v1
kind: Pod
metadata:
name: text
namespace: text
spec:
nodeName: worker01 #添加节点名参数
containers:
- name: hello
image: centos:7
imagePullPolicy: IfNotPresent
command: ["bash","-c","--"]
args: ["while true; do sleep 3;done;"]kubectl create -f text.yaml

kubectl describe pod text -n text
kubectl label nodes worker03 type=node_type
kubectl get node --show-labels #获取所有节点的标签,得到worker03设置的标签
vim text1.yamlapiVersion: v1
kind: Pod
metadata:
name: text1
namespace: text
spec:
nodeSelector: #标签选择器参数
type: node_type #刚刚添加的类型
containers:
- name: hello1
image: centos:7
imagePullPolicy: IfNotPresent
command: ["bash","-c","--"]
args: ["while true; do sleep 3;done;"]
kubectl get pod -n text
kubectl describe pod text1 -n text
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/69946831/viewspace-3143703/ ,如需转载,请注明出处,否则将追究法律责任。