Skip to content

Commit c82bd3d

Browse files
committed
Merge pull request openshift#502 from bfallonf/sticky_sessions
Edits after sticky sessions PR
2 parents cebb5fa + 7a7bf8b commit c82bd3d

File tree

1 file changed

+85
-76
lines changed

1 file changed

+85
-76
lines changed

architecture/core_objects/routing.adoc

+85-76
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,27 @@ protocols:
2020
- WebSockets
2121
- TLS with SNI
2222

23-
NOTE: WebSocket traffic uses the same route conventions and supports the same
23+
[NOTE]
24+
WebSocket traffic uses the same route conventions and supports the same
2425
TLS termination types as other traffic.
2526

2627
The router uses the service selector to watch the endpoints that support the
2728
service, bypassing its logic and replacing it with the router's own. Routers
28-
subscribe to a configuration and automatically update themselves with any
29-
changes. Router may be containerized or virtual, converting any changes to API
30-
calls to another system, such as *F5*.
29+
subscribe to a configuration and automatically update themselves when the
30+
configuration changes. A router may be containerized or virtual, converting any
31+
changes to API calls to another system, such as *F5*.
3132

3233
Other capabilities exist to load-balance a service within a cluster. These
3334
services are exposed via a configurable link relation between different
3435
services, and ensure a set of services can be available.
3536
link:../../dev_guide/deployments.html[Deployments] can use these services as
3637
local proxies for each host, or reuse the shared routing infrastructure.
3738

38-
As an OpenShift administrator, you can configure routers in your instance. This
39-
allows developers to then set the route types for their projects.
39+
An OpenShift administrator can configure routers in an OpenShift instance.
40+
Developers can then set the route types for their projects.
4041

4142
== Route Types
42-
Routes can be either secure or unsecure. Secure routes provide the ability to
43+
Routes can be either secure or unsecured. Secure routes provide the ability to
4344
use different types of TLS termination to serve certificates to the client.
4445
Routers support link:#edge-termination[edge],
4546
link:#passthrough-termination[passthrough], and
@@ -48,7 +49,7 @@ link:#re-encryption-termination[re-encryption] termination.
4849
To create a secure route, specify the TLS termination of the route in a JSON
4950
file.
5051

51-
.An Unsecure Route
52+
.An Unsecured Route
5253
====
5354
5455
----
@@ -96,7 +97,7 @@ file.
9697
----
9798
====
9899

99-
.An Unsecure Route with a Path:
100+
.An Unsecured Route with a Path:
100101
====
101102
102103
----
@@ -119,10 +120,16 @@ file.
119120
120121
====
121122

122-
Unsecure routes are likely faster to set up, as they are the default configuration, but secure routes offer greater security for information to remain private.
123+
Unsecured routes are can be faster to set up, as they are the default
124+
configuration, but secure routes offer greater security for information to
125+
remain private.
123126

124-
== Path Based Routes
125-
Path based routes specify a path component that can be compared against a URL. This implies that the traffic for the route is HTTP based. Routers should match routes based on the most specific path to the least. However, this depends on your implementation. The following table shows example routes and their accessibility:
127+
== Path-Based Routes
128+
Path-based routes specify a path component that can be compared against a URL,
129+
implying that the traffic for the route is HTTP based. Routers should match
130+
routes based on the most specific path to the least. However, this depends on
131+
your implementation. The following table shows example routes and their
132+
accessibility:
126133

127134
////
128135
* For a route with \_www.example.com/test_:
@@ -155,23 +162,24 @@ Path based routes specify a path component that can be compared against a URL. T
155162
|===
156163

157164
== Securing Routes
158-
You can create a secure route to your pods by specifying the TLS termination of
159-
the route and, optionally, providing certificates.
165+
Create a secure route to your pods by specifying the TLS termination of the
166+
route and, optionally, providing certificates.
160167

