Pod的调度约束

一、根据节点的名字来调度 

1)nodeName:用于将pod调度到指定的Node名称上,不会经过默认调度器。
 [root@master01 demo3]# kubectl describe nginx-harbor-limit
  Type    Reason   Age   From             Message
  ----    ------   ----  ----             -------
  Normal  Pulling  35s   kubelet, node02  Pulling image "42.159.152.148/mydate/nginx:latest"
  Normal  Pulled   33s   kubelet, node02  Successfully pulled image "42.159.152.148/mydate/nginx:latest"
  Normal  Created  33s   kubelet, node02  Created container nginx-harbor-limit
  Normal  Started  32s   kubelet, node02  Started container nginx-harbor-limit

  2)nodeSelect:用于将pod调度到匹配Label的Node上,通过默认的调度器来调度。
[root@master01 demo3]# kubectl describe nginx-harbor-limit
Events:
  Type    Reason     Age   From               Message
  ----    ------     ----  ----               -------
  Normal  Scheduled  4m8s  default-scheduler  Successfully assigned default/nginx-harbor-limit-757b75774-vg5dz to node01
  Normal  Pulling    4m6s  kubelet, node01    Pulling image "42.159.152.148/mydate/nginx:latest"
  Normal  Pulled     4m5s  kubelet, node01    Successfully pulled image "42.159.152.148/mydate/nginx:latest"
  Normal  Created    4m5s  kubelet, node01    Created container nginx-harbor-limit
  Normal  Started    4m5s  kubelet, node01    Started container nginx-harbor-limit


apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-harbor-limit
  labels:
        app: nginx-harbor-limit
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx-harbor-limit
  template:
    metadata:
      labels:
        app: nginx-harbor-limit
    spec:
      nodeName: node02            #注意这里是get node看到的名字,不一定是ip地址。
      imagePullSecrets:
      - name: registry-pull-152.148-harbor
      containers:
        - name: nginx-harbor-limit
          image: 42.159.152.148/mydate/nginx:latest
          ports:
            - containerPort: 80

二、根据节点标签来调度
[root@master01 demo3]# kubectl label nodes node01 team=A      #给节点打标签
[root@master01 demo3]# kubectl label nodes node02 team=B
[root@master01 demo3]# kubectl get nodes --show-labels       #标签查看
[root@master01 demo3]# more lable-select.yaml 

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-harbor-limit
  labels:
        app: nginx-harbor-limit
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx-harbor-limit
  template:
    metadata:
      labels:
        app: nginx-harbor-limit
    spec:
      nodeSelector:   #根据标签来选择
        team: A
      imagePullSecrets:
      - name: registry-pull-152.148-harbor
      containers:
        - name: nginx-harbor-limit
          image: 42.159.152.148/mydate/nginx:latest
          ports:
            - containerPort: 80

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值