Skip to content

Commit d121331

Browse files
committed
RHDEVDOCS-5562: Creating content for Adding OpenShift Routes as a traffic manager for Argo Rollouts
1 parent 07d169c commit d121331

File tree

3 files changed

+305
-1
lines changed

3 files changed

+305
-1
lines changed

argo_rollouts/using-argo-rollouts-for-progressive-deployment-delivery.adoc

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Progressive delivery reduces the risk of a release by exposing the new version o
1616

1717
With Argo Rollouts, you can use automation and metric analysis to support progressive deployment delivery and drive the automated rollout or rollback of a new version of an application.
1818
Argo Rollouts provide advanced deployment capabilities and enable integration with ingress controllers and service meshes.
19-
You can use Argo Rollouts to manage multiple replica sets that represent different versions of the deployed application. Depending on your deployment strategy, you can handle traffic to these versions during an update by optimizing their existing traffic shaping abilities and gradually shifting traffic to the new version. You can combine Argo Rollouts with a metric provider like Prometheus to do metric-based and policy-driven rollouts and rollbacks based on the parameters set.
19+
You can use Argo Rollouts to manage multiple replica sets that represent different versions of the deployed application. Depending on your deployment strategy, you can handle traffic to these versions during an update by optimizing their existing traffic shaping abilities and gradually shifting traffic to the new version. You can combine Argo Rollouts with a metric provider like Prometheus to do metric-based and policy-driven rollouts and rollbacks based on the parameters set.
2020

