Skip to content

Commit d3eade0

Browse files
authored
Merge pull request #2533 from kubernetes-sigs/v1-docs
v1.0 docs
2 parents a068498 + 14f2e31 commit d3eade0

File tree

7 files changed

+191
-15
lines changed

7 files changed

+191
-15
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
apiVersion: gateway.networking.k8s.io/v1
2+
kind: HTTPRoute
3+
metadata:
4+
name: timeout-example
5+
spec:
6+
parentRefs:
7+
- name: example-gateway
8+
rules:
9+
- matches:
10+
- path:
11+
type: PathPrefix
12+
value: /timeout
13+
timeouts:
14+
request: 10s
15+
backendRequest: 2s
16+
backendRefs:
17+
- name: timeout-svc
18+
port: 8080
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#$ Used in:
2+
#$ - site-src/guides/tls.md
3+
apiVersion: gateway.networking.k8s.io/v1alpha2
4+
kind: BackendTLSPolicy
5+
metadata:
6+
name: tls-upstream-auth
7+
spec:
8+
targetRef:
9+
kind: Service
10+
name: auth-service
11+
group: ""
12+
tls:
13+
caCertRefs:
14+
- kind: ConfigMapReference
15+
name: auth-cert
16+
group: ""
17+
hostname: auth.example.com
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#$ Used in:
2+
#$ - site-src/guides/tls.md
3+
apiVersion: gateway.networking.k8s.io/v1alpha2
4+
kind: BackendTLSPolicy
5+
metadata:
6+
name: tls-upstream-dev
7+
spec:
8+
targetRef:
9+
kind: Service
10+
name: dev-service
11+
group: ""
12+
tls:
13+
wellKnownCACerts: "System"
14+
hostname: dev.example.com

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ nav:
7979
- TCP routing: guides/tcp.md
8080
- gRPC Routing: guides/grpc-routing.md
8181
- Migrating from Ingress: guides/migrating-from-ingress.md
82+
- Backend Protocol Selection: guides/backend-protocol.md
8283
- Reference:
8384
- Implementer's Guide: reference/implementers-guide.md
8485
- API Types:

site-src/api-types/httproute.md

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ The specification of an HTTPRoute consists of:
1717
matching the Host header of HTTP requests.
1818
- [Rules][httprouterule]- Define a list of rules to perform actions against
1919
matching HTTP requests. Each rule consists of [matches][matches],
20-
[filters][filters] (optional), and [backendRefs][backendRef] (optional)
20+
[filters][filters] (optional), [backendRefs][backendRef] (optional) and [timeouts][timeouts] (optional)
2121
fields.
2222

2323
The following illustrates an HTTPRoute that sends all traffic to one Service:
@@ -165,6 +165,44 @@ Service:
165165
Reference the [backendRef][backendRef] API documentation for additional details
166166
on `weight` and other fields.
167167

168+
#### Timeouts (optional)
169+
170+
??? example "Experimental Channel in v1.0.0+"
171+
172+
HTTPRoute timeouts are part of the Experimental Channel in `v1.0.0+`.
173+
174+
HTTPRoute Rules include a `Timeouts` field. If unspecified, timeout behavior is implementation-specific.
175+
176+
There are 2 kinds of timeouts that can be configured in an HTTPRoute Rule:
177+
178+
1. `request` is the timeout for the Gateway API implementation to send a response to a client HTTP request. This timeout is intended to cover as close to the whole request-response transaction as possible, although an implementation MAY choose to start the timeout after the entire request stream has been received instead of immediately after the transaction is initiated by the client.
179+
180+
2. `backendRequest` is a timeout for a single request from the Gateway to a backend. This timeout covers the time from when the request first starts being sent from the gateway to when the full response has been received from the backend. This can be particularly helpful if the Gateway retries connections to a backend.
181+
182+
Because the `request` timeout encompasses the `backendRequest` timeout, the value of `backendRequest` must not be greater than the value of `request` timeout.
183+
184+
Timeouts are optional, and their fields are of type [Duration](/geps/gep-2257/). A zero-valued timeout ("0s") MUST be interpreted as disabling the timeout. A valid non-zero-valued timeout MUST be >= 1ms.
185+
186+
The following example uses the `request` field which will cause a timeout if a client request is taking longer than 10 seconds to complete. The example also defines a 2s `backendRequest` which specifies a timeout for an individual request from the gateway to a backend service `timeout-svc`:
187+
```yaml
188+
{% include 'experimental/http-route-timeouts/timeout-example.yaml' %}
189+
```
190+
191+
Reference the [timeouts][timeouts] API documentation for additional details.
192+
193+
##### Backend Protocol
194+
195+
??? example "Experimental Channel in v1.0.0+"
196+
197+
This concept is part of the Experimental Channel in `v1.0.0+`.
198+
199+
200+
Some implementations may require the [backendRef][backendRef] to be labeled
201+
explicitly in order to route traffic using a certain protocol. For Kubernetes
202+
Service backends this can be done by specifying the [`appProtocol`][appProtocol]
203+
field.
204+
205+
168206
## Status
169207

