把Pod分配到node上

发布时间 2023-07-24 17:22:54作者: pr1s0n

分配Pod到node

给node打上标签

kubectl label nodes <your-node-name> disktype=ssd

查看标签

kubectl get nodes --show-labels

image-20230515171829538

根据标签分配node

apiVersion: v1
kind: Pod
metadata:
  name: nginx
  labels:
    env: test
spec:
  containers:
  - name: nginx
    image: nginx
    imagePullPolicy: IfNotPresent
  nodeSelector:
    disktype: ssd
image-20230515172011110

指定node

apiVersion: v1
kind: Pod
metadata:
  name: nginx
spec:
  nodeName: foo-node # 调度 Pod 到特定的节点
  containers:
  - name: nginx
    image: nginx
    imagePullPolicy: IfNotPresent