Skip to content

Commit f60df58

Browse files
authored
TLS_PASSTHROUGH document (#650)
* TLS_PASSTHROUGH documentation
1 parent d3fa856 commit f60df58

19 files changed

+1384
-80
lines changed

.github/workflows/publish-doc.yaml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
push:
55
branches:
66
- main
7+
- 'release-v*.*.*'
78
jobs:
89
publish-docs:
910
runs-on: ubuntu-latest
@@ -24,10 +25,15 @@ jobs:
2425
run: |
2526
python -m pip install --upgrade pip
2627
pip install mkdocs-material mike
27-
- name: Build
28+
- name: Deploy to Mike
2829
run: |
29-
mike deploy 1.0.5 latest --update-aliases --push
30-
mike set-default latest --allow-empty --push
31-
32-
33-
30+
if [[ ${{ github.ref }} == refs/heads/main ]]; then
31+
# Deploy to the mike doc version `dev` and update the `latest` alias for the main branch new git commits
32+
mike deploy dev latest --update-aliases --push
33+
mike set-default latest
34+
elif [[ ${{ github.ref }} == refs/heads/release-v* ]]; then
35+
# Deploy to the mike doc version `vx.x.x` for the new git branches `release-vx.x.x`
36+
branch_name=${{ github.ref }}
37+
version=${branch_name##refs/heads/release-}
38+
mike deploy $version --push
39+
fi

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ go.work*
1616

1717
# gomock generated prog.go
1818
pkg/aws/services/gomock_reflect_*
19-
19+
mocks/controller-runtime/client/gomock_reflect_*
2020
pkg/**/prog.*
2121

2222
# Image build tarballed bundles

docs/api-types/target-group-policy.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,39 @@
33
## Introduction
44

55
By default, AWS Gateway API Controller assumes plaintext HTTP/1 traffic for backend Kubernetes resources.
6-
TargetGroupPolicy is a CRD that can be attached to a Service, which allows the users to define protocol and
6+
TargetGroupPolicy is a CRD that can be attached to Service or ServiceExport, which allows the users to define protocol, protocol version and
77
health check configurations of those backend resources.
88

99
When attaching a policy to a resource, the following restrictions apply:
1010

11-
- A policy can be only attached to `Service` resources.
12-
- The attached resource can only be `backendRef` of `HTTPRoute` and `GRPCRoute`.
11+
- A policy can be attached to `Service` that being `backendRef` of `HTTPRoute`, `GRPCRoute` and `TLSRoute`.
12+
- A policy can be attached to `ServiceExport`.
1313
- The attached resource should exist in the same namespace as the policy resource.
1414

1515
The policy will not take effect if:
16-
1716
- The resource does not exist
1817
- The resource is not referenced by any route
1918
- The resource is referenced by a route of unsupported type
19+
- The ProtocolVersion is non-empty if the TargetGroupPolicy protocol is TCP
20+
21+
Please check the TargetGroupPolicy API Reference for more details. [TargetGroupPolicy API Reference](../api-reference.md#application-networking.k8s.aws/v1alpha1.TargetGroupPolicy)
22+
2023

2124
These restrictions are not forced; for example, users may create a policy that targets a service that is not created yet.
2225
However, the policy will not take effect unless the target is valid.
2326

27+
28+
2429
### Limitations and Considerations
2530

26-
- Attaching TargetGroupPolicy to a resource that is already referenced by a route will result in a replacement
31+
- Attaching TargetGroupPolicy to an existing Service that is already referenced by a route will result in a replacement
2732
of VPC Lattice TargetGroup resource, except for health check updates.
33+
- Attaching TargetGroupPolicy to an existing ServiceExport will result in a replacement of VPC Lattice TargetGroup resource, except for health check updates.
2834
- Removing TargetGroupPolicy of a resource will roll back protocol configuration to default setting. (HTTP1/HTTP plaintext)
2935

3036
## Example Configuration
3137

32-
This will enable TLS traffic between the gateway and Kubernetes service, with customized health check configuration.
33-
34-
Note that the TLS traffic is always terminated at the gateway, so it will be re-encrypted in this case. The gateway does not perform any certificate validations to the certificate on targets.
38+
This will enable HTTPS traffic between the gateway and Kubernetes service, with customized health check configuration.
3539

3640
```
3741
apiVersion: application-networking.k8s.aws/v1alpha1

docs/api-types/tls-route.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# TLSRoute API Reference
2+
3+
## Introduction
4+
5+
With integration of the Gateway API, AWS Gateway API Controller supports `TLSRoute`.
6+
This allows you to define and manage end-to-end TLS encrypted traffic routing to your Kubernetes clusters.
7+
8+
### Considerations
9+
10+
- `TLSRoute` sectionName must refer to a `TLS` protocol listener with `mode: Passthrough` in the parentRefs `Gateway`.
11+
- `TLSRoute` only supports to have one rule.
12+
- `TLSRoute` does not support any rule matching condition.
13+
- The `hostnames` field with exactly one host name is required.
14+
15+
16+
## Example Configuration
17+
18+
Here is a sample configuration that demonstrates how to set up a `TLSRoute` resource to route end-to-end TLS encrypted traffic to a nginx service:
19+
20+
```yaml
21+
apiVersion: gateway.networking.k8s.io/v1alpha2
22+
kind: TLSRoute
23+
metadata:
24+
name: nginx-tls-route
25+
spec:
26+
hostnames:
27+
- nginx-test.my-test.com
28+
parentRefs:
29+
- name: my-hotel-tls-passthrough
30+
sectionName: tls
31+
rules:
32+
- backendRefs:
33+
- name: nginx-tls
34+
kind: Service
35+
port: 443
36+
```
37+
38+
In this example:
39+
40+
- The `TLSRoute` is named ` nginx-tls-route` and is associated with a parent gateway named `my-hotel-tls-passthrough` that has
41+
a listener section named `tls`:
42+
```
43+
- name: tls
44+
protocol: TLS
45+
port: 443
46+
tls:
47+
mode: Passthrough
48+
```
49+
- The `TLSRoute` is configured to route traffic to a k8s service named `nginx-tls` on port 443.
50+
- The `hostnames` field is set to `nginx-test.my-test.com`. The customer must use this hostname to send traffic to the nginx service.
51+
52+
53+
For the detailed tls passthrough traffic connectivity setup, please refer the user guide [here](../guides/tls-passthrough.md).
54+
55+
For the detailed Gateway API `TLSRoute` resource specifications, you can refer to the
56+
Kubernetes official [documentation](https://gateway-api.sigs.k8s.io/reference/spec/#gateway.networking.k8s.io/v1alpha2.TLSRoute).
57+
58+
For the VPC Lattice tls passthrough Listener configuration details, you can refer to the VPC Lattice [documentation](https://docs.aws.amazon.com/vpc-lattice/latest/ug/tls-listeners.html).

docs/contributing/developer.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ And install additional CRDs for the controller:
5858

5959
```bash
6060
kubectl apply -f config/crds/bases/externaldns.k8s.io_dnsendpoints.yaml
61+
kubectl apply -f config/crds/bases/gateway.networking.k8s.io_tlsroutes.yaml
6162
kubectl apply -f config/crds/bases/application-networking.k8s.aws_serviceexports.yaml
6263
kubectl apply -f config/crds/bases/application-networking.k8s.aws_serviceimports.yaml
6364
kubectl apply -f config/crds/bases/application-networking.k8s.aws_targetgrouppolicies.yaml

docs/guides/tls-passthrough.md

Lines changed: 222 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,222 @@
1+
# TLS Passthrough Support
2+
3+
[Kubernetes Gateway API](https://gateway-api.sigs.k8s.io/guides/tls/) lays out the general guidelines on how to configure TLS passthrough. Here are examples on how to use them against AWS Gateway Api controller and VPC Lattice.
4+
5+
## Install Gateway API TLSRoute CRD
6+
7+
The TLSRoute CRD is already included in the helm chart and deployment.yaml, if you are using these 2 methods to install the controller no extra steps needed.
8+
If you want to install the TLSRoute CRD manually by yourself:
9+
```
10+
# Install CRD
11+
kubectl apply -f config/crds/bases/gateway.networking.k8s.io_tlsroutes.yaml
12+
# Verfiy TLSRoute CRD
13+
kubectl get crd tlsroutes.gateway.networking.k8s.io
14+
NAME CREATED AT
15+
tlsroutes.gateway.networking.k8s.io 2024-03-07T23:16:22Z
16+
```
17+
18+
## Setup TLS Passthrough Connectivity in a single cluster
19+
20+
### 1. Configure TLS Passthrough Listener on Gateway
21+
22+
```
23+
kubectl apply -f files/examples/my-gateway-tls-passthrough.yaml
24+
```
25+
26+
```
27+
# tls listener config snips:
28+
apiVersion: gateway.networking.k8s.io/v1beta1
29+
kind: Gateway
30+
metadata:
31+
name: my-hotel-tls-passthrough
32+
spec:
33+
gatewayClassName: amazon-vpc-lattice
34+
listeners:
35+
...
36+
- name: tls
37+
protocol: TLS
38+
port: 443
39+
tls:
40+
mode: Passthrough
41+
...
42+
```
43+
44+
### 2. Configure TLSRoute
45+
46+
```
47+
# Suppose in the below example, we use the "parking" service as the client pod to test the TLS passthrough traffic.
48+
kubectl apply -f files/examples/parking.yaml
49+
50+
# Configure nginx backend service (This nginx image includes a self-signed certificate)
51+
kubectl apply -f files/example/nginx-server-tls-passthrough.yaml
52+
53+
# configure nginx tls route
54+
kubectl apply -f files/examples/tlsroute-nginx.yaml
55+
56+
```
57+
58+
### 3. Verify the controller has reconciled nginx-tls route
59+
60+
Make sure the TLSRoute has the `application-networking.k8s.aws/lattice-assigned-domain-name` annotation and status `Accepted: True`
61+
```
62+
kubectl get tlsroute nginx-tls -o yaml
63+
apiVersion: gateway.networking.k8s.io/v1alpha2
64+
kind: TLSRoute
65+
metadata:
66+
annotations:
67+
application-networking.k8s.aws/lattice-assigned-domain-name: nginx-tls-default-0af995120af2711bc.7d67968.vpc-lattice-svcs.us-west-2.on.aws
68+
...
69+
name: nginx-tls
70+
namespace: default
71+
...
72+
73+
status:
74+
parents:
75+
- conditions:
76+
- lastTransitionTime: .....
77+
message: ""
78+
observedGeneration: 1
79+
reason: Accepted
80+
status: "True"
81+
type: Accepted
82+
- lastTransitionTime: .....
83+
message: ""
84+
observedGeneration: 1
85+
reason: ResolvedRefs
86+
status: "True"
87+
type: ResolvedRefs
88+
controllerName: application-networking.k8s.aws/gateway-api-controller
89+
90+
```
91+
92+
### 4. Verify TLS Passthrough Traffic
93+
94+
```
95+
kubectl get deployment nginx-tls
96+
NAME READY UP-TO-DATE AVAILABLE AGE
97+
nginx-tls 2/2 2 2 1d
98+
99+
# Use the specified TLSRoute hostname to send traffic to the beackend nginx service
100+
kubectl exec deployments/parking -- curl -kv https://nginx-test.my-test.com --resolve nginx-test.my-test.com:443:169.254.171.0
101+
102+
* Trying 169.254.171.0:443...
103+
* Connected to nginx-test.my-test.com (169.254.171.0) port 443 (#0)
104+
....
105+
* TLSv1.2 (OUT), TLS header, Certificate Status (22):
106+
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
107+
* TLSv1.2 (IN), TLS handshake, Server hello (2):
108+
* TLSv1.2 (IN), TLS handshake, Certificate (11):
109+
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
110+
* TLSv1.2 (IN), TLS handshake, Server finished (14):
111+
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
112+
* TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
113+
* TLSv1.2 (OUT), TLS handshake, Finished (20):
114+
* TLSv1.2 (IN), TLS change cipher, Change cipher spec (1):
115+
* TLSv1.2 (IN), TLS handshake, Finished (20): <---------- TLS Handshake from client pod to the backend `nginx-tls` pod successfully, no tls termination in the middle
116+
* SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
117+
* ALPN, server accepted to use h2
118+
....
119+
<body>
120+
<h1>Welcome to nginx!</h1>
121+
<p>If you see this page, the nginx web server is successfully installed and
122+
working. Further configuration is required.</p>
123+
....
124+
125+
```
126+
127+
## Setup TLS Passthrough Connectivity spanning multiple clusters
128+
129+
130+
![tlsoute multi cluster](../images/tlsroute-multi-cluster.png)
131+
132+
### 1. In this example we still use the "parking" Kubernetes service as the client pod to test the cross cluster TLS passthrough traffic.
133+
```
134+
kubectl apply -f files/examples/parking.yaml
135+
```
136+
137+
### 2. In cluster-1, create `tls-rate1` Kubernetes Service:
138+
```
139+
kubectl apply -f files/examples/tls-rate1.yaml
140+
```
141+
142+
### 3. Configure ServiceExport with TargetGroupPolicy `protocol:TCP` in cluster-2
143+
144+
```
145+
# Create tls-rate2 Kubernetes Service in cluster-2
146+
kubectl apply -f files/examples/tls-rate2.yaml
147+
# Create serviceexport in cluster-2
148+
kubectl apply -f files/examples/tls-rate2-export.yaml
149+
# Create targetgroup policy to configure TCP protocol for tls-rate2 in cluster-2
150+
kubectl apply -f files/examples/tls-rate2-targetgrouppolicy.yaml
151+
```
152+
153+
```
154+
# Snips of serviceexport config
155+
apiVersion: application-networking.k8s.aws/v1alpha1
156+
kind: ServiceExport
157+
metadata:
158+
name: tls-rate-2
159+
annotations:
160+
application-networking.k8s.aws/federation: "amazon-vpc-lattice"
161+
# Snips of targetgroup policy config
162+
apiVersion: application-networking.k8s.aws/v1alpha1
163+
kind: TargetGroupPolicy
164+
metadata:
165+
name: tls-rate2
166+
spec:
167+
targetRef:
168+
group: "application-networking.k8s.aws"
169+
kind: ServiceExport
170+
name: tls-rate2
171+
protocol: TCP
172+
```
173+
174+
### 4. Configure ServiceImport in cluster1
175+
176+
```
177+
kubectl apply -f files/examples/tls-rate2-import.yaml
178+
```
179+
180+
### 5. Configure TLSRoute for blue/green deployment
181+
182+
```
183+
kubectl apply -f files/examples/rate-tlsroute-bluegreen.yaml
184+
185+
# snips of TLSRoute span multiple Kubernetes Clusters
186+
apiVersion: gateway.networking.k8s.io/v1alpha2
187+
kind: TLSRoute
188+
metadata:
189+
name: tls-rate
190+
spec:
191+
hostnames:
192+
- tls-rate.my-test.com
193+
parentRefs:
194+
- name: my-hotel-tls
195+
sectionName: tls
196+
rules:
197+
- backendRefs:
198+
- name: tls-rate1 <---------- to Kubernetes Cluster-1
199+
kind: Service
200+
port: 443
201+
weight: 10
202+
- name: tls-rate2 <---------- to Kubernetes Cluster-2
203+
kind: ServiceImport
204+
port: 443
205+
weight: 90
206+
```
207+
### 6. Verify cross-cluster TLS passthrough traffic
208+
209+
Expected to receive the weighted traffic route to tls-rate1 service(10%) and tls-rate2 service(90%), if you curl the `tls-rate.my-test.com` from the client pod multiple times:
210+
```
211+
kubectl exec deploy/parking -- sh -c 'for ((i=1; i<=30; i++)); do curl -k https://tls-rate.my-test.com --resolve tls-rate.my-test.com:443:169.254.171.0 2>/dev/null; done'
212+
213+
Requsting to TLS Pod(tls-rate2-7f8b9cc97b-fgqk6): tls-rate2 handler pod <----> k8s service in cluster-2
214+
Requsting to TLS Pod(tls-rate2-7f8b9cc97b-fgqk6): tls-rate2 handler pod
215+
Requsting to TLS Pod(tls-rate2-7f8b9cc97b-fgqk6): tls-rate2 handler pod
216+
Requsting to TLS Pod(tls-rate2-7f8b9cc97b-fgqk6): tls-rate2 handler pod
217+
Requsting to TLS Pod(tls-rate1-98cc7fd87a-642zw): tls-rate1 handler pod <----> k8s service in cluster-1
218+
Requsting to TLS Pod(tls-rate2-7f8b9cc97b-fgqk6): tls-rate2 handler pod
219+
Requsting to TLS Pod(tls-rate2-7f8b9cc97b-fgqk6): tls-rate2 handler pod
220+
Requsting to TLS Pod(tls-rate2-7f8b9cc97b-fgqk6): tls-rate2 handler pod
221+
Requsting to TLS Pod(tls-rate1-98cc7fd87a-642zw): tls-rate1 handler pod
222+
```
34 KB
Loading
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: gateway.networking.k8s.io/v1beta1
2+
kind: Gateway
3+
metadata:
4+
name: my-hotel-tls-passthrough
5+
spec:
6+
gatewayClassName: amazon-vpc-lattice
7+
listeners:
8+
- name: http
9+
protocol: HTTP
10+
port: 80
11+
- name: tls
12+
protocol: TLS
13+
port: 443
14+
tls:
15+
mode: Passthrough

0 commit comments

Comments
 (0)