mirror of
https://github.com/kubevela/kubevela.git
synced 2026-08-18 20:17:04 +00:00
Feat: support parallel apply in deploy2env (#2938)
Signed-off-by: Yin Da <yd219913@alibaba-inc.com>
This commit is contained in:
@@ -16,9 +16,10 @@ spec:
|
||||
)
|
||||
|
||||
app: op.#ApplyEnvBindApp & {
|
||||
env: parameter.env
|
||||
policy: parameter.policy
|
||||
app: context.name
|
||||
env: parameter.env
|
||||
policy: parameter.policy
|
||||
parallel: parameter.parallel
|
||||
app: context.name
|
||||
// context.namespace indicates the namespace of the app
|
||||
namespace: context.namespace
|
||||
}
|
||||
@@ -27,5 +28,7 @@ spec:
|
||||
policy: *"" | string
|
||||
// +usage=Declare the name of the env in policy
|
||||
env: string
|
||||
// +usage=components are applied in parallel
|
||||
parallel: *false | bool
|
||||
}
|
||||
|
||||
|
||||
@@ -141,6 +141,33 @@
|
||||
}
|
||||
}
|
||||
|
||||
#ApplyComponentsToEnv: #Steps & {
|
||||
inputs: {
|
||||
decisions: [...#PlacementDecision]
|
||||
components: [...#Component]
|
||||
env: string
|
||||
waitHealthy: bool
|
||||
} @step(1)
|
||||
|
||||
outputs: #Steps & {
|
||||
for decision in inputs.decisions {
|
||||
for key, comp in inputs.components {
|
||||
"\(decision.cluster)-\(decision.namespace)-\(key)": #ApplyComponent & {
|
||||
value: comp
|
||||
if decision.cluster != _|_ {
|
||||
cluster: decision.cluster
|
||||
}
|
||||
if decision.namespace != _|_ {
|
||||
namespace: decision.namespace
|
||||
}
|
||||
waitHealthy: inputs.waitHealthy
|
||||
env: inputs.env
|
||||
} @step(1)
|
||||
}
|
||||
}
|
||||
} @step(2)
|
||||
}
|
||||
|
||||
#ApplyEnvBindApp: {
|
||||
#do: "steps"
|
||||
|
||||
@@ -148,6 +175,7 @@
|
||||
policy: string
|
||||
app: string
|
||||
namespace: string
|
||||
parallel: bool
|
||||
|
||||
env_: env
|
||||
policy_: policy
|
||||
@@ -158,21 +186,24 @@
|
||||
}
|
||||
} @step(1)
|
||||
|
||||
apply: #Steps & {
|
||||
for decision in prepare.outputs.decisions {
|
||||
for key, comp in prepare.outputs.components {
|
||||
"\(decision.cluster)-\(decision.namespace)-\(key)": #ApplyComponent & {
|
||||
value: comp
|
||||
if decision.cluster != _|_ {
|
||||
cluster: decision.cluster
|
||||
}
|
||||
if decision.namespace != _|_ {
|
||||
namespace: decision.namespace
|
||||
}
|
||||
env: env_
|
||||
} @step(2)
|
||||
}
|
||||
apply: #ApplyComponentsToEnv & {
|
||||
inputs: {
|
||||
decisions: prepare.outputs.decisions
|
||||
components: prepare.outputs.components
|
||||
env: env_
|
||||
waitHealthy: !parallel
|
||||
}
|
||||
} @step(2)
|
||||
|
||||
if parallel {
|
||||
wait: #ApplyComponentsToEnv & {
|
||||
inputs: {
|
||||
decisions: prepare.outputs.decisions
|
||||
components: prepare.outputs.components
|
||||
env: env_
|
||||
waitHealthy: true
|
||||
}
|
||||
} @step(3)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
#ApplyComponent: {
|
||||
#provider: "oam"
|
||||
#do: "component-apply"
|
||||
cluster: *"" | string
|
||||
env: *"" | string
|
||||
#provider: "oam"
|
||||
#do: "component-apply"
|
||||
cluster: *"" | string
|
||||
env: *"" | string
|
||||
waitHealthy: *true | bool
|
||||
value: {...}
|
||||
patch?: {...}
|
||||
...
|
||||
|
||||
@@ -106,7 +106,12 @@ func (p *provider) ApplyComponent(ctx wfContext.Context, v *value.Value, act wfT
|
||||
}
|
||||
}
|
||||
|
||||
if !healthy {
|
||||
waitHealthy, err := v.GetBool("waitHealthy")
|
||||
if err != nil {
|
||||
waitHealthy = true
|
||||
}
|
||||
|
||||
if waitHealthy && !healthy {
|
||||
act.Wait("wait healthy")
|
||||
}
|
||||
|
||||
|
||||
@@ -10,9 +10,10 @@ import (
|
||||
}
|
||||
template: {
|
||||
app: op.#ApplyEnvBindApp & {
|
||||
env: parameter.env
|
||||
policy: parameter.policy
|
||||
app: context.name
|
||||
env: parameter.env
|
||||
policy: parameter.policy
|
||||
parallel: parameter.parallel
|
||||
app: context.name
|
||||
// context.namespace indicates the namespace of the app
|
||||
namespace: context.namespace
|
||||
}
|
||||
@@ -22,5 +23,7 @@ template: {
|
||||
policy: *"" | string
|
||||
// +usage=Declare the name of the env in policy
|
||||
env: string
|
||||
// +usage=components are applied in parallel
|
||||
parallel: *false | bool
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user