sigs.k8s.io/gateway-api@v1.0.0/site-src/guides/tcp.md (about)

     1  !!! info "Experimental Channel"
     2  
     3      The `TCPRoute` resource described below is currently only included in the
     4      "Experimental" channel of Gateway API. For more information on release
     5      channels, refer to the [related documentation](https://gateway-api.sigs.k8s.io/concepts/versioning).
     6  
     7  Gateway API is designed to work with multiple protocols and [TCPRoute][tcproute]
     8  is one such route which allows for managing [TCP][tcp] traffic.
     9  
    10  In this example, we have one Gateway resource and two TCPRoute resources that
    11  distribute the traffic with the following rules:
    12  
    13  - All TCP streams on port 8080 of the Gateway are forwarded to port 6000 of
    14    `my-foo-service` Kubernetes Service.
    15  - All TCP streams on port 8090 of the Gateway are forwarded to port 6000 of
    16    `my-bar-service` Kubernetes Service.
    17  
    18  In this example two `TCP` listeners will be applied to the [Gateway][gateway]
    19  in order to route them to two separate backend `TCPRoutes`, note that the
    20  `protocol` set for the `listeners` on the `Gateway` is `TCP`:
    21  
    22  ```yaml
    23  {% include 'experimental/basic-tcp.yaml' %}
    24  ```
    25  
    26  In the above example we separate the traffic for the two separate backend TCP
    27  [Services][svc] by using the `sectionName` field in the `parentRefs`:
    28  
    29  ```yaml
    30  spec:
    31    parentRefs:
    32    - name: my-tcp-gateway
    33      sectionName: foo
    34  ```
    35  
    36  This corresponds directly with the `name` in the `listeners` in the `Gateway`:
    37  
    38  ```yaml
    39    listeners:
    40    - name: foo
    41      protocol: TCP
    42      port: 8080
    43    - name: bar
    44      protocol: TCP
    45      port: 8090
    46  ```
    47  
    48  In this way each `TCPRoute` "attaches" itself to a different port on the
    49  `Gateway` so that the service `my-foo-service` is taking traffic for port `8080`
    50  from outside the cluster and `my-bar-service` takes the port `8090` traffic.
    51  
    52  [tcproute]:/reference/spec/#gateway.networking.k8s.io/v1alpha2.TCPRoute
    53  [tcp]:https://datatracker.ietf.org/doc/html/rfc793
    54  [httproute]:/reference/spec/#gateway.networking.k8s.io/v1alpha2.HTTPRoute
    55  [gateway]:/reference/spec/#gateway.networking.k8s.io/v1alpha2.Gateway
    56  [svc]:https://kubernetes.io/docs/concepts/services-networking/service/