Kubernetes 调度器 - 固定节点

指定调度节点

1、Pod.spec.nodeName 将 Pod 直接调度到指定的 Node 节点上,会跳过 Scheduler 的调度策略,该匹配规则是强制匹配

apiVersion: apps/v1
kind: Deployment
metadata:
  name: myapp-pod6
spec:
  selector:
    matchLabels:
      app: myapp-pod6
  replicas: 4
  template:
    metadata:
      labels:
        app: myapp-pod6
    spec:
      nodeName: xgcloud-ops-k8s-cluster-1.novalocal
      containers:
      - name: myapp-pod6
        image: busybox
        command: [sh, -c, echo Hello Kubernetes! && sleep 3600]

 

kubectl apply -f pod6.yaml 

kubectl get pod -o wide

Kubernetes 调度器 - 固定节点

 

 

 

2、Pod.spec.nodeSelector:通过 kubernetes 的 label-selector 机制选择节点,由调度器调度策略匹配 label,而后调度 Pod 到目标节点,该匹配规则属于强制约束

apiVersion: apps/v1
kind: Deployment
metadata:
  name: myapp-pod7
spec:
  selector:
    matchLabels:
      app: myapp-pod7
  replicas: 4
  template:
    metadata:
      labels:
        app: myapp-pod7
    spec:
      nodeSelector:
        kubernetes.io/hostname: xgcloud-ops-k8s-cluster-2.novalocal 
      containers:
      - name: myapp-pod7
        image: busybox
        command: [sh, -c, echo Hello Kubernetes! && sleep 3600]

 

kubectl apply -f pod7.yaml 

kubectl get pod -o wide

Kubernetes 调度器 - 固定节点

 

 

Kubernetes 调度器 - 固定节点

 

Kubernetes 调度器 - 固定节点

上一篇:HTML中强调文字


下一篇:django的文件上传处理