Component Replication
To replicate component, replication
policy is added as a built-in policy. It can be only used together with deploy
workflow step. If using replication
policy in deploy
workflow step, a new field context.replicaKey
will be added to when rendering the component. You can use this field to dispatch the resources to the same cluster with different replicaKey
.
note
policy is only supported in KubeVela version 1.6.0+.
context.replicaKey
is always used in metadata.name
in ComponentDefinition or TraitDefinition when dispatching resources to avoid name conflict. We’ll see it later in the example.
The following ComponentDefinition is an example which make use of replication
policy. It uses context.replicaKey
to add suffixes to resource names.
Copy the definition to file replica-webservice.cue
and apply the definition:
Then application will dispatch two deployments and two services:
There are three policies that can use in deploy
step: topology
, and replication
. They can be used together to both replicate component and dispatch them to different clusters. Here is the rules when they are use together:
- The applying order of policies is
topology
->override
->replication
. More information can be found in Multi cluster Applicationoverride
modifies the component properties. If not used, no properties will be changed.replication
will turn one component into multiple ones.
note