Tutorials

Here is a simple example of how to use Volcano with CRD resources.

Step: 1

Create a queue named “test”.

  1. # kubectl create -f queue.yaml
  2. // queue.yaml
  3. apiVersion: scheduling.volcano.sh/v1beta1
  4. kind: Queue
  5. metadata:
  6. name: test
  7. spec:
  8. weight: 1
  9. reclaimable: false
  10. capability:
  11. cpu: 2

Step: 2

Create a VolcanoJob named “job-1”.

  1. # kubectl create -f vcjob.yaml
  2. // vcjob.yaml
  3. apiVersion: batch.volcano.sh/v1alpha1
  4. kind: Job
  5. metadata:
  6. name: job-1
  7. spec:
  8. minAvailable: 1
  9. schedulerName: volcano
  10. queue: test
  11. policies:
  12. - event: PodEvicted
  13. action: RestartJob
  14. tasks:
  15. - replicas: 1
  16. name: nginx
  17. policies:
  18. - event: TaskCompleted
  19. action: CompleteJob
  20. template:
  21. spec:
  22. containers:
  23. - command:
  24. - sleep
  25. - 10m
  26. image: nginx:latest
  27. name: nginx
  28. resources:
  29. requests:
  30. cpu: 1
  31. limits:
  32. cpu: 1
  33. restartPolicy: Never

Step: 3

Check the status of the custom job.

  1. # kubectl get vcjob job-1 -oyaml
  2. apiVersion: batch.volcano.sh/v1alpha1
  3. kind: Job
  4. metadata:
  5. creationTimestamp: "2020-01-18T12:59:37Z"
  6. generation: 1
  7. managedFields:
  8. - apiVersion: batch.volcano.sh/v1alpha1
  9. fieldsType: FieldsV1
  10. fieldsV1:
  11. f:spec:
  12. .: {}
  13. f:minAvailable: {}
  14. f:policies: {}
  15. f:queue: {}
  16. f:schedulerName: {}
  17. manager: kubectl
  18. operation: Update
  19. time: "2020-08-18T12:59:37Z"
  20. - apiVersion: batch.volcano.sh/v1alpha1
  21. fieldsType: FieldsV1
  22. fieldsV1:
  23. f:spec:
  24. f:tasks: {}
  25. f:status:
  26. .: {}
  27. f:minAvailable: {}
  28. f:running: {}
  29. f:state:
  30. .: {}
  31. f:lastTransitionTime: {}
  32. f:phase: {}
  33. manager: vc-controller-manager
  34. operation: Update
  35. time: "2020-08-18T12:59:45Z"
  36. name: job-1
  37. namespace: default
  38. resourceVersion: "850500"
  39. selfLink: /apis/batch.volcano.sh/v1alpha1/namespaces/default/jobs/job-1
  40. uid: 215409ec-7337-4abf-8bea-e6419defd688
  41. spec:
  42. minAvailable: 1
  43. policies:
  44. - action: RestartJob
  45. event: PodEvicted
  46. queue: test
  47. schedulerName: volcano
  48. tasks:
  49. - name: nginx
  50. policies:
  51. - action: CompleteJob
  52. event: TaskCompleted
  53. replicas: 1
  54. template:
  55. spec:
  56. containers:
  57. - command:
  58. - sleep
  59. - 10m
  60. image: nginx:latest
  61. name: nginx
  62. resources:
  63. limits:
  64. cpu: 1
  65. requests:
  66. cpu: 1
  67. status:
  68. minAvailable: 1
  69. running: 1
  70. state:
  71. lastTransitionTime: "2020-08-18T12:59:45Z"
  72. phase: Running

Step: 4

