mirror of
https://github.com/kubevela/kubevela.git
synced 2026-08-18 03:56:36 +00:00
Fix: workflow example (#2323)
This commit is contained in:
@@ -11,17 +11,20 @@ spec:
|
||||
parameter: {
|
||||
component: string
|
||||
}
|
||||
load: op.#Load
|
||||
|
||||
apply: op.#ApplyComponent & {
|
||||
component: parameter.component
|
||||
value: load.value[parameter.component]
|
||||
}
|
||||
|
||||
workload: apply.output
|
||||
// wait until deployment ready
|
||||
wait: op.#ConditionalWait & {
|
||||
continue: apply.workload.status.readyReplicas == apply.workload.status.replicas && apply.workload.status.observedGeneration == apply.workload.metadata.generation
|
||||
continue: workload.status.readyReplicas == workload.status.replicas && workload.status.observedGeneration == workload.metadata.generation
|
||||
}
|
||||
|
||||
// export service ClusterIP
|
||||
clusterIP: apply.traits["service"].value.spec.clusterIP
|
||||
clusterIP: apply.outputs["service"].value.spec.clusterIP
|
||||
---
|
||||
apiVersion: core.oam.dev/v1beta1
|
||||
kind: WorkflowStepDefinition
|
||||
@@ -36,8 +39,10 @@ spec:
|
||||
parameter: {
|
||||
component: string
|
||||
}
|
||||
load: op.#Load
|
||||
|
||||
apply: op.#ApplyComponent & {
|
||||
component: parameter.component
|
||||
value: load.value[parameter.component]
|
||||
}
|
||||
|
||||
// wait redis ready
|
||||
@@ -67,10 +72,12 @@ spec:
|
||||
// 往三方配置中心apollo读取配置
|
||||
// config: op.#HTTPGet
|
||||
|
||||
load: op.#Load
|
||||
|
||||
apply: op.#ApplyComponent & {
|
||||
component: parameter.component
|
||||
value: load.value[parameter.component]
|
||||
// 给环境变量中注入BackendIP
|
||||
workload: patch: spec: template: spec: {
|
||||
patch: workload: spec: template: spec: {
|
||||
containers: [{
|
||||
// patchKey=name
|
||||
env: [{name: "BackendIP",value: parameter.backendIP}]
|
||||
@@ -78,9 +85,10 @@ spec:
|
||||
}
|
||||
}
|
||||
|
||||
workload: apply.output
|
||||
// wait until argo.rollout ready
|
||||
wait: op.#ConditionalWait & {
|
||||
continue: apply.workload.status.readyReplicas == apply.workload.status.replicas && apply.workload.status.observedGeneration == apply.workload.metadata.generation
|
||||
continue: workload.status.readyReplicas == workload.status.replicas && workload.status.observedGeneration == workload.metadata.generation
|
||||
}
|
||||
|
||||
message: {...}
|
||||
|
||||
@@ -12,18 +12,20 @@ spec:
|
||||
prefixIP?: string
|
||||
}
|
||||
|
||||
load: op.#Load
|
||||
|
||||
// apply workload to kubernetes cluster
|
||||
apply: op.#ApplyComponent & {
|
||||
component: parameter.component
|
||||
value: load.value[parameter.component]
|
||||
}
|
||||
|
||||
// wait until workload.status equal "Running"
|
||||
wait: op.#ConditionalWait & {
|
||||
continue: apply.status.phase =="Running"
|
||||
continue: apply.output.status.phase =="Running"
|
||||
}
|
||||
|
||||
// export podIP
|
||||
myIP: apply.status.podIP
|
||||
myIP: apply.output.status.podIP
|
||||
---
|
||||
apiVersion: core.oam.dev/v1beta1
|
||||
kind: WorkflowStepDefinition
|
||||
|
||||
@@ -16,16 +16,16 @@ spec:
|
||||
workflow:
|
||||
steps:
|
||||
- name: deploy-server1
|
||||
type: apply-component
|
||||
type: custom-apply-component
|
||||
properties:
|
||||
component: "server1"
|
||||
outputs:
|
||||
- name: server1IP
|
||||
valueFrom: "myIP"
|
||||
- name: server1IP
|
||||
valueFrom: "myIP"
|
||||
- name: deploy-server2
|
||||
type: apply-with-ip
|
||||
inputs:
|
||||
- from: server1IP
|
||||
parameterKey: serverIP
|
||||
- from: server1IP
|
||||
parameterKey: prefixIP
|
||||
properties:
|
||||
component: "server2"
|
||||
|
||||
@@ -9,35 +9,28 @@ spec:
|
||||
import ("vela/op")
|
||||
parameter: {
|
||||
component: string
|
||||
serverIP?: string
|
||||
prefixIP: string
|
||||
}
|
||||
|
||||
// load component from application
|
||||
component: op.#Load & {
|
||||
component: parameter.component
|
||||
value: {}
|
||||
}
|
||||
load: op.#Load
|
||||
|
||||
// apply workload to kubernetes cluster
|
||||
apply: op.#Apply & {
|
||||
value: {
|
||||
component.value.workload
|
||||
metadata: name: parameter.component
|
||||
if parameter.serverIP!=_|_{
|
||||
spec: containers: [{env: [{name: "PrefixIP",value: parameter.serverIP}]}]
|
||||
}
|
||||
apply: op.#ApplyComponent & {
|
||||
value: load.value[parameter.component] & {
|
||||
properties: serverIP: parameter.prefixIP
|
||||
}
|
||||
}
|
||||
|
||||
// wait until workload.status equal "Running"
|
||||
wait: op.#ConditionalWait & {
|
||||
continue: apply.value.status.phase =="Running"
|
||||
continue: apply.output.status.phase =="Running"
|
||||
}
|
||||
---
|
||||
apiVersion: core.oam.dev/v1beta1
|
||||
kind: WorkflowStepDefinition
|
||||
metadata:
|
||||
name: apply-component
|
||||
name: custom-apply-component
|
||||
spec:
|
||||
schematic:
|
||||
cue:
|
||||
@@ -45,26 +38,23 @@ spec:
|
||||
import ("vela/op")
|
||||
parameter: {
|
||||
component: string
|
||||
prefixIP?: string
|
||||
}
|
||||
|
||||
// load component from application
|
||||
component: op.#Load & {
|
||||
component: parameter.component
|
||||
}
|
||||
load: op.#Load
|
||||
|
||||
// apply workload to kubernetes cluster
|
||||
apply: op.#ApplyComponent & {
|
||||
component: parameter.component
|
||||
value: load.value[parameter.component]
|
||||
}
|
||||
|
||||
// wait until workload.status equal "Running"
|
||||
wait: op.#ConditionalWait & {
|
||||
continue: apply.workload.status.phase =="Running"
|
||||
continue: apply.output.status.phase =="Running"
|
||||
}
|
||||
|
||||
// export podIP
|
||||
myIP: apply.workload.status.podIP
|
||||
myIP: apply.output.status.podIP
|
||||
---
|
||||
apiVersion: core.oam.dev/v1beta1
|
||||
kind: ComponentDefinition
|
||||
@@ -82,6 +72,7 @@ spec:
|
||||
template: |
|
||||
parameter: {
|
||||
version: *"1.14.2" | string
|
||||
serverIP?: string
|
||||
}
|
||||
output: {
|
||||
apiVersion: "v1"
|
||||
@@ -95,6 +86,9 @@ spec:
|
||||
name: "nginx"
|
||||
image: "nginx:"+parameter.version
|
||||
ports: [{containerPort: 80}]
|
||||
if parameter.serverIP!=_|_{
|
||||
env: [{name: "PrefixIP",value: parameter.serverIP}]
|
||||
}
|
||||
}]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user