170208
Status defines the observed state of HTTPRoute.
@@ -214,4 +252,5 @@ resolution applies to merging, refer to the [API specification][httprouterule].
214252
[filters]: /reference/spec/#gateway.networking.k8s.io/v1beta1.HTTPRouteFilter
215253
[backendRef]: /reference/spec/#gateway.networking.k8s.io/v1beta1.HTTPBackendRef
216254
[parentRef]: /reference/spec/#gateway.networking.k8s.io/v1beta1.ParentRef
217-
255+
[timeouts]: /reference/spec/#gateway.networking.k8s.io/v1.HTTPRouteTimeouts
256+
[appProtocol]: https://kubernetes.io/docs/concepts/services-networking/service/#application-protocol

site-src/guides/backend-protocol.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Backend Protocol
2+
3+
??? example "Experimental Channel in v1.0.0+"
4+
5+
This concept is part of the Experimental Channel in `v1.0.0+`.
6+
7+
Not all implementations of Gateway API support automatic protocol selection. In some cases protocols are disabled without an explicit opt-in.
8+
9+
When a Route's backend references a Kubernetes Service, application developers can specify the protocol using `ServicePort` [`appProtocol`][appProtocol] field.
10+
11+
For example the following `store` Kubernetes Service is indicating the port `8080` supports HTTP/2 Prior Knowledge.
12+
13+
14+
```yaml
15+
apiVersion: v1
16+
kind: Service
17+
metadata:
18+
name: store
19+
spec:
20+
selector:
21+
app: store
22+
ports:
23+
- protocol: TCP
24+
appProtocol: kubernetes.io/h2c
25+
port: 8080
26+
targetPort: 8080
27+
```
28+
29+
Currently, Gateway API has conformance testing for:
30+
31+
- `kubernetes.io/h2c` - HTTP/2 Prior Knowledge
32+
- `kubernetes.io/ws` - WebSocket over HTTP
33+
34+
[appProtocol]: https://kubernetes.io/docs/concepts/services-networking/service/#application-protocol

site-src/guides/tls.md

Lines changed: 66 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# TLS Configuration
22

3-
Gateway API allow for a variety of ways to configure TLS. This document lays
3+
Gateway API allows for a variety of ways to configure TLS. This document lays
44
out various TLS settings and gives general guidelines on how to use them
55
effectively.
66

77
!!! info "Experimental Channel"
88