Check the status of PodGroup named “job-1”.

  1. # kubectl get podgroup job-1 -oyaml
  2. apiVersion: scheduling.volcano.sh/v1beta1
  3. kind: PodGroup
  4. metadata:
  5. creationTimestamp: "2020-08-18T12:59:37Z"
  6. generation: 5
  7. managedFields:
  8. - apiVersion: scheduling.volcano.sh/v1beta1
  9. fieldsType: FieldsV1
  10. fieldsV1:
  11. f:metadata:
  12. f:ownerReferences:
  13. .: {}
  14. k:{"uid":"215409ec-7337-4abf-8bea-e6419defd688"}:
  15. .: {}
  16. f:apiVersion: {}
  17. f:blockOwnerDeletion: {}
  18. f:controller: {}
  19. f:kind: {}
  20. f:name: {}
  21. f:uid: {}
  22. f:spec:
  23. .: {}
  24. f:minMember: {}
  25. f:minResources:
  26. .: {}
  27. f:cpu: {}
  28. f:queue: {}
  29. f:status: {}
  30. manager: vc-controller-manager
  31. operation: Update
  32. time: "2020-08-18T12:59:37Z"
  33. - apiVersion: scheduling.volcano.sh/v1beta1
  34. fieldsType: FieldsV1
  35. fieldsV1:
  36. f:status:
  37. f:conditions: {}
  38. f:phase: {}
  39. f:running: {}
  40. manager: vc-scheduler
  41. operation: Update
  42. time: "2020-08-18T12:59:45Z"
  43. name: job-1
  44. namespace: default
  45. ownerReferences:
  46. - apiVersion: batch.volcano.sh/v1alpha1
  47. blockOwnerDeletion: true
  48. controller: true
  49. kind: Job
  50. name: job-1
  51. uid: 215409ec-7337-4abf-8bea-e6419defd688
  52. resourceVersion: "850501"
  53. selfLink: /apis/scheduling.volcano.sh/v1beta1/namespaces/default/podgroups/job-1
  54. uid: ea5b4f87-b750-440b-a41a-5c9944a7ae43
  55. spec:
  56. minMember: 1
  57. minResources:
  58. cpu: "1"
  59. queue: test
  60. status:
  61. conditions:
  62. - lastTransitionTime: "2020-08-18T12:59:38Z"
  63. message: '1/0 tasks in gang unschedulable: pod group is not ready, 1 minAvailable.'
  64. reason: NotEnoughResources
  65. status: "True"
  66. transitionID: 606145d1-660f-4e01-850d-ed556cebc098
  67. type: Unschedulable
  68. - lastTransitionTime: "2020-08-18T12:59:45Z"
  69. reason: tasks in gang are ready to be scheduled
  70. status: "True"
  71. transitionID: 57e6ba9e-55cc-47ce-a37e-d8bddd99d54b
  72. type: Scheduled
  73. phase: Running
  74. running: 1

Step: 5

Check the status of queue “test”.

  1. # kubectl get queue test -oyaml
  2. apiVersion: scheduling.volcano.sh/v1beta1
  3. kind: Queue
  4. metadata:
  5. creationTimestamp: "2020-08-18T12:59:30Z"
  6. generation: 1
  7. managedFields:
  8. - apiVersion: scheduling.volcano.sh/v1beta1
  9. fieldsType: FieldsV1
  10. fieldsV1:
  11. f:spec:
  12. .: {}
  13. f:capability: {}
  14. f:reclaimable: {}
  15. f:weight: {}
  16. manager: kubectl
  17. operation: Update
  18. time: "2020-08-18T12:59:30Z"
  19. - apiVersion: scheduling.volcano.sh/v1beta1
  20. fieldsType: FieldsV1
  21. fieldsV1:
  22. f:spec:
  23. f:capability:
  24. f:cpu: {}
  25. f:status:
  26. .: {}
  27. f:running: {}
  28. f:state: {}
  29. manager: vc-controller-manager
  30. operation: Update
  31. time: "2020-08-18T12:59:39Z"
  32. name: test
  33. resourceVersion: "850474"
  34. selfLink: /apis/scheduling.volcano.sh/v1beta1/queues/test
  35. uid: b9c9ee54-5ef8-4784-9bec-7a665acb1fde
  36. spec:
  37. capability:
  38. cpu: 2
  39. reclaimable: false
  40. weight: 1
  41. status:
  42. running: 1
  43. state: Open