|
| 1 | +// Modules included in the following assemblies: |
| 2 | +// |
| 3 | +// * networking/gateway-api.adoc |
| 4 | + |
| 5 | +:_mod-docs-content-type: CONCEPT |
| 6 | +[id="nw-ingress-gateway-api-deployment_{context}"] |
| 7 | += Gateway API Deployment topologies |
| 8 | + |
| 9 | +Gateway API is designed to accomodate two topologies: shared gateways or dedicated gateways. Each topology has their own advantages and as well as different security implications. |
| 10 | + |
| 11 | +Dedicated gateway:: Routes and any load balancers or proxies are served from the same namespace. The `Gateway` |
| 12 | +object restricts routes to a particular application namespace. This is the default topology for Gateway API in {product-title}. |
| 13 | + |
| 14 | +Shared gateway:: Routes are served from multiple namespaces or with multiple hostnames. The `Gateway` object filters allow routes from application namespaces using the `spec.listeners.allowedRoutes.namespaces` field. |
| 15 | + |
| 16 | +[id="dedicated-gateway-example_{context}"] |
| 17 | +== Dedicated gateway example |
| 18 | +An example of a `Gateway` resource, `fin-gateway`: |
| 19 | + |
| 20 | +.Example dedicated `Gateway` resource |
| 21 | +[source,yaml] |
| 22 | +---- |
| 23 | +apiVersion: gateway.networking.k8s.io/v1 |
| 24 | +kind: Gateway |
| 25 | +metadata: |
| 26 | + name: fin-gateway |
| 27 | + namespace: openshift-ingress |
| 28 | +spec: |
| 29 | + listeners: |
| 30 | + - name: http |
| 31 | + protocol: HTTP |
| 32 | + port: 8080 |
| 33 | + hostname: "example.com" |
| 34 | +---- |
| 35 | + |
| 36 | +An example of the associated `HTTPRoute` resource, `sales-db`, that attaches to the dedicated `Gateway` object: |
| 37 | + |
| 38 | +.Example `HTTPRoute` resource |
| 39 | +[source,yaml] |
| 40 | +---- |
| 41 | +apiVersion: gateway.networking.k8s.io/v1 |
| 42 | +kind: HTTPRoute |
| 43 | +metadata: |
| 44 | + name: sales-db |
| 45 | + namespace: openshift-ingress |
| 46 | +spec: |
| 47 | + parentRefs: |
| 48 | + - name: fin-gateway |
| 49 | + rules: |
| 50 | + - backendRefs: |
| 51 | + - name: sales-db |
| 52 | + ¦ port: 8080 |
| 53 | +---- |
| 54 | + |
| 55 | +The `HTTPRoute` resource must have the `Gateway` object's name as the value for its `parentRefs` field in order to attach to the gateway. Implicitly, the route is assumed to be in the same namespace as the `Gateway` object. |
| 56 | + |
| 57 | +[id="shared-gateway-example_{context}"] |
| 58 | +== Shared gateway example |
| 59 | +An example of a `Gateway` resource, `devops-gateway`, that has a label selector `spec.listeners.allowedRoutes.namespaces` set to match any namespaces containing `shared-gateway-access: "true"`: |
| 60 | + |
| 61 | +.Example shared `Gateway` resource |
| 62 | +[source,yaml] |
| 63 | +---- |
| 64 | +apiVersion: gateway.networking.k8s.io/v1 |
| 65 | +kind: Gateway |
| 66 | +metadata: |
| 67 | + name: devops-gateway |
| 68 | + namespace: openshift-ingress |
| 69 | +listeners: |
| 70 | + - name: https |
| 71 | + protocol: HTTPS |
| 72 | + hostname: "example.com" |
| 73 | + allowedRoutes: |
| 74 | + namespaces: |
| 75 | + from: Selector |
| 76 | + selector: |
| 77 | + ¦ matchLabels: |
| 78 | + ¦ shared-gateway-access: "true" |
| 79 | +---- |
| 80 | + |
| 81 | +Examples of the allowed namespaces for the `devops-gateway` resource: |
| 82 | + |
| 83 | +.Example `Namespace` resources |
| 84 | +[source,yaml] |
| 85 | +---- |
| 86 | +apiVersion: v1 |
| 87 | +kind: Namespace |
| 88 | +metadata: |
| 89 | + name: dev |
| 90 | + labels: |
| 91 | + shared-gateway-access: "true" |
| 92 | +--- |
| 93 | +apiVersion: v1 |
| 94 | +kind: Namespace |
| 95 | +metadata: |
| 96 | + name: ops |
| 97 | + labels: |
| 98 | + shared-gateway-access: "true" |
| 99 | +---- |
| 100 | + |
| 101 | +An example of two `HTTPRoute` resources, `dev-portal` and `ops-home`, that sit in different namespaces but are attached to the shared gateway: |
| 102 | + |
| 103 | +[source,yaml] |
| 104 | +---- |
| 105 | +apiVersion: v1 |
| 106 | +kind: HTTPRoute |
| 107 | +metadata: |
| 108 | + name: dev-portal |
| 109 | + namespace: dev |
| 110 | +spec: |
| 111 | + parentRefs: |
| 112 | + - name: devops-gateway |
| 113 | + namespace: openshift-ingress |
| 114 | + rules: |
| 115 | + - backendRefs: |
| 116 | + - name: dev-portal |
| 117 | + port: 8080 |
| 118 | +--- |
| 119 | +apiVersion: v1 |
| 120 | +kind: HTTPRoute |
| 121 | +metadata: |
| 122 | + name: ops-home |
| 123 | + namespace: ops |
| 124 | +spec: |
| 125 | + parentRefs: |
| 126 | + - name: devops-gateway |
| 127 | + namespace: openshift-ingress |
| 128 | + rules: |
| 129 | + - backendRefs: |
| 130 | + - name: ops-home |
| 131 | + port: 8080 |
| 132 | +---- |
| 133 | + |
| 134 | +With a shared gateway topology, the routes must specify the namespace of the `Gateway` object it wants to attach to. Multiple `Gateway` objects can be deployed and shared across namespaces. When there are multiple shared gateways this becomes conceptually similar to Ingress Controller sharding. |
| 135 | + |
0 commit comments