kubernetes scheduling for expensive resources

﹥>﹥吖頭↗ 提交于 2019-12-08 03:52:23

Using labels and label selectors for your nodes is right. But you need to use NodeAffinity on your pods.

Something like this:

apiVersion: v1
kind: Pod
metadata:
  name: run-with-gpu
spec:
  affinity:
    nodeAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
        nodeSelectorTerms:
        - matchExpressions:
          - key: kubernetes.io/node-type
            operator: In
            values:
            - gpu
  containers:
  - name: your-gpu-workload
    image: mygpuimage

Also, attach the label to your GPU nodes:

$ kubectl label nodes <node-name> kubernetes.io/node-type=gpu
Todoy

You can use labels and label selectors for this. kubernates docs

Update: example

apiVersion: v1
kind: Pod
metadata:
  name: with-gpu-antiAffinity
spec:
  affinity:
    podAntiAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
      - weight: 100
        podAffinityTerm:
          labelSelector:
            matchExpressions:
            - key: resources
              operator: In
              values:
              - cpu-only
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!