2121
[id="prerequisites_using-argo-rollouts-for-progressive-deployment-delivery"]
2222
== Prerequisites
@@ -39,6 +39,12 @@ include::modules/gitops-creating-rolloutmanager-custom-resource.adoc[leveloffset
3939
// Deleting a RolloutManager custom resource
4040
include::modules/gitops-deleting-rolloutmanager-custom-resource.adoc[leveloffset=+1]
4141

42+
// Routing traffic by using Argo Rollouts
43+
include::modules/con_routing-traffic-by-using-argo-rollouts.adoc[leveloffset=+1]
44+
45+
// Configuring Argo Rollouts to route traffic by using OpenShift Routes
46+
include::modules/gitops-configure-rollout-route-traffic-using-openshift-routes.adoc[leveloffset=+2]
47+
4248
[role="_additional-resources"]
4349
[id="additional-resources_argo-rollouts-in-gitops"]
4450
== Additional resources
@@ -48,4 +54,7 @@ include::modules/gitops-deleting-rolloutmanager-custom-resource.adoc[leveloffset
4854
* link:https://docs.openshift.com/container-platform/latest/applications/deployments/route-based-deployment-strategies.html#deployments-blue-green_route-based-deployment-strategies[Blue-green deployments]
4955
* link:https://argo-rollouts-manager.readthedocs.io/en/latest/crd_reference/[`RolloutManager` Custom Resource specification]
5056
* link:https://www.redhat.com/architect/blue-green-canary-argo-rollouts[Blue-green and canary deployments with Argo Rollouts]
57+
* xref:../installing_gitops/installing-argocd-gitops-cli.adoc#installing-argocd-gitops-cli[Installing the GitOps CLI]
58+
* xref:../gitops_cli_argocd/configuring-argocd-gitops-cli.adoc#configuring-argocd-gitops-cli[Configuring the GitOps CLI]
59+
* xref:../argo_rollouts/using-argo-rollouts-for-progressive-deployment-delivery.adoc#gitops-creating-rolloutmanager-custom-resource_using-argo-rollouts-for-progressive-deployment-delivery[Creating a RolloutManager custom resource]
5160
* link:https://cloud.redhat.com/blog/trying-out-argo-rollouts-in-openshift-gitops-1.9/[Argo Rollouts tech preview limitations]
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * <list of assemblies where this module is included>
4+
:_mod-docs-content-type: CONCEPT
5+
[id="routing-traffic-by-using-argo-rollouts_{context}"]
6+
= Routing traffic by using Argo Rollouts
7+
8+
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.
9+
10+
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.
11+
12+
You can use OpenShift Routes to split traffic between two application versions:
13+
14+
* *Canary version*: A new version of an application where you gradually route the traffic.
15+
* *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.
Lines changed: 280 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,280 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * argo_rollouts/using-argo-rollouts-for-progressive-deployment-delivery.adoc
4+
5+
:_mod-docs-content-type: PROCEDURE
6+
[id="gitops-configure-rollout-route-traffic-using-openshift-routes_{context}"]
7+
= Configuring Argo Rollouts to route traffic by using OpenShift Routes
8+
9+
You can use OpenShift Routes to configure Argo Rollouts to create routes, rollouts, and services.
10+
11+
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.
12+
13+
.Prerequisites
14+
15+
* You have logged in to the {OCP} cluster as an administrator.
16+
* You have installed the {gitops-title} on your {OCP} cluster.
17+
* You have installed Argo Rollouts on your {OCP} cluster. For more information, see xref:../argo_rollouts/using-argo-rollouts-for-progressive-deployment-delivery.adoc#gitops-creating-rolloutmanager-custom-resource_using-argo-rollouts-for-progressive-deployment-delivery[Creating a RolloutManager custom resource].
18+
* You have installed the {gitops-title} CLI on your system. For more information, see xref:../installing_gitops/installing-argocd-gitops-cli.adoc#installing-argocd-gitops-cli[Installing the {gitops-shortname} CLI].
19+
* You have installed the Argo Rollouts CLI on your system. For more information, see _Argo Rollouts CLI overview_.
20+
21+
.Procedure
22+
23+
. Create a `Route` object.
24+
.. In the *Administrator* perspective of the web console, click *Networking* -> *Routes*.
25+
.. Click *Create Route*.
26+
.. On the *Create Route* page, click *YAML view* and add the following snippet:
27+
+
28+
The following example creates a route called `rollouts-demo-route`:
29+
+
30+
[source,yaml]
31+
----
32+
apiVersion: route.openshift.io/v1
33+
kind: Route
34+
metadata:
35+
name: rollouts-demo-route
36+
spec:
37+
port:
38+
targetPort: http #<1>
39+
tls: #<2>
40+
insecureEdgeTerminationPolicy: Redirect
41+
termination: edge
42+
to:
43+
kind: Service
44+
name: argo-rollouts-stable-service #<3>
45+
weight: 100 # <4>
46+
47+
alternateBackends:
48+
- kind: Service
49+
name: argo-rollouts-canary-service #<5>
50+
weight: 0 #<6>
51+
----
52+
<1> Specifies the name of the port used by the application for running inside the container.
53+
<2> Specifies the TLS configuration used to secure the route
54+
<3> The name of the targeted stable service.
55+
<4> This field is automatically modified to stable weight by Route Rollout plugin.
56+
<5> The name of the targeted canary service.
57+
<6> This field is automatically modified to canary weight by Route Rollout plugin.
58+
+
59+
.. Click *Create* to create the route. It is then displayed on the *Routes* page.
60+
. Create the services, canary and stable, to be referenced in the route.
61+
.. In the *Administrator* perspective of the web console, click *Networking* -> *Services*.
62+
.. Click *Create Service*.
63+
.. On the *Create Service* page, click *YAML view* and add the following snippet:
64+
+
65+
The following example creates a canary service called `argo-rollouts-canary-service`. Canary traffic is directed to this service.
66+
+
67+
[source,yaml]
68+
----
69+
apiVersion: v1
70+
kind: Service
71+
metadata:
72+
name: argo-rollouts-canary-service
73+
spec:
74+
ports: #<1>
75+
- port: 80
76+
targetPort: http
77+
protocol: TCP
78+
name: http
79+
80+
selector: #<2>
81+
app: rollouts-demo
82+
----
83+
<1> Specifies the name of the port used by the application for running inside the container.
84+
<2> Ensure that the contents of the `selector` field are the same as in stable service and `Rollout` CR.
85+
+
86+
[IMPORTANT]
87+
====
88+
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.
89+
====
90+
.. Click *Create* to create the canary service.
91+
+
92+
Rollouts automatically update the created service with pod template hash of the canary `ReplicaSet`. For example, `rollouts-pod-template-hash: 7bf84f9696`.
93+
.. Similarly, repeat these steps to create the stable service:
94+
+
95+
The following example creates a stable service called `argo-rollouts-stable-service`. Stable traffic is directed to this service.
96+
+
97+
[source,yaml]
98+
----
99+
apiVersion: v1
100+
kind: Service
101+
metadata:
102+
name: argo-rollouts-stable-service
103+
spec:
104+
ports: #<1>
105+
- port: 80
106+
targetPort: http
107+
protocol: TCP
108+
name: http
109+
110+
selector: #<2>
111+
app: rollouts-demo
112+
----
113+
<1> Specifies the name of the port used by the application for running inside the container.
114+
<2> Ensure that the contents of the `selector` field are the same as in canary service and `Rollout` CR .
115+
+
116+
[IMPORTANT]
117+
====
118+
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.
119+
====
120+
.. Click *Create* to create the stable service.
121+
+
122+
Rollouts automatically update the created service with pod template hash of the stable `ReplicaSet`. For example, `rollouts-pod-template-hash: 1b6a7733`.
123+
. Create the `Rollout` CR to reference the `Route` and `Service` objects.
124+
.. In the *Administrator* perspective of the web console, go to *Operators* -> *Installed Operators* -> *Red Hat OpenShift GitOps* -> *Rollout*.
125+
.. On the *Create Rollout* page, click *YAML view* and add the following snippet:
126+
+
127+
The following example creates a `Rollout` CR called `rollouts-demo`:
128+
+
129+
[source,yaml]
130+
----
131+
apiVersion: argoproj.io/v1alpha1
132+
kind: Rollout
133+
metadata:
134+
name: rollouts-demo
135+
spec:
136+
template: #<1>
137+
metadata:
138+
labels:
139+
app: rollouts-demo
140+
spec:
141+
containers:
142+
- name: rollouts-demo
143+
image: argoproj/rollouts-demo:blue
144+
ports:
145+
- name: http
146+
containerPort: 8080
147+
protocol: TCP
148+
resources:
149+
requests:
150+
memory: 32Mi
151+
cpu: 5m
152+
153+
revisionHistoryLimit: 2
154+
replicas: 5
155+
strategy:
156+
canary:
157+
canaryService: argo-rollouts-canary-service #<2>
158+
stableService: argo-rollouts-stable-service #<3>
159+
trafficRouting:
160+
plugins:
161+
argoproj-labs/openshift:
162+
routes:
163+
- rollouts-demo-route #<4>
164+
steps: #<5>
165+
- setWeight: 30
166+
- pause: {}
167+
- setWeight: 60
168+
- pause: {}
169+
selector: #<6>
170+
matchLabels:
171+
app: rollouts-demo
172+
----
173+
<1> Specifies the pods that are to be created.
174+
<2> This must match the name of the created canary `Service`.
175+
<3> This must match the name of the created stable `Service`.
176+
<4> This must match the name of the created `Route` CR.
177+
<5> Specify the steps for the rollout. This example gradually routes 30%, 60%, and 100% of traffic to the canary version.
178+
<6> Ensure that the contents of the `selector` field are the same as in canary and stable service.
179+
.. Click *Create*.
180+
+
181+
After the Rollout has been created, you can verify that the *Status* field of the Rollout shows *Phase: Healthy*.
182+
.. In the *RolloutManager* tab, under the *RolloutManagers* section, verify that the *Status* field of the *RolloutManager* instance shows as *Phase: Available*.
183+
184+
. Verify that the route is directing 100% of the traffic towards the stable version of the application.
185+
+
186+
[NOTE]
187+
====
188+
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.
189+
====
190+
.. Go to *Networking* -> *Routes* and look for the `Route` resource you want to verify.
191+
.. Select the *YAML* tab and view the following snippet:
192+
+
193+
.Example: `Route`
194+
[source,yaml]
195+
----
196+
kind: Route
197+
metadata:
198+
name: rollouts-demo-route
199+
spec:
200+
alternateBackends:
201+
- kind: Service
202+
name: argo-rollouts-canary-service
203+
weight: 0 #<1>
204+
# (...)
205+
to:
206+
kind: Service
207+
name: argo-rollouts-stable-service
208+
weight: 100 #<2>
209+
----
210+
<1> This means that 0% of traffic is directed to the canary version.
211+
<2> This means that 100% of traffic is directed to the stable version.
212+
. Simulate the new canary version of the application by modifying the container image deployed in the rollout.
213+
.. In the *Administrator* perspective of the web console, go to *Operators* -> *Installed Operators* -> *Red Hat OpenShift GitOps* -> *Rollout*.
214+
215+
.. Select the existing *Rollout* and modify the `.spec.template.spec.containers.image` value from `argoproj/rollouts-demo:blue` to `argoproj/rollouts-demo:yellow`.
216+
+
217+
As a result, the container image deployed in the rollout is modified and the rollout initiates a new canary deployment.
218+
+
219+
[NOTE]
220+
====
221+
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.
222+
====
223+
+
224+
.Example route with 30% of traffic directed to the canary version and 70% directed to the stable version.
225+
[source,yaml]
226+
----
227+
spec:
228+
alternateBackends:
229+
- kind: Service
230+
name: argo-rollouts-canary-service
231+
weight: 30
232+
# (...)
233+
to:
234+
kind: Service
235+
name: argo-rollouts-stable-service
236+
weight: 70
237+
----
238+
239+
. Simulate another new canary version of the application by running the following command in the Argo Rollouts CLI:
240+
+
241+
[source,yaml]
242+
----
243+
$ oc argo rollouts promote rollouts-demo -n <namespace> <1>
244+
----
245+
<1> Specify namespace where the `Rollout` resource is defined.
246+
+
247+
This increases the traffic weight to 60% in the canary version and 40% in the stable version.
248+
+
249+
.Example route with 60% of traffic directed to the canary version and 40% directed to the stable version.
250+
[source,yaml]
251+
----
252+
spec:
253+
alternateBackends:
254+
- kind: Service
255+
name: argo-rollouts-canary-service
256+
weight: 60
257+
# (...)
258+
to:
259+
kind: Service
260+
name: argo-rollouts-stable-service
261+
weight: 40
262+
----
263+
. 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:
264+
+
265+
[source,yaml]
266+
----
267+
$ oc argo rollouts promote rollouts-demo -n <namespace> <1>
268+
----
269+
<1> Specify namespace where the `Rollout` resource is defined.
270+
+
271+
.Example route with 0% of traffic directed to the canary version and 100% directed to the stable version.
272+
[source,yaml]
273+
----
274+
spec:
275+
# (...)
276+
to:
277+
kind: Service
278+
name: argo-rollouts-stable-service
279+
weight: 100
280+
----

0 commit comments

Comments
 (0)