|
| 1 | +# HTTPRoute API Reference |
| 2 | + |
| 3 | +## Introduction |
| 4 | + |
| 5 | +With integration of the Gateway API, the EKS Controller project supports `HTTPRoute`. |
| 6 | +This allows you to define and manage the routing of HTTP and HTTPS traffic within your Kubernetes cluster. |
| 7 | + |
| 8 | +### HTTPRoute Key Features & Limitations: |
| 9 | + |
| 10 | +**Features**: |
| 11 | + |
| 12 | +- **Routing Traffic**: Enables routing HTTP traffic to servers within your Kubernetes cluster. |
| 13 | +- **Path and Method Matching**: The `HTTPRoute` allows for matching by: |
| 14 | + - An exact path. |
| 15 | + - Any path with a specified prefix. |
| 16 | + - A specific HTTP Method. |
| 17 | +- **Header Matching**: Enables matching based on specific headers in the HTTP request. |
| 18 | + |
| 19 | +**Limitations**: |
| 20 | + |
| 21 | +- **Listener Protocol**: The `HTTPRoute` sectionName must refer to an HTTP or HTTPS listener in the parent `Gateway`. |
| 22 | +- **Method Matches**: One method match is allowed within a single rule. |
| 23 | +- **QueryParam Matches**: Matching by QueryParameters is not supported. |
| 24 | +- **Header Matches Limit**: A maximum of 5 header matches per rule is supported. |
| 25 | +- **Case Insensitivity**: All path matches are currently case-insensitive. |
| 26 | + |
| 27 | +## Example Configuration: |
| 28 | + |
| 29 | +### Example 1 |
| 30 | + |
| 31 | +Here is a sample configuration that demonstrates how to set up an `HTTPRoute` that forwards HTTP traffic to a |
| 32 | +Service and ServiceImport, using rules to determine which backendRef to route traffic to. |
| 33 | + |
| 34 | +```yaml |
| 35 | +apiVersion: gateway.networking.k8s.io/v1beta1 |
| 36 | +kind: HTTPRoute |
| 37 | +metadata: |
| 38 | + name: inventory |
| 39 | +spec: |
| 40 | + parentRefs: |
| 41 | + - name: my-hotel |
| 42 | + sectionName: http |
| 43 | + rules: |
| 44 | + - backendRefs: |
| 45 | + - name: inventory-ver1 |
| 46 | + kind: Service |
| 47 | + port: 80 |
| 48 | + matches: |
| 49 | + - path: |
| 50 | + type: PathPrefix |
| 51 | + value: /ver1 |
| 52 | + - backendRefs: |
| 53 | + - name: inventory-ver2 |
| 54 | + kind: ServiceImport |
| 55 | + port: 80 |
| 56 | + matches: |
| 57 | + - path: |
| 58 | + type: PathPrefix |
| 59 | + value: /ver2 |
| 60 | +``` |
| 61 | +
|
| 62 | +In this example: |
| 63 | +
|
| 64 | +- The `HTTPRoute` is named `inventory` and is associated with a parent gateway named `my-hotel` that has |
| 65 | + a section named `http`. |
| 66 | +- The first routing rule forwards traffic to a backend Service named `inventory-ver1` on port `80`. |
| 67 | + The rule also specifies a path match condition, where traffic must have a path starting with `/ver1` for the routing |
| 68 | + rule to apply. |
| 69 | +- The second routing rule forwards traffic to a backend ServiceImport named `inventory-ver2` on port `80`. |
| 70 | + The rule also specifies a path match condition, where traffic must have a path starting with `/ver2` for the routing |
| 71 | + rule to apply. |
| 72 | + |
| 73 | +### Example 2 |
| 74 | + |
| 75 | +Here is a sample configuration that demonstrates how to set up a `HTTPRoute` that forwards HTTP and HTTPS traffic to a |
| 76 | +Service and ServiceImport, using weighted rules to route more traffic to one backendRef than the other. Weighted rules |
| 77 | +simplify the process of creating blue/green deployments by shifting rule weight from one backendRef to another. |
| 78 | + |
| 79 | +```yaml |
| 80 | +apiVersion: gateway.networking.k8s.io/v1beta1 |
| 81 | +kind: HTTPRoute |
| 82 | +metadata: |
| 83 | + name: inventory |
| 84 | +spec: |
| 85 | + parentRefs: |
| 86 | + - name: my-hotel |
| 87 | + sectionName: http |
| 88 | + - name: my-hotel |
| 89 | + sectionName: https |
| 90 | + rules: |
| 91 | + - backendRefs: |
| 92 | + - name: inventory-ver1 |
| 93 | + kind: Service |
| 94 | + port: 80 |
| 95 | + weight: 10 |
| 96 | + - name: inventory-ver2 |
| 97 | + kind: ServiceImport |
| 98 | + port: 80 |
| 99 | + weight: 90 |
| 100 | +``` |
| 101 | + |
| 102 | +In this example: |
| 103 | + |
| 104 | +- The `HTTPRoute` is named `inventory` and is associated with a parent gateway named `my-hotel` that has |
| 105 | + two sections, named `http` and `https`. |
| 106 | +- The first routing rule forwards traffic to a backend Service named `inventory-ver1` on port `80`. |
| 107 | + The rule also specifies a weight of `10`. |
| 108 | +- The second routing rule forwards traffic to a backend ServiceImport named `inventory-ver2` on port `80`. |
| 109 | + The rule also specifies a weight of `90`. |
| 110 | +- The amount of traffic forwarded to a backendRef is `(rule weight / total weight) * 100%`. Thus, 10% of the traffic is |
| 111 | + forwarded to `inventory-ver1` at port `80` and 90% of the traffic is forwarded to `inventory-ver2` at the default port. |
| 112 | + |
| 113 | +--- |
| 114 | + |
| 115 | +This `HTTPRoute` documentation provides a detailed introduction, feature set, and a basic example of how to configure |
| 116 | +and use the resource within the EKS Controller project. For in-depth details and specifications, you can refer to the |
| 117 | +official [Gateway API documentation](https://gateway-api.sigs.k8s.io/reference/spec/#gateway.networking.k8s.io/v1alpha2.HTTPRoute). |
0 commit comments