mirror of
https://github.com/openshift/openshift-docs.git
synced 2026-02-05 12:46:18 +01:00
64 lines
1.8 KiB
Plaintext
64 lines
1.8 KiB
Plaintext
// Module filename: nw-annotating-a-route-with-a-cookie-name.adoc
|
|
// Use module with the following module:
|
|
// nw-using-cookies-keep-route-statefulness.adoc
|
|
//
|
|
// Module included in the following assemblies:
|
|
//
|
|
// * networking/configuring-routing.adoc
|
|
// * microshift_networking/microshift-configuring-routes.adoc
|
|
|
|
:_mod-docs-content-type: PROCEDURE
|
|
[id="nw-annotating-a-route-with-a-cookie-name_{context}"]
|
|
= Annotating a route with a cookie
|
|
|
|
[role="_abstract"]
|
|
To enable applications to manage session persistence and load distribution, annotate the route with a custom cookie name. Overwriting the default cookie allows the backend application to identify and delete the specific cookie, forcing endpoint re-selection when necessary.
|
|
|
|
When a server is overloaded, the server tries to remove the requests from the client and redistribute the requests to other endpoints.
|
|
|
|
.Procedure
|
|
|
|
. Annotate the route with the specified cookie name:
|
|
+
|
|
[source,terminal]
|
|
----
|
|
$ oc annotate route <route_name> router.openshift.io/cookie_name="<cookie_name>"
|
|
----
|
|
+
|
|
where:
|
|
+
|
|
`<route_name>`:: Specifies the name of the route.
|
|
`<cookie_name>`:: Specifies the name for the cookie.
|
|
+
|
|
For example, to annotate the route `my_route` with the cookie name `my_cookie`:
|
|
+
|
|
[source,terminal]
|
|
----
|
|
$ oc annotate route my_route router.openshift.io/cookie_name="my_cookie"
|
|
----
|
|
|
|
. Capture the route hostname in a variable:
|
|
+
|
|
[source,terminal]
|
|
----
|
|
$ ROUTE_NAME=$(oc get route <route_name> -o jsonpath='{.spec.host}')
|
|
----
|
|
+
|
|
where:
|
|
+
|
|
`<route_name>`:: Specifies the name of the route.
|
|
|
|
. Save the cookie, and then access the route:
|
|
+
|
|
[source,terminal]
|
|
----
|
|
$ curl $ROUTE_NAME -k -c /tmp/cookie_jar
|
|
----
|
|
+
|
|
Use the cookie saved by the previous command when connecting to the route:
|
|
+
|
|
[source,terminal]
|
|
----
|
|
$ curl $ROUTE_NAME -k -b /tmp/cookie_jar
|
|
----
|