9-
The `TLSRoute` resource described below is currently only included in the
9+
The `TLSRoute` and `BackendTLSPolicy` resources described below are currently only included in the
1010
"Experimental" channel of Gateway API. For more information on release
1111
channels, refer to the [related documentation](https://gateway-api.sigs.k8s.io/concepts/versioning).
1212

@@ -23,32 +23,36 @@ For Gateways, there are two connections involved:
2323
With Gateway API, TLS configuration of downstream and
2424
upstream connections is managed independently.
2525

26-
Depending on the Listener Protocol, different TLS modes and Route types are supported.
26+
For downstream connections, depending on the Listener Protocol, different TLS modes and Route types are supported.
2727

28-
Listener Protocol | TLS Mode | Route Type Supported
29-
--- | --- | ---
30-
TLS | Passthrough | TLSRoute
31-
TLS | Terminate | TCPRoute
32-
HTTPS | Terminate | HTTPRoute
28+
| Listener Protocol | TLS Mode | Route Type Supported |
29+
|-------------------|-------------|---------------------|
30+
| TLS | Passthrough | TLSRoute |
31+
| TLS | Terminate | TCPRoute |
32+
| HTTPS | Terminate | HTTPRoute |
3333

3434
Please note that in case of `Passthrough` TLS mode, no TLS settings take
35-
effect as the TLS session from the client is NOT terminated at the Gateway.
36-
The rest of the document assumes that TLS is being terminated at the Gateway,
37-
which is the default setting.
35+
effect as the TLS session from the client is NOT terminated at the Gateway, but rather
36+
passes through the Gateway, encrypted.
37+
38+
For upstream connections, `BackendTLSPolicy` is used, and neither listener protocol nor TLS mode apply to the
39+
upstream TLS configuration. For `HTTPRoute`, the use of both `Terminate` TLS mode and `BackendTLSPolicy` is supported.
40+
Using these together provides what is commonly known as a connection that is terminated and then re-encrypted at
41+
the Gateway.
3842

3943
## Downstream TLS
4044

4145
Downstream TLS settings are configured using listeners at the Gateway level.
4246

4347
### Listeners and TLS
4448

45-
Listeners expose the TLS setting on a per domain or sub-domain basis.
49+
Listeners expose the TLS setting on a per domain or subdomain basis.
4650
TLS settings of a listener are applied to all domains that satisfy the
4751
`hostname` criteria.
4852

4953
In the following example, the Gateway serves the TLS certificate
5054
defined in the `default-cert` Secret resource for all requests.
51-
Although, the example refers to HTTPS protocol, one can also use the same
55+
Although the example refers to HTTPS protocol, one can also use the same
5256
feature for TLS-only protocol along with TLSRoutes.
5357

5458
```yaml
@@ -98,6 +102,55 @@ would be invalid.
98102
{% include 'standard/tls-cert-cross-namespace.yaml' %}
99103
```
100104

105+
## Upstream TLS
106+
107+
Upstream TLS settings are configured using the experimental `BackendTLSPolicy`
108+
attached to a `Service` via a target reference.
109+
110+
This resource can be used to describe the SNI the Gateway should use to connect to the
111+
backend and how the certificate served by the backend Pod(s) should be verified.
112+
113+
### TargetRefs and TLS
114+
115+
BackendTLSPolicy contains specification for the `TargetRef` and `TLS`. TargetRef is required and
116+
identifies the `Service` for which your HTTPRoute requires TLS. The `TLS` configuration contains a
117+
required `Hostname`, and either `CACertRefs` or `WellKnownCACerts`.
118+
119+
Hostname refers to the SNI the Gateway should use to connect to the backend, and
120+
must match the certificate served by the backend pod.
121+
122+
CACertRefs refer to one or more PEM-encoded TLS certificates. If there are no specific certificates
123+
to use, then you must set WellKnownCACerts to "System" to tell the Gateway to use a set of trusted
124+
CA Certificates. There may be some variation in which system certificates are used by each implementation.
125+
Refer to documentation from your implementation of choice for more information.
126+
127+
!!! info "Restrictions"
128+
129+
- Cross-namespace certificate references are not allowed.
130+
- Wildcard hostnames are not allowed.
131+
132+
### Examples
133+
134+
#### Using System Certificates
135+
136+
In this example, the `BackendTLSPolicy` is configured to use system certificates to connect with a
137+
TLS-encrypted upstream connection where Pods backing the `dev` Service are expected to serve a valid
138+
certificate for `dev.example.com`.
139+
140+
```yaml
141+
{% include 'experimental/v1alpha2/backendtlspolicy-system-certs.yaml' %}
142+
```
143+
144+
#### Using Explicit CA Certificates
145+
146+
In this example, the `BackendTLSPolicy` is configured to use certificates defined in the configuration
147+
map `auth-cert` to connect with a TLS-encrypted upstream connection where Pods backing the `auth` Service
148+
are expected to serve a valid certificate for `auth.example.com`.
149+
150+
```yaml
151+
{% include 'experimental/v1alpha2/backendtlspolicy-ca-certs.yaml' %}
152+
```
153+
101154
## Extensions
102155

103156
Gateway TLS configurations provides an `options` map to add additional TLS

0 commit comments

Comments
 (0)