From 8338a1f485f65bd5cd1300f6e379a3fef1bcd463 Mon Sep 17 00:00:00 2001 From: suwliang3 <105624645+suwliang3@users.noreply.github.com> Date: Tue, 27 Dec 2022 18:25:19 +0800 Subject: [PATCH] [addon istio] Modify the workflow of canary-rollback (#570) Signed-off-by: suwanliang_yewu Signed-off-by: suwanliang_yewu --- .../definitions/canary-rollout-wf-def.yaml | 0 .../definitions/rollback-wf-def.yaml | 26 +++------ .../addons/canary-rollout-istio/metadata.yaml | 18 ++++++ .../addons/canary-rollout-istio/readme.md | 56 +++++++++++++++++++ experimental/addons/istio/metadata.yaml | 3 +- experimental/addons/istio/readme.md | 2 +- 6 files changed, 84 insertions(+), 21 deletions(-) rename experimental/addons/{istio => canary-rollout-istio}/definitions/canary-rollout-wf-def.yaml (100%) rename experimental/addons/{istio => canary-rollout-istio}/definitions/rollback-wf-def.yaml (71%) create mode 100644 experimental/addons/canary-rollout-istio/metadata.yaml create mode 100644 experimental/addons/canary-rollout-istio/readme.md diff --git a/experimental/addons/istio/definitions/canary-rollout-wf-def.yaml b/experimental/addons/canary-rollout-istio/definitions/canary-rollout-wf-def.yaml similarity index 100% rename from experimental/addons/istio/definitions/canary-rollout-wf-def.yaml rename to experimental/addons/canary-rollout-istio/definitions/canary-rollout-wf-def.yaml diff --git a/experimental/addons/istio/definitions/rollback-wf-def.yaml b/experimental/addons/canary-rollout-istio/definitions/rollback-wf-def.yaml similarity index 71% rename from experimental/addons/istio/definitions/rollback-wf-def.yaml rename to experimental/addons/canary-rollout-istio/definitions/rollback-wf-def.yaml index 5188a4da..7cfa095f 100644 --- a/experimental/addons/istio/definitions/rollback-wf-def.yaml +++ b/experimental/addons/canary-rollout-istio/definitions/rollback-wf-def.yaml @@ -9,31 +9,21 @@ spec: template: |- import ("vela/op") - parameter: {...} + parameter: { + rollbackVersion: string + } comps: op.#Load compNames: [ for name, c in comps.value {name}] firstcomp: compNames[0] - rolloutObj: op.#Read & { - value: { - apiVersion: "standard.oam.dev/v1alpha1" - kind: "Rollout" - metadata: { - name: firstcomp - namespace: context.namespace - } - } - } - - _sourceRevision: rolloutObj.value.status.LastSourceRevision - apply: op.#ApplyComponent & { value: comps.value[firstcomp] patch: { traits: "rollout": { spec: { - targetRevisionName: _sourceRevision + // +patchStrategy=retainKeys + targetRevisionName: parameter.rollbackVersion } } @@ -45,7 +35,7 @@ spec: route: [{ destination: { host: firstcomp - subset: _sourceRevision + subset: parameter.rollbackVersion } weight: 100 }] @@ -59,8 +49,8 @@ spec: host: firstcomp subsets: [ { - name: _sourceRevision - labels: {"service.istio.io/canonical-name": _sourceRevision} + name: parameter.rollbackVersion + labels: {"service.istio.io/canonical-name": parameter.rollbackVersion} }, ] } diff --git a/experimental/addons/canary-rollout-istio/metadata.yaml b/experimental/addons/canary-rollout-istio/metadata.yaml new file mode 100644 index 00000000..dc019c61 --- /dev/null +++ b/experimental/addons/canary-rollout-istio/metadata.yaml @@ -0,0 +1,18 @@ +name: canary-rollout-istio +version: 1.0.2 +description: Enable service mash and managing triffic shiffting in workflow. +icon: https://github.com/istio/istio/raw/master/logo/istio-bluelogo-whitebackground-unframed.svg +url: https://istio.io/ + +tags: +- service-mesh +- rollout + +deployTo: + control_plane: true + runtime_cluster: true + +dependencies: +- name: istio +- name: rollout + diff --git a/experimental/addons/canary-rollout-istio/readme.md b/experimental/addons/canary-rollout-istio/readme.md new file mode 100644 index 00000000..f4684f17 --- /dev/null +++ b/experimental/addons/canary-rollout-istio/readme.md @@ -0,0 +1,56 @@ +# Canary Rollout with Istio + +This addon provides istio support for vela rollout, it just adds two definitions and depends on vela-rollout and istio addons. + +## Directory Structure +```shell +. +├── definitions // contains the X-Definition yaml/cue files. These file will be rendered as KubeVela Component in `template.yaml` +├── metadata.yaml // addon metadata information. +├── readme.md +``` + +## Quick start +### Install vela canary-rollout-istio addon +```shell +vela addon enable canary-rollout-istio +``` +For offline install please use +```shell +cd ~/experimental/addons +vela addon enable canary-rollout-istio/ +``` +### Verify installs +Check the deployment status of the application through `vela status :` +```shell +$ vela status addon-canary-rollout-istio -n vela-system +About: + + Name: addon-canary-rollout-istio + Namespace: vela-system + Created at: 2022-12-26 15:34:28 +0800 CST + Status: running + +Workflow: + + mode: DAG-DAG + finished: true + Suspend: false + Terminated: false + Steps + - id: yisdqy3lx7 + name: deploy-deploy-addon-to-all-clusters + type: deploy + phase: succeeded +``` +When we see that the `finished` field in Workflow is `true` and the Status is `running`, it means that the entire application is delivered successfully. + +If status shows as rendering or healthy as false, it means that the application has either failed to deploy or is still being deployed. Please proceed according to the information returned in `kubectl get application -o yaml`. + +You can also view WorkflowStepDefinition list by using the following command: +```shell +$ vela def list |& grep canary-roll +canary-rollback WorkflowStepDefinition vela-system canary-rollout-istio +canary-rollout WorkflowStepDefinition vela-system canary-rollout-istio +``` + diff --git a/experimental/addons/istio/metadata.yaml b/experimental/addons/istio/metadata.yaml index 3baa881e..2b2ccfde 100644 --- a/experimental/addons/istio/metadata.yaml +++ b/experimental/addons/istio/metadata.yaml @@ -1,12 +1,11 @@ name: istio -version: 1.0.1 +version: 1.0.2 description: Enable service mash and managing triffic shiffting in workflow. icon: https://github.com/istio/istio/raw/master/logo/istio-bluelogo-whitebackground-unframed.svg url: https://istio.io/ tags: - service-mesh -- rollout deployTo: control_plane: true diff --git a/experimental/addons/istio/readme.md b/experimental/addons/istio/readme.md index a4920223..896bdaba 100644 --- a/experimental/addons/istio/readme.md +++ b/experimental/addons/istio/readme.md @@ -1,6 +1,6 @@ # Istio -This addon provides istio support for vela rollout. +This addon provides istio for service mesh. ## Directory Structure ```shell