Scheduling

Volcano supports Kubernetes native scheduling. You can use nodeAffinity for scheduling. The following example uses forcible node affinity for scheduling. For more information about the nodeAffinity field, see official Kubernetes documentation.

  • Add the following fields in bold to the YAML file of VolcanoJob:
    apiVersion: batch.volcano.sh/v1alpha1  
    kind: Job                         
    metadata:
      name: mindx-test
      labels:
    ...
    spec:
    ...
      maxRetry: 3
      queue: default
      tasks:
      - name: "default-test"
        replicas: 1 
        template:
          metadata:
            labels:
    ...
          spec:
            affinity:      # Add the following fields in bold.
              nodeAffinity:                             # Node affinity configuration
                requiredDuringSchedulingIgnoredDuringExecution: 
                  nodeSelectorTerms:                    # Node selection list
                    - matchExpressions:
                        - key: aaa               # Match the node whose label key is aaa and value is yyy.
                          operator: In
                          values:
                            - yyy
                 podAntiAffinity:
                   requiredDuringSchedulingIgnoredDuringExecution:
    ...
              nodeSelector:
                host-arch: huawei-arm
    ...
  • Add the following fields in bold to the YAML file of AscendJob:
    apiVersion: mindxdl.gitee.com/v1
    kind: AscendJob
    metadata:
      name: test-2
    ...
    spec:
      schedulerName: volcano  
      runPolicy:
        schedulingPolicy:   
          minAvailable: 2
          queue: default
      successPolicy: AllWorkers
      replicaSpecs:
        Master:
          replicas: 1
          restartPolicy: Never
          template:
            metadata:
              labels:
    ...
            spec:
              affinity:   # New field
                nodeAffinity:                           # Node affinity configuration
                  requiredDuringSchedulingIgnoredDuringExecution: 
                    nodeSelectorTerms:                  # Node selection list
                      - matchExpressions:
                        - key: aaa               # Match the node whose label key is aaa and value is yyy.
                          operator: In
                          values:
                            - yyy
              nodeSelector:
                host-arch: huawei-arm
    ...

    You can run the kubectl get node --show-labels command to query the node label. In the LABELS field, the value before the equal sign (=) is the label key, and the value after the equal sign (=) is the label value, for example, aaa = yyy.