Skip to content

Commit 70f518b

Browse files
committed
Adds TLS Termination to Gateway API type
1 parent 545e72b commit 70f518b

File tree

5 files changed

+383
-58
lines changed

5 files changed

+383
-58
lines changed

api/v1alpha1/gateway_types.go

Lines changed: 82 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,12 @@ type GatewaySpec struct {
5656
// Listeners associated with this Gateway. Listeners define what addresses,
5757
// ports, protocols are bound on this Gateway.
5858
Listeners []Listener `json:"listeners"`
59-
// Routes associated with this Gateway. Routes define
60-
// protocol-specific routing to backends (e.g. Services).
61-
Routes []core.TypedLocalObjectReference `json:"routes"`
59+
// Routes defines routes to associate with the Gateway.
60+
//
61+
// Support: Core
62+
//
63+
// +optional
64+
Routes []Route `json:"routes,omitempty"`
6265
}
6366

6467
const (
@@ -68,6 +71,25 @@ const (
6871
HTTPSProcotol = "HTTPS"
6972
)
7073

74+
// Route defines the schema for a route.
75+
type Route struct {
76+
// RouteRef is a reference to an object to associate with the Gateway.
77+
// RouteRef defines protocol-specific routing to back-ends (e.g. Services).
78+
//
79+
// If unspecified, no routes will be associated to the Gateway.
80+
//
81+
// Support: Core
82+
//
83+
// +optional
84+
RouteRef core.ObjectReference `json:"routeRef"`
85+
// TLS is the configuration used for establishing a TLS connection.
86+
//
87+
// Support: Core
88+
//
89+
// +optional
90+
TLS *TLSConfig `json:"tls,omitempty"`
91+
}
92+
7193
// Listener defines a
7294
type Listener struct {
7395
// Name is the listener's name and should be specified as an
@@ -87,7 +109,7 @@ type Listener struct {
87109
// the request address is invalid, the GatewayClass MUST indicate
88110
// this in the associated entry in GatewayStatus.Listeners.
89111
//
90-
// Support:
112+
// Support: Core
91113
//
92114
// +optional
93115
Address *ListenerAddress `json:"address,omitempty"`
@@ -107,7 +129,7 @@ type Listener struct {
107129
// Support: Core
108130
//
109131
// +optional
110-
TLS *ListenerTLS `json:"tls,omitempty"`
132+
TLS *TLSConfig `json:"tls,omitempty"`
111133
// Extension for this Listener.
112134
//
113135
// Support: custom.
@@ -149,7 +171,7 @@ const (
149171
TLS1_3 = "TLS1_3"
150172
)
151173

152-
// ListenerTLS describes the TLS configuration for a given port.
174+
// TLSConfig describes configuration for establishing a TLS connection.
153175
//
154176
// References
155177
// - nginx: https://nginx.org/en/docs/http/configuring_https_servers.html
@@ -158,20 +180,41 @@ const (
158180
// - gcp: https://cloud.google.com/load-balancing/docs/use-ssl-policies#creating_an_ssl_policy_with_a_custom_profile
159181
// - aws: https://docs.aws.amazon.com/elasticloadbalancing/latest/application/create-https-listener.html#describe-ssl-policies
160182
// - azure: https://docs.microsoft.com/en-us/azure/app-service/configure-ssl-bindings#enforce-tls-1112
161-
type ListenerTLS struct {
183+
type TLSConfig struct {
162184
// Certificates is a reference to one or more Kubernetes objects each containing
163-
// an identity certificate that is bound to the listener. The hostname in a TLS
185+
// an identity certificate that is bound to a listener. The hostname in a TLS
164186
// SNI client hello message is used for certificate matching and route hostname
165-
// selection. The SNI server_name must match a route hostname for the Gateway to
166-
// route the TLS request.
187+
// selection.
167188
//
168189
// If apiGroup and kind are empty, will default to Kubernetes Secrets resources.
169190
//
170191
// Support: Core (Kubernetes Secrets)
171192
// Support: Implementation-specific (Other resource types)
172193
//
173-
// +required
174-
Certificates []core.TypedLocalObjectReference `json:"certificates"`
194+
// +optional
195+
ListenerCertificates []core.TypedLocalObjectReference `json:"listenerCertificates,omitempty"`
196+
// CACertificates is a reference to one or more Kubernetes objects
197+
// each containing a CA certificate used by the TLS client for
198+
// establishing a connection with a server.
199+
//
200+
// Here is a ConfigMap example (in yaml):
201+
//
202+
// apiVersion: v1
203+
// kind: ConfigMap
204+
// metadata:
205+
// name: my-dest-svc-ca
206+
// namespace: my-dest-svc-namespace
207+
// data:
208+
// ca-bundle.crt: |
209+
// -----BEGIN CERTIFICATE-----
210+
// Destination Service CA Certificate Bundle.
211+
// -----END CERTIFICATE-----
212+
//
213+
// Support: Core (Kubernetes ConfigMap)
214+
// Support: Implementation-specific (For other resource types)
215+
//
216+
// +optional
217+
CACertificates []core.TypedLocalObjectReference `json:"caCertificates,omitempty"`
175218
// MinimumVersion of TLS allowed. It is recommended to use one of
176219
// the TLS_* constants above. Note: this is not strongly
177220
// typed to allow implementation-specific versions to be used without
@@ -182,7 +225,15 @@ type ListenerTLS struct {
182225
// values.
183226
//
184227
// +optional
185-
MinimumVersion *string `json:"minimumVersion"`
228+
MinimumVersion *string `json:"minimumVersion,omitempty"`
229+
// TLSTermination defines how to terminate TLS connections.
230+
//
231+
// If unspecified, TLS termination type "Edge" will be used.
232+
//
233+
// Support: Core
234+
//
235+
// +optional
236+
TLSTermination TLSTerminationType `json:"tlsTermination,omitempty"`
186237
// Options are a list of key/value pairs to give extended options
187238
// to the provider.
188239
//
@@ -192,9 +243,26 @@ type ListenerTLS struct {
192243
// construct.
193244
//
194245
// Support: Implementation-specific.
195-
Options map[string]string `json:"options"`
246+
//
247+
// +optional
248+
Options map[string]string `json:"options,omitempty"`
196249
}
197250

251+
// TLSTerminationType specifies where TLS connections will terminate.
252+
type TLSTerminationType string
253+
254+
const (
255+
// TLSTerminationEdge terminates the TLS connection at the gateway.
256+
TLSTerminationEdge TLSTerminationType = "Edge"
257+
258+
// TLSTerminationPassthrough terminates the TLS connection at the
259+
// destination service. The destination service is responsible for
260+
// decrypting data from the connection. The Gateway listener must be
261+
// configured for the HTTPS protocol. SNI is used by the Gateway to
262+
// perform route selection.
263+
TLSTerminationPassthrough TLSTerminationType = "Passthrough"
264+
)
265+
198266
// GatewayStatus defines the observed state of Gateway.
199267
type GatewayStatus struct {
200268
// Conditions describe the current conditions of the Gateway.

api/v1alpha1/httproute_types.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,6 @@ type HTTPHeaderFilter struct {
180180
type HTTPRouteAction struct {
181181
// ForwardTo sends requests to the referenced object.
182182
ForwardTo *core.TypedLocalObjectReference `json:"forwardTo"`
183-
184183
// Extension is an optional, implementation-specific extension
185184
// to the "action" behavior.
186185
//

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 37 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)