volcano.sh/volcano@v1.9.0/example/integrations/argo/README.md (about)

     1  # Use Argo Workflow to integrate Volcano Job
     2  
     3  The Argo resource template allows users to create, delete, or update any type of Kubernetes resource (including CRDs). We can use the resource template to integrate Volcano Jobs into Argo Workflow, and use Argo to add job dependency management and DAG process control capabilities to volcano.
     4  
     5  ```markdown
     6  [argo examples:kubernetes resource](https://github.com/argoproj/argo/blob/master/examples/README.md#kubernetes-resources)
     7  ```
     8  
     9  ## Argo Workflow RBAC
    10  
    11  When the Argo Workflow is running, you need to specify serviceAccount for the Argo Workflow. If not specified, the default serviceAccount in the current namespace is used.
    12  
    13  ```yaml
    14  argo submit --serviceaccount <name>
    15  ```
    16  
    17  Installing argo will create serviceaccount **argo**, rolebinding **argo-binding** and role **argo-role** by default. If necessary, you can manually create clusterrole and clusterrolebinding.
    18  
    19  In order to successfully manage kubernetes resources, it is necessary to add the management authority of the operated resources for the role/clusterrole bound to serviceAccount.
    20  
    21  We add the management authority for all resources in volcano api groups(resources and verbs can be subdivided according to the actual situation,verbs **create** and **get** is must):
    22  
    23  ```yaml
    24  - apiGroups:
    25    - batch.volcano.sh
    26    resources:
    27    - "*"
    28    verbs:
    29    - "*"
    30  ```
    31  
    32  ## Create Volcano Job by Argo Workflow
    33  
    34  In order to ensure that Argo Workflow can manage the kubernetes resources created by itself, owner references need to be added for new resources:
    35  
    36  ```yaml
    37            ownerReferences:
    38            - apiVersion: argoproj.io/v1alpha1
    39              blockOwnerDeletion: true
    40              kind: Workflow
    41              name: "{{workflow.name}}"
    42              uid: "{{workflow.uid}}"
    43  ```
    44  
    45  Example of using Argo Workflow to create Volcano Job:
    46  
    47  ```yaml
    48  # in a workflow. The resource template type accepts any k8s manifest
    49  # (including CRDs) and can perform any kubectl action against it (e.g. create,
    50  # apply, delete, patch).
    51  apiVersion: argoproj.io/v1alpha1
    52  kind: Workflow
    53  metadata:
    54    generateName: volcano-job
    55  spec:
    56    entrypoint: nginx-tmpl
    57    serviceAccountName: argo        # specify the service account
    58    templates:
    59    - name: nginx-tmpl
    60      activeDeadlineSeconds: 120        # to limit the elapsed time for a workflow, you need set the variable activeDeadlineSeconds
    61      resource:        # indicates that this is a resource template
    62        action: create        # can be any kubectl action (e.g. create, delete, apply, patch)
    63        # The successCondition and failureCondition are optional expressions.
    64        # If failureCondition is true, the step is considered failed.
    65        # If successCondition is true, the step is considered successful.
    66        # They use kubernetes label selection syntax and can be applied against any field
    67        # of the resource (not just labels). Multiple AND conditions can be represented by comma
    68        # delimited expressions.
    69        # For more details: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/
    70        # argoexec will get the resource information by "kubectl get -o json -w resouce/name" and check if the conditions are match
    71        # Completed is the phase that all tasks of Job are completed
    72        # Failed is the phase that the job is restarted failed reached the maximum number of retries.
    73        # change the successCondition or failureCondition according to the actual situation
    74        successCondition: status.state.phase = Completed
    75        failureCondition: status.state.phase = Failed
    76        manifest: |						#put your kubernetes spec here
    77          apiVersion: batch.volcano.sh/v1alpha1
    78          kind: Job
    79          metadata:
    80            generateName: test-job-
    81            ownerReferences:
    82            - apiVersion: argoproj.io/v1alpha1
    83              blockOwnerDeletion: true
    84              kind: Workflow
    85              name: "{{workflow.name}}"
    86              uid: "{{workflow.uid}}"
    87          spec:
    88            minAvailable: 1
    89            schedulerName: volcano
    90            policies:
    91            - event: PodEvicted
    92              action: RestartJob
    93            plugins:
    94              ssh: []
    95              env: []
    96              svc: []
    97            maxRetry: 5
    98            queue: default
    99            tasks:
   100            - replicas: 2
   101              name: "default-nginx"
   102              template:
   103                metadata:
   104                  name: web
   105                spec:
   106                  containers:
   107                  - image: nginx:latest
   108                    imagePullPolicy: IfNotPresent
   109                    name: nginx
   110                    resources:
   111                      requests:
   112                        cpu: "100m"
   113                  restartPolicy: OnFailure
   114  ```
   115  
   116  Argo Workflow will create one Volcano Job.If the job is a long running job(like nginx process), you must set activeDeadlineSeconds for template otherwise Workflow will not enter the next step.
   117