github.com/oam-dev/kubevela@v1.9.11/docs/examples/workflow/definition.yaml (about)

     1  apiVersion: core.oam.dev/v1beta1
     2  kind: WorkflowStepDefinition
     3  metadata:
     4    name: apply-with-ip
     5  spec:
     6    schematic:
     7      cue:
     8        template: |
     9          import ("vela/op")
    10          parameter: {
    11             component: string
    12             prefixIP: string
    13          }
    14  
    15          // load component from application
    16          load: op.#Load
    17  
    18          // apply workload to kubernetes cluster
    19          apply: op.#ApplyComponent & {
    20             value: load.value[parameter.component] & {
    21                  properties: serverIP: parameter.prefixIP
    22             }
    23          }
    24  
    25          // wait until workload.status equal "Running"
    26          wait: op.#ConditionalWait & {
    27             continue: apply.output.status.phase =="Running"
    28          }
    29  ---
    30  apiVersion: core.oam.dev/v1beta1
    31  kind: WorkflowStepDefinition
    32  metadata:
    33    name: custom-apply-component
    34  spec:
    35    schematic:
    36      cue:
    37        template: |
    38          import ("vela/op")
    39          parameter: {
    40             component: string
    41          }
    42  
    43          // load component from application
    44          load: op.#Load
    45  
    46          // apply workload to kubernetes cluster
    47          apply: op.#ApplyComponent & {
    48              value: load.value[parameter.component]
    49          }
    50  
    51          // wait until workload.status equal "Running"
    52          wait: op.#ConditionalWait & {
    53             continue: apply.output.status.phase =="Running"
    54          }
    55  
    56          // export podIP
    57          myIP: apply.output.status.podIP
    58  ---
    59  apiVersion: core.oam.dev/v1beta1
    60  kind: ComponentDefinition
    61  metadata:
    62    name: singleton-server
    63    annotations:
    64      definition.oam.dev/description: "singleton-server is Pod"
    65  spec:
    66    workload:
    67      definition:
    68        apiVersion: v1
    69        kind: Pod
    70    schematic:
    71      cue:
    72        template: |
    73          parameter: {
    74            version: *"1.14.2" | string
    75            serverIP?: string
    76          }
    77          output: {
    78            apiVersion: "v1"
    79            kind: "Pod"
    80            metadata: {
    81              labels: app: "nginx"
    82              name: context.name
    83            }
    84            spec:{
    85              containers:[{
    86                  name: "nginx"
    87                  image: "nginx:"+parameter.version
    88                  ports: [{containerPort: 80}]
    89                  if parameter.serverIP!=_|_{
    90                      env: [{name: "PrefixIP",value: parameter.serverIP}]
    91                  }
    92              }]
    93            }
    94          }