-
Notifications
You must be signed in to change notification settings - Fork 1.8k
RHDEVDOCS-5562: Creating content for Using Argo Rollouts to route traffic by OpenShift Routes #72104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
bscott-rh
merged 1 commit into
openshift:gitops-docs-main
from
Dhruv-Soni11:RHDEVDOCS-5562
Jun 20, 2024
Merged
RHDEVDOCS-5562: Creating content for Using Argo Rollouts to route traffic by OpenShift Routes #72104
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| // Module included in the following assemblies: | ||
| // | ||
| // * argo_rollouts/using-argo-rollouts-for-progressive-deployment-delivery.adoc | ||
| :_mod-docs-content-type: CONCEPT | ||
| [id="routing-traffic-by-using-argo-rollouts_{context}"] | ||
| = Routing traffic by using Argo Rollouts | ||
|
|
||
| You can progressively route a subset of user traffic to a new application version by using Argo Rollouts and its traffic-splitting mechanisms. This allows you to test if the application is deployed and working. | ||
|
|
||
| With Openshift Routes, you can configure Argo Rollouts to reduce or increase the amount of traffic by directing it to various applications in a cluster environment based on your requirements. | ||
|
|
||
| You can use OpenShift Routes to split traffic between two application versions: | ||
|
|
||
| * *Canary version*: A new version of an application where you gradually route the traffic. | ||
| * *Stable version*: The current version of an application. After the canary version is stable and has all the user traffic directed to it, it becomes the new stable version. The previous stable version is discarded. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
276 changes: 276 additions & 0 deletions
276
modules/gitops-configure-rollout-route-traffic-using-openshift-routes.adoc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,276 @@ | ||
| // Module included in the following assemblies: | ||
| // | ||
| // * argo_rollouts/using-argo-rollouts-for-progressive-deployment-delivery.adoc | ||
|
|
||
| :_mod-docs-content-type: PROCEDURE | ||
| [id="gitops-configure-rollout-route-traffic-using-openshift-routes_{context}"] | ||
| = Configuring Argo Rollouts to route traffic by using OpenShift Routes | ||
|
|
||
| You can use OpenShift Routes to configure Argo Rollouts to create routes, rollouts, and services. | ||
|
|
||
| The following example procedure creates a route, a rollout, and two services. It then gradually routes an increasing percentage of traffic to a canary version of the application before that canary state is marked as successful and becomes the new stable version. | ||
|
|
||
| .Prerequisites | ||
|
|
||
| * You have logged in to the {OCP} cluster as an administrator. | ||
| * You have installed the {gitops-title} on your {OCP} cluster. | ||
| * You have installed Argo Rollouts on your {OCP} cluster. For more information, see "Creating a RolloutManager custom resource". | ||
Dhruv-Soni11 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| * You have installed the {gitops-title} CLI on your system. For more information, see "Installing the {gitops-shortname} CLI". | ||
| * You have installed the Argo Rollouts CLI on your system. For more information, see "Argo Rollouts CLI overview". | ||
|
|
||
| .Procedure | ||
|
|
||
| . Create a `Route` object. | ||
| .. In the *Administrator* perspective of the web console, click *Networking* -> *Routes*. | ||
| .. Click *Create Route*. | ||
| .. On the *Create Route* page, click *YAML view* and add the following snippet: | ||
| The following example creates a route called `rollouts-demo-route`: | ||
| + | ||
| [source,yaml] | ||
| ---- | ||
| apiVersion: route.openshift.io/v1 | ||
| kind: Route | ||
| metadata: | ||
| name: rollouts-demo-route | ||
| spec: | ||
| port: | ||
| targetPort: http #<1> | ||
| tls: #<2> | ||
| insecureEdgeTerminationPolicy: Redirect | ||
| termination: edge | ||
| to: | ||
| kind: Service | ||
| name: argo-rollouts-stable-service #<3> | ||
| weight: 100 # <4> | ||
|
|
||
| alternateBackends: | ||
| - kind: Service | ||
| name: argo-rollouts-canary-service #<5> | ||
| weight: 0 #<6> | ||
| ---- | ||
| <1> Specifies the name of the port used by the application for running inside the container. | ||
| <2> Specifies the TLS configuration used to secure the route. | ||
| <3> The name of the targeted stable service. | ||
| <4> This field is automatically modified to stable weight by Route Rollout plugin. | ||
| <5> The name of the targeted canary service. | ||
| <6> This field is automatically modified to canary weight by Route Rollout plugin. | ||
Dhruv-Soni11 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| + | ||
| .. Click *Create* to create the route. It is then displayed on the *Routes* page. | ||
| . Create the services, canary and stable, to be referenced in the route. | ||
| .. In the *Administrator* perspective of the web console, click *Networking* -> *Services*. | ||
| .. Click *Create Service*. | ||
| .. On the *Create Service* page, click *YAML view* and add the following snippet: | ||
| The following example creates a canary service called `argo-rollouts-canary-service`. Canary traffic is directed to this service. | ||
| + | ||
| [source,yaml] | ||
| ---- | ||
| apiVersion: v1 | ||
| kind: Service | ||
| metadata: | ||
| name: argo-rollouts-canary-service | ||
| spec: | ||
| ports: #<1> | ||
| - port: 80 | ||
| targetPort: http | ||
| protocol: TCP | ||
| name: http | ||
|
|
||
| selector: #<2> | ||
| app: rollouts-demo | ||
| ---- | ||
| <1> Specifies the name of the port used by the application for running inside the container. | ||
| <2> Ensure that the contents of the `selector` field are the same as in stable service and `Rollout` custom resource (CR). | ||
| + | ||
| [IMPORTANT] | ||
| ==== | ||
| Ensure that the name of the canary service specified in the `Route` object matches with the name of the canary service specified in the `Service` object. | ||
| ==== | ||
| .. Click *Create* to create the canary service. | ||
Dhruv-Soni11 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| + | ||
| Rollouts automatically update the created service with pod template hash of the canary `ReplicaSet`. For example, `rollouts-pod-template-hash: 7bf84f9696`. | ||
| .. Repeat these steps to create the stable service: | ||
| The following example creates a stable service called `argo-rollouts-stable-service`. Stable traffic is directed to this service. | ||
| + | ||
| [source,yaml] | ||
| ---- | ||
| apiVersion: v1 | ||
| kind: Service | ||
| metadata: | ||
| name: argo-rollouts-stable-service | ||
| spec: | ||
| ports: #<1> | ||
| - port: 80 | ||
| targetPort: http | ||
| protocol: TCP | ||
| name: http | ||
|
|
||
| selector: #<2> | ||
| app: rollouts-demo | ||
| ---- | ||
| <1> Specifies the name of the port used by the application for running inside the container. | ||
| <2> Ensure that the contents of the `selector` field are the same as in canary service and `Rollout` CR . | ||
| + | ||
Dhruv-Soni11 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| [IMPORTANT] | ||
| ==== | ||
| Ensure that the name of the stable service specified in the `Route` object matches with the name of the stable service specified in the `Service` object. | ||
| ==== | ||
Dhruv-Soni11 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| .. Click *Create* to create the stable service. | ||
| + | ||
| Rollouts automatically update the created service with pod template hash of the stable `ReplicaSet`. For example, `rollouts-pod-template-hash: 1b6a7733`. | ||
| . Create the `Rollout` CR to reference the `Route` and `Service` objects. | ||
| .. In the *Administrator* perspective of the web console, go to *Operators* -> *Installed Operators* -> *Red Hat OpenShift GitOps* -> *Rollout*. | ||
| .. On the *Create Rollout* page, click *YAML view* and add the following snippet: | ||
| The following example creates a `Rollout` CR called `rollouts-demo`: | ||
| + | ||
| [source,yaml] | ||
| ---- | ||
| apiVersion: argoproj.io/v1alpha1 | ||
| kind: Rollout | ||
| metadata: | ||
| name: rollouts-demo | ||
| spec: | ||
| template: #<1> | ||
| metadata: | ||
| labels: | ||
| app: rollouts-demo | ||
| spec: | ||
| containers: | ||
Dhruv-Soni11 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| - name: rollouts-demo | ||
| image: argoproj/rollouts-demo:blue | ||
| ports: | ||
| - name: http | ||
| containerPort: 8080 | ||
| protocol: TCP | ||
| resources: | ||
| requests: | ||
| memory: 32Mi | ||
| cpu: 5m | ||
|
|
||
| revisionHistoryLimit: 2 | ||
| replicas: 5 | ||
| strategy: | ||
| canary: | ||
| canaryService: argo-rollouts-canary-service #<2> | ||
| stableService: argo-rollouts-stable-service #<3> | ||
| trafficRouting: | ||
| plugins: | ||
| argoproj-labs/openshift: | ||
| routes: | ||
| - rollouts-demo-route #<4> | ||
| steps: #<5> | ||
| - setWeight: 30 | ||
| - pause: {} | ||
| - setWeight: 60 | ||
| - pause: {} | ||
| selector: #<6> | ||
| matchLabels: | ||
| app: rollouts-demo | ||
| ---- | ||
| <1> Specifies the pods that are to be created. | ||
| <2> This value must match the name of the created canary `Service`. | ||
| <3> This value must match the name of the created stable `Service`. | ||
| <4> This value must match the name of the created `Route` CR. | ||
| <5> Specify the steps for the rollout. This example gradually routes 30%, 60%, and 100% of traffic to the canary version. | ||
| <6> Ensure that the contents of the `selector` field are the same as in canary and stable service. | ||
| .. Click *Create*. | ||
| + | ||
| After the Rollout has been created, you can verify that the *Status* field of the Rollout shows *Phase: Healthy*. | ||
| .. In the *RolloutManager* tab, under the *RolloutManagers* section, verify that the *Status* field of the *RolloutManager* instance shows as *Phase: Available*. | ||
Dhruv-Soni11 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| . Verify that the route is directing 100% of the traffic towards the stable version of the application. | ||
| + | ||
| [NOTE] | ||
| ==== | ||
| When the first instance of the `Rollout` resource is created, the rollout regulates the amount of traffic to be directed towards the stable and canary application versions. In the initial instance, the creation of the `Rollout` resource routes all of the traffic towards the stable version of the application and skips the part where the traffic is sent to the canary version. | ||
| ==== | ||
| .. Go to *Networking* -> *Routes* and look for the `Route` resource you want to verify. | ||
| .. Select the *YAML* tab and view the following snippet: | ||
| + | ||
| .Example: `Route` | ||
| [source,yaml] | ||
| ---- | ||
| kind: Route | ||
| metadata: | ||
| name: rollouts-demo-route | ||
| spec: | ||
| alternateBackends: | ||
| - kind: Service | ||
| name: argo-rollouts-canary-service | ||
| weight: 0 #<1> | ||
| # (...) | ||
| to: | ||
| kind: Service | ||
| name: argo-rollouts-stable-service | ||
| weight: 100 #<2> | ||
| ---- | ||
Dhruv-Soni11 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| <1> A value of `0` means that 0% of traffic is directed to the canary version. | ||
| <2> A value of `100` means that 100% of traffic is directed to the stable version. | ||
| . Simulate the new canary version of the application by modifying the container image deployed in the rollout. | ||
| .. In the *Administrator* perspective of the web console, go to *Operators* -> *Installed Operators* -> *Red Hat OpenShift GitOps* -> *Rollout*. | ||
|
|
||
| .. Select the existing *Rollout* and modify the `.spec.template.spec.containers.image` value from `argoproj/rollouts-demo:blue` to `argoproj/rollouts-demo:yellow`. | ||
| + | ||
| As a result, the container image deployed in the rollout is modified and the rollout initiates a new canary deployment. | ||
| + | ||
| [NOTE] | ||
| ==== | ||
| As per the `setWeight` property defined in the `.spec.strategy.canary.steps` field of the `Rollout` resource, initially 30% of traffic to the route reaches the canary version and 70% of traffic is directed towards the stable version. The rollout is paused after 30% of traffic is directed to the canary version. | ||
| ==== | ||
| + | ||
| .Example route with 30% of traffic directed to the canary version and 70% directed to the stable version. | ||
| [source,yaml] | ||
| ---- | ||
| spec: | ||
| alternateBackends: | ||
| - kind: Service | ||
| name: argo-rollouts-canary-service | ||
| weight: 30 | ||
| # (...) | ||
| to: | ||
| kind: Service | ||
| name: argo-rollouts-stable-service | ||
| weight: 70 | ||
| ---- | ||
|
|
||
| . Simulate another new canary version of the application by running the following command in the Argo Rollouts CLI: | ||
| + | ||
| [source,terminal] | ||
| ---- | ||
| $ oc argo rollouts promote rollouts-demo -n <namespace> <1> | ||
| ---- | ||
| <1> Specify the namespace where the `Rollout` resource is defined. | ||
| + | ||
| This increases the traffic weight to 60% in the canary version and 40% in the stable version. | ||
| + | ||
| .Example route with 60% of traffic directed to the canary version and 40% directed to the stable version. | ||
| [source,yaml] | ||
| ---- | ||
| spec: | ||
| alternateBackends: | ||
| - kind: Service | ||
| name: argo-rollouts-canary-service | ||
| weight: 60 | ||
| # (...) | ||
| to: | ||
| kind: Service | ||
| name: argo-rollouts-stable-service | ||
| weight: 40 | ||
| ---- | ||
| . Increase the traffic weight in the canary version to 100% and discard the traffic in the old stable version of the application by running the following command: | ||
| + | ||
| [source,terminal] | ||
| ---- | ||
| $ oc argo rollouts promote rollouts-demo -n <namespace> <1> | ||
| ---- | ||
| <1> Specify the namespace where the `Rollout` resource is defined. | ||
| + | ||
| .Example route with 0% of traffic directed to the canary version and 100% directed to the stable version. | ||
| [source,yaml] | ||
| ---- | ||
| spec: | ||
| # (...) | ||
| to: | ||
| kind: Service | ||
| name: argo-rollouts-stable-service | ||
| weight: 100 | ||
| ---- | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.