Files
kubevela/docs/examples/workflow
Jian.Li 6cbdbe84b2 Refactor application code to make it run as Dag workflow (#2236)
* Refactor: remove use of AppConfig in AppRevision

* Refactor: remove insert secret and configmap

* Feat(workflow): upgrade

* Fix(conflict): workflow cherry

* Feat(workflow): support DAG mode

* Feat(workflow): prepare steps in step

* Feat(tools): random string

* Fix(rand): gosec weak random

* Fix(ci): test passing

* Feat(workflow): generate steps

* Fix: fix rebase from master

* Fix: fix workflow ut

* Feat(test): add test cases

* Fix: fix lint and rebase from master

* Refactor: application code

* Fix: fix ci lint

* Fix: make code reviewable

* Fix: workflow_test.go

* Feat: collect services

* Fix(ci): unit tests

* Feat: make one

* Test: application with input/output and workflow

* Fix: trace test

* Fix: update step index falied

* Feat: refactor op.#Load

* Fix: delete dead code

* Refactor: op.xxx

* Fix: patch component

* Test: add generator test

* Fix: add license

* Fix: pending e2e plugin test

* Fix: disable test/e2e-test

* Fix: patch by script

Co-authored-by: 天元 <jianbo.sjb@alibaba-inc.com>
Co-authored-by: FogDong <dongtianxin.tx@alibaba-inc.com>
2021-09-12 10:12:46 +08:00
..
2021-08-09 10:27:18 +08:00
2021-08-11 16:30:16 +08:00
2021-08-11 16:30:16 +08:00
2021-08-11 16:30:16 +08:00

Install Definitions

kubectl apply -f definition.yaml

Check Component and Workflow definitions:

 kubectl get componentDefinition
 kubectl get workflowstep

Output:

 NAME              AGE
 singleton-server   49s

 NAME              AGE
 apply-component   49s
 apply-with-ip      49s

Begin The Workflow Demo

This Demo is to apply component in the cluster in order by workflow, and inject the IP of the previous pod into the environment variables of the next Pod.

  1. Apply Application:

    kubectl apply -f app.yaml
    
  2. Check workflow status in Application:

    kubectl get -f app.yaml
    

    Output:

    ...
    status:  
      workflow:
        appRevision: application-sample-v1
        contextBackend:
          apiVersion: v1
          kind: ConfigMap
          name: workflow-application-sample-v1
          uid: 783769c9-0fe1-4686-8528-94ce2887a5f8
        stepIndex: 2
        steps:
        - name: deploy-server1
          phase: succeeded
          resourceRef:
            apiVersion: ""
            kind: ""
            name: ""
          type: apply
        - name: deploy-server2
          phase: succeeded
          resourceRef:
            apiVersion: ""
            kind: ""
            name: ""
          type: apply
    
    
  3. Check Resource in cluster.

    kubectl get pods
    

    Output:

    NAME       READY   STATUS    RESTARTS   AGE
    server1    1/1     Running   0          15s
    server2    1/1     Running   0          18s
    

    This means the resource has been rendered correctly.

  4. Check server2 Environment variable

    kubectl exec server2 -- env|grep PrefixIP
    

    Output:

    PrefixIP=10.244.0.22
    

WorkflowStep Definition Introduction.

WorkflowStep consists of a series of actions, you can describe the actions to be done step by step in WorkflowStep Definition.

  1. op.#Load Get component schema from workflow context
  2. op.#Apply Apply schema to cluster.
  3. op.#ConditionalWait Condition waits until continue is true.