Files
kubevela/pkg/stdlib/pkgs/multicluster.cue
Somefive de81c24f42 Feat: support standalone style multi-cluster (#3223)
* Feat: ref component

Signed-off-by: Somefive <yd219913@alibaba-inc.com>

* Feat: support topology and override

Signed-off-by: Somefive <yd219913@alibaba-inc.com>

* Feat: add support for external policy and workflow

Signed-off-by: Somefive <yd219913@alibaba-inc.com>

* Feat: add admission control

Signed-off-by: Somefive <yd219913@alibaba-inc.com>

* Fix: disable cross namespace ref object

Signed-off-by: Somefive <yd219913@alibaba-inc.com>

* Chore: refactor

Signed-off-by: Somefive <yd219913@alibaba-inc.com>

* Feat: support labelSelector in ref-objects

Signed-off-by: Somefive <yd219913@alibaba-inc.com>

* Feat: add pre approve for deploy step

Signed-off-by: Somefive <yd219913@alibaba-inc.com>

* Chore: refactor

Signed-off-by: Somefive <yd219913@alibaba-inc.com>

* Fix: test

Signed-off-by: Somefive <yd219913@alibaba-inc.com>

* Feat: support comp/trait type in override policy even not used by prototype

Signed-off-by: Somefive <yd219913@alibaba-inc.com>

* Feat: support regex match for patch component name

Signed-off-by: Somefive <yd219913@alibaba-inc.com>

* Fix: labelSelector not work for cluster

Signed-off-by: Somefive <yd219913@alibaba-inc.com>

* Fix: ref workflow contains external policy

Signed-off-by: Somefive <yd219913@alibaba-inc.com>

* Fix: revision test

Signed-off-by: Somefive <yd219913@alibaba-inc.com>

* Feat: parallel apply components

Signed-off-by: Somefive <yd219913@alibaba-inc.com>

* Feat: add test for oam provider

Signed-off-by: Somefive <yd219913@alibaba-inc.com>

* Fix: service ref-comp & indirect trait ns

Signed-off-by: Somefive <yd219913@alibaba-inc.com>

* Fix: align namespace setting for chart

Signed-off-by: Somefive <yd219913@alibaba-inc.com>

* Fix: add strict unmarshal and reformat

Signed-off-by: Somefive <yd219913@alibaba-inc.com>

* Fix: merge with cluster rework

Signed-off-by: Somefive <yd219913@alibaba-inc.com>

* Feat: patch trait-def

Signed-off-by: Somefive <yd219913@alibaba-inc.com>

* Fix: apply components + load dynamic component

Signed-off-by: Somefive <yd219913@alibaba-inc.com>

* Fix: add test for loadPoliciesInOrder

Signed-off-by: Somefive <yd219913@alibaba-inc.com>

* Feat: add test for open merge

Signed-off-by: Somefive <yd219913@alibaba-inc.com>

* Fix: reformat & add test for step generator

Signed-off-by: Somefive <yd219913@alibaba-inc.com>

* Fix: add test for parse override policy related defs

Signed-off-by: Somefive <yd219913@alibaba-inc.com>

* Fix: add test for multicluster provider (expandTopology and overrideConfiguration)

Signed-off-by: Somefive <yd219913@alibaba-inc.com>

* Fix: add admission test

Signed-off-by: Somefive <yd219913@alibaba-inc.com>

* Fix: revert trait status pass in component status

Signed-off-by: Somefive <yd219913@alibaba-inc.com>

* Fix: add test for dependency in workflowstep & standalone multicluster test

Signed-off-by: Somefive <yd219913@alibaba-inc.com>

* Fix: add check for ref and steps in WorkflowStep & enhance ref-objects scheme check

Signed-off-by: Somefive <yd219913@alibaba-inc.com>
2022-03-07 10:21:00 +08:00

265 lines
4.6 KiB
CUE

#Placement: {
clusterSelector?: {
labels?: [string]: string
name?: string
}
namespaceSelector?: {
labels?: [string]: string
name?: string
}
}
#PlacementDecision: {
namespace?: string
cluster?: string
}
#Component: {
name?: string
type?: string
properties?: {...}
traits?: [...{
type: string
disable?: bool
properties: {...}
}]
externalRevision?: string
}
#ReadPlacementDecisions: {
#provider: "multicluster"
#do: "read-placement-decisions"
inputs: {
policyName: string
envName: string
}
outputs: {
decisions?: [...#PlacementDecision]
}
}
#MakePlacementDecisions: {
#provider: "multicluster"
#do: "make-placement-decisions"
inputs: {
policyName: string
envName: string
placement: #Placement
}
outputs: {
decisions: [...#PlacementDecision]
}
}
#PatchApplication: {
#provider: "multicluster"
#do: "patch-application"
inputs: {
envName: string
patch?: components: [...#Component]
selector?: components: [...string]
}
outputs: {...}
...
}
#LoadEnvBindingEnv: #Steps & {
inputs: {
env: string
policy: string
}
loadPolicies: oam.#LoadPolicies @step(1)
policy_: string
if inputs.policy == "" {
envBindingPolicies: [ for k, v in loadPolicies.value if v.type == "env-binding" {k}]
policy_: envBindingPolicies[0]
}
if inputs.policy != "" {
policy_: inputs.policy
}
loadPolicy: loadPolicies.value["\(policy_)"]
envMap: {
for ev in loadPolicy.properties.envs {
"\(ev.name)": ev
}
...
}
envConfig_: envMap["\(inputs.env)"]
outputs: {
policy: policy_
envConfig: envConfig_
}
}
#PrepareEnvBinding: #Steps & {
inputs: {
env: string
policy: string
}
env_: inputs.env
policy_: inputs.policy
loadEnv: #LoadEnvBindingEnv & {
inputs: {
env: env_
policy: policy_
}
} @step(1)
envConfig: loadEnv.outputs.envConfig
placementDecisions: #MakePlacementDecisions & {
inputs: {
policyName: loadEnv.outputs.policy
envName: env_
placement: envConfig.placement
}
} @step(2)
patchedApp: #PatchApplication & {
inputs: {
envName: env_
if envConfig.selector != _|_ {
selector: envConfig.selector
}
if envConfig.patch != _|_ {
patch: envConfig.patch
}
}
} @step(3)
outputs: {
components: patchedApp.outputs.spec.components
decisions: placementDecisions.outputs.decisions
}
}
#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"
env: string
policy: string
app: string
namespace: string
parallel: bool
env_: env
policy_: policy
prepare: #PrepareEnvBinding & {
inputs: {
env: env_
policy: policy_
}
} @step(1)
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)
}
}
#ListClusters: {
#provider: "multicluster"
#do: "list-clusters"
outputs: {
clusters: [...string]
}
}
#ExpandTopology: {
#provider: "multicluster"
#do: "expand-topology"
inputs: {
policies: [...{...}]
}
outputs: {
decisions: [...#PlacementDecision]
}
}
#OverrideConfiguration: {
#provider: "multicluster"
#do: "override-configuration"
inputs: {
policies: [...{...}]
components: [...#Component]
}
outputs: {
components: [...#Component]
}
}
#HandleDeployPolicies: #Steps & {
inputs: {
policies: [...{...}]
components: [...#Component]
}
_inputs: inputs
expandTopology: #ExpandTopology & {
inputs: {
policies: _inputs.policies
}
} @step(1)
overrideConfiguration: #OverrideConfiguration & {
inputs: {
policies: _inputs.policies
components: _inputs.components
}
} @step(2)
outputs: {
decisions: expandTopology.outputs.decisions
components: overrideConfiguration.outputs.components
}
}