diff --git a/charts/vela-core/README.md b/charts/vela-core/README.md index 98aa01ed2..61331a236 100644 --- a/charts/vela-core/README.md +++ b/charts/vela-core/README.md @@ -97,6 +97,7 @@ helm install --create-namespace -n vela-system kubevela kubevela/vela-core --wai | `featureGates.gzipResourceTracker` | if enabled, resourceTracker will be compressed using gzip before being stored | `false` | | `featureGates.zstdResourceTracker` | if enabled, resourceTracker will be compressed using zstd before being stored. It is much faster and more efficient than gzip. If both gzip and zstd are enabled, zstd will be used. | `false` | | `featureGates.applyOnce` | if enabled, the apply-once feature will be applied to all applications, no state-keep and no resource data storage in ResourceTracker | `false` | +| `featureGates.multiStageComponentApply` | if enabled, the multiStageComponentApply feature will be combined with the stage field in TraitDefinition to complete the multi-stage apply. | `false` | ### MultiCluster parameters diff --git a/charts/vela-core/templates/kubevela-controller.yaml b/charts/vela-core/templates/kubevela-controller.yaml index 74c0694af..0ac3ff1e1 100644 --- a/charts/vela-core/templates/kubevela-controller.yaml +++ b/charts/vela-core/templates/kubevela-controller.yaml @@ -221,6 +221,7 @@ spec: - "--feature-gates=GzipResourceTracker={{- .Values.featureGates.gzipResourceTracker | toString -}}" - "--feature-gates=ZstdResourceTracker={{- .Values.featureGates.zstdResourceTracker | toString -}}" - "--feature-gates=ApplyOnce={{- .Values.featureGates.applyOnce | toString -}}" + - "--feature-gates=MultiStageComponentApply= {{- .Values.featureGates.multiStageComponentApply | toString -}}" {{ if .Values.authentication.enabled }} {{ if .Values.authentication.withUser }} - "--authentication-with-user" diff --git a/charts/vela-core/values.yaml b/charts/vela-core/values.yaml index bb48e3783..8c8d37f23 100644 --- a/charts/vela-core/values.yaml +++ b/charts/vela-core/values.yaml @@ -113,11 +113,13 @@ optimize: ##@param featureGates.gzipResourceTracker if enabled, resourceTracker will be compressed using gzip before being stored ##@param featureGates.zstdResourceTracker if enabled, resourceTracker will be compressed using zstd before being stored. It is much faster and more efficient than gzip. If both gzip and zstd are enabled, zstd will be used. ##@param featureGates.applyOnce if enabled, the apply-once feature will be applied to all applications, no state-keep and no resource data storage in ResourceTracker +##@param featureGates.multiStageComponentApply if enabled, the multiStageComponentApply feature will be combined with the stage field in TraitDefinition to complete the multi-stage apply. featureGates: enableLegacyComponentRevision: false gzipResourceTracker: false zstdResourceTracker: false applyOnce: false + multiStageComponentApply: false ## @section MultiCluster parameters diff --git a/docs/examples/multi-stage-component-apply/README.md b/docs/examples/multi-stage-component-apply/README.md new file mode 100644 index 000000000..c933e10f6 --- /dev/null +++ b/docs/examples/multi-stage-component-apply/README.md @@ -0,0 +1,43 @@ +# MultiStageComponentApply + +This example shows how to enable MultiStageComponentApply, the MultiStageComponentApply feature will be combined with the stage field in TraitDefinition to complete the multi-stage apply. Currently, the stage field in TraitDefinition is an optional parameter, which provides `PreDispatch` and `PostDispatch`. + +## How to use multi-stage +> The future-gate is still in alpha stage, and it is recommended to use it only in short-term test clusters. + +The `MultiStageComponentApply` is not enabled by default, you need some extra works to use it. + +1. Add an args `--feature-gates=MultiStageComponentApply=ture` in KubeVela controller's deployment like: + +```yaml + spec: + containers: + - args: + - --feature-gates=MultiStageComponentApply=true + ... +``` + +2. Sometime, you have multi-stage apply requirements inside the component, and it is the `outputs` resource defined in the trait. In this case, you can use the `stage` with the value `PreDispatch` or `PostDispatch` like: + +```yaml + apiVersion: core.oam.dev/v1beta1 + kind: TraitDefinition + metadata: + annotations: + definition.oam.dev/description: Add storages on K8s pod for your workload which follows the pod spec in path 'spec.template'. + name: storage + namespace: vela-system + spec: + appliesToWorkloads: + - deployments.apps + - statefulsets.apps + - daemonsets.apps + - jobs.batch + podDisruptive: true + stage: PreDispatch + schematic: + cue: + template: | + ... +``` +