kubetnetes NodeSelector

Pod.spec.nodeSelector是通过kubernetes的label-selector机制进行节点选择,由scheduler调度策略MatchNodeSelector进行label匹配,调度pod到目标节点,该匹配规则是强制约束。启用节点选择器的步骤为:

  1. NODE添加lable 标签
[root@node2 ~]# kubectl label nodes 192.168.1.33 zone=middleware      
node "192.168.1.33" labeled
  1. Pod定义中添加nodeSelector
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: nginx
spec:
  replicas: 2
  template:
    metadata:
      labels:
        app: nginx
    spec:
      nodeSelector:
        zone: middleware #指定调度节点为带有label标记为 zone=middleware 
      containers:
        .......

未经允许不得转载:99ya » kubetnetes NodeSelector