161-
NOTE: Currently, TLS termination in OpenShift Beta relies on SNI for serving
168+
[NOTE]
169+
Currently, TLS termination in OpenShift Beta relies on SNI for serving
162170
custom certificates. Any non-SNI traffic received on port 443 has TLS
163171
termination with a generic certificate. In the future, the ability to create
164172
custom front ends within the router will allow all traffic to serve custom
165173
certificates.
166174

167-
By default, OpenShift routes are unsecure, but can be set to any of the
175+
By default, OpenShift routes are unsecured, but can be set to any of the
168176
following three types of secure TLS termination.
169177

170178
[[edge-termination]]
171179
*Edge Termination*
172180

173181
With edge termination, TLS termination occurs prior to traffic reaching its
174-
destination. TLS certificates are served by the front end of the router.
182+
destination. TLS certificates are served by the front-end of the router.
175183

176184
You can configure edge termination on your route by specifying the following:
177185

@@ -299,49 +307,50 @@ link:#special-notes[special notes] below.
299307
[[wildcard-certificates]]
300308
*Wildcard Certificates*
301309

302-
Based on the implementation, you may be able to use a default certificate. Default certificates
303-
are useful for implementing a wildcard certificate for the router. For example, if you have
304-
many routes that end in example.com you may wish to install a router with a wild card
305-
certificate for `*.example.com`.
310+
Depending on your implementation, you can use a default certificate. Default
311+
certificates are useful for implementing a wildcard certificate for the router.
312+
For example, if you have many routes that end in `example.com` you may wish to
313+
install a router with a wildcard certificate for `*.example.com`.
306314

307-
To provide the default certificate to the router you must specify it in the create command with
308-
the default-cert option. The certificate should be a concatenated file of the key, certificate,
309-
and any CA certificates that are required by the browser. The certificate should be in a
310-
form acceptable by the underlying router implementation. In the case of HAProxy it should be a
311-
PEM based certificate.
312-
313-
****
314-
`oadm router --credentials="$KUBECONFIG" --default-cert=/full/path/to/certificate.pem`
315-
****
315+
To provide the default certificate to the router you must specify it in the
316+
create command with the `--default-cert` option. The certificate should be a
317+
concatenated file of the key, certificate, and any CA certificates that are
318+
required by the browser. The certificate must be in a form acceptable by the
319+
underlying router implementation. In the case of HAProxy it should be a
320+
PEM-based certificate.
316321

317-
For HAProxy, if a default certificate is provided, it will load it first. The certificate that
318-
is loaded first will be presented to any route that matches the CN on the certificate and
319-
any route that is secure but does not match any configured certificates. For example, if
320-
the default certificate is for `\*.example.com` and a secure route for `www.foo.com` is created
321-
with no certificates the route will still be written and the router will serve the `*.example.com`
322-
certficiate. This may result in a browser warning for users since the CN on the certificate
323-
does not match the url.
322+
----
323+
$ oadm router --credentials="$KUBECONFIG" --default-cert=/full/path/to/certificate.pem
324+
----
324325

325-
If no default certificate is supplied, the HAProxy router will default to a generic, expired
326+
For HAProxy, if a default certificate is provided, it will be loaded first. The
327+
certificate that is loaded first is presented to any route that matches the CN
328+
on the certificate and any route that is secure but does not match any
329+
configured certificates. For example, if the default certificate is for
330+
`\*.example.com` and a secure route for `www.foo.com` is created with no
331+
certificates the route will still be written and the router will serve the
332+
`*.example.com` certficiate. This may result in a browser warning for users
333+
since the CN on the certificate does not match the url. If no default
334+
certificate is supplied, the HAProxy router will default to a generic, expired
326335
certificate that is provided in the base image.
327336

328337
[[special-notes]]
329338
*Special Notes About Secure Routes*
330339

331340
Currently, password protected key files are not supported. HAProxy prompts you
332341
for a password upon starting and does not have a way to automate this process.
333-
To remove a passphrase from a keyfile, you can run:
342+
To remove a passphrase from a keyfile, run:
334343

335-
****
336-
`# openssl rsa -in _<passwordProtectedKey.key>_ -out _<new.key>_`
337-
****
344+
----
345+
# openssl rsa -in <passwordProtectedKey.key> -out <new.key>
346+
----
338347

339-
When creating a secure route, you must include your certificate files as a
340-
single line of text. Replace the existing line breaks with:
348+
When creating a secure route, include your certificate files as a single line of
349+
text. Replace the existing line breaks with:
341350

342-
****
343-
`\n`
344-
****
351+
----
352+
\n
353+
----
345354

346355
== Routers
347356
A template router provides certain infrastructure information to the underlying
@@ -353,10 +362,10 @@ router implementation, such as:
353362
template.
354363
- Calling a reload script.
355364

356-
Router plug-ins assume they can bind to host ports 80 and 443. This is to allow
357-
external traffic to route to the host and subsequently through the router.
358-
Routers also assume that networking is configured such that it can access all
359-
pods in the cluster.
365+
Router plug-ins assume they can bind to host ports 80 and 443 to allow external
366+
traffic to route to the host and subsequently through the router. Routers also
367+
assume that networking is configured such that it can access all pods in the
368+
cluster.
360369

361370
At the time of writing, a template router is the single type of router plug-in
362371
available in OpenShift.
@@ -370,31 +379,29 @@ repository to run an HAProxy instance alongside the template router plug-in. To
370379
test routes, an install command is provided.
371380

372381

373-
Check the default router ("router"):
374-
375-
****
376-
$ `oadm router --dry-run`
377-
****
382+
To check the default router (named *router*):
378383

379-
See what the router would look like if created:
384+
----
385+
$ oadm router --dry-run
386+
----
380387

381-
****
382-
$ `oadm router -o json`
383-
****
388+
To view what the router would look like if created:
384389

385-
Create a router if it does not exist:
390+
----
391+
$ oadm router -o json
392+
----
386393

387-
****
388-
$ `oadm router router-west --replicas=2 --credentials="$KUBECONFIG"`
389-
****
394+
To create a router if it does not exist:
390395

391-
Use a different router image and see the router configuration:
396+
----
397+
$ oadm router router-west --replicas=2 --credentials="$KUBECONFIG"
398+
----
392399

393-
****
394-
$ `oadm router region-west -o yaml --images=myrepo/somerouter:mytag`
395-
****
400+
To use a different router image and view the router configuration:
396401

397-
NOTE: This command is currently being actively developed. It is intended to simplify the tasks of setting up routers in a new installation.
402+
----
403+
$ oadm router region-west -o yaml --images=myrepo/somerouter:mytag
404+
----
398405

399406
The following diagram illustrates how data flows from the master through the
400407
plug-in and finally into an HAProxy configuration:
@@ -404,13 +411,15 @@ image:router_model.png[HAProxy Router Data Flow]
404411

405412
*Sticky Sessions*
406413

407-
Implementing sticky sessions is up to the underlying router configuration. The default HAProxy
408-
template implements sticky sessions using the `balance source` directive which balances based
409-
on the source IP. In addition, the template router plugin will provide the service name and
410-
namespace to the underlying implementation. This can be used for more advanced configuration
411-
such as implementing stick-tables that synchronize between a set of peers. For details on the
412-
implementation you may inspect the `haproxy-config.template` located in the `/var/lib/haproxy/conf`
413-
directory of your router container.
414+
Sticky sessions are implemented by the underlying router configuration. The
415+
default
416+
link:https://github.com/openshift/origin/blob/3dc5a6e7416a9a6f2270cc236b26be7abb491ab0/images/router/haproxy/conf/haproxy-config.template[HAProxy
417+
template] in the `/var/lib/haproxy/conf` directory of the router container
418+
configures sticky sessions using the `balance source` directive, which balances
419+
based on the source IP. In addition, the template router plug-in provides the
420+
service name and namespace to the underlying implementation. This can be used
421+
for more advanced configurations, such as implementing stick-tables to
422+
synchronize peers.
414423

415424
////
416425
== Highly-available Routers

0 commit comments

Comments
 (0)