快速开始

最近更新于 Jul 31, 2021

这里演示的是一个如何使用Volcano CRD资源的简单例子。

步骤1:

创建一个名为“test”的自定义队列。

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

步骤2:

创建一个名为“job-1”的Volcano Job。

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

步骤3:

检查自定义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

步骤4:

检查名为”job-1“的PodGroup的状态

  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

步骤5:

检查队列“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