You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Problem: NKG does not support cross-namespace Secret references on Gateway.
Solution: Add support for ReferenceGrants that permit Gateways to reference Secrets
in different namespaces. NKG now processes ReferenceGrants and verifies that
Gateways with references to Secrets in different Namespaces have a corresponding
ReferenceGrant. If no ReferenceGrant exists, the RefNotPermitted reason is used in
all the listener conditions (Accepted, Programmed, and ResolvedRefs), and the
listener is marked invalid. Secrets will only be resolved if the reference is permitted.
No additional validation is needed for ReferenceGrant as it does not correspond to
any nginx config. We treat every upsert/delete of a ReferenceGrant as a change.
This means we will regenerate nginx config every time a ReferenceGrant is created,
updated (generation must change), or deleted, even if it does not apply to the
accepted Gateway.
Copy file name to clipboardExpand all lines: examples/https-termination/README.md
+74-12Lines changed: 74 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,8 @@
1
1
# HTTPS Termination Example
2
2
3
-
In this example, we expand on the simple [cafe-example](../cafe-example) by adding HTTPS termination to our routes and an HTTPS redirect from port 80 to 443.
3
+
In this example, we expand on the simple [cafe-example](../cafe-example) by adding HTTPS termination to our routes and
4
+
an HTTPS redirect from port 80 to 443. We will also show how you can use a ReferenceGrant to permit your Gateway to
5
+
reference a Secret in a different Namespace.
4
6
5
7
## Running the Example
6
8
@@ -40,37 +42,50 @@ In this example, we expand on the simple [cafe-example](../cafe-example) by addi
40
42
41
43
## 3. Configure HTTPS Termination and Routing
42
44
43
-
1. Create a Secret with a TLS certificate and key:
45
+
1. Create the Namespace `certificate` and a Secret with a TLS certificate and key:
The TLS certificate and key in this Secret are used to terminate the TLS connections for the cafe application.
49
-
**Important**: This certificate and key are for demo purposes only.
51
+
> **Important**: This certificate and key are for demo purposes only.
52
+
53
+
1. Create the `ReferenceGrant`:
54
+
```
55
+
kubectl apply -f reference-grant.yaml
56
+
```
57
+
58
+
This ReferenceGrant allows all Gateways in the `default` namespace to reference the `cafe-secret` Secret in
59
+
the `certificate` namespace.
50
60
51
61
1. Create the `Gateway` resource:
52
62
```
53
63
kubectl apply -f gateway.yaml
54
64
```
55
65
56
66
This [Gateway](./gateway.yaml) configures:
57
-
*`http` listener for HTTP traffic
58
-
*`https` listener for HTTPS traffic. It terminates TLS connections using the `cafe-secret` we created in step 1.
67
+
*`http` listener for HTTP traffic
68
+
*`https` listener for HTTPS traffic. It terminates TLS connections using the `cafe-secret` we created in step 1.
59
69
60
70
1. Create the `HTTPRoute` resources:
61
71
```
62
72
kubectl apply -f cafe-routes.yaml
63
73
```
64
74
65
-
To configure HTTPS termination for our cafe application, we will bind our `coffee` and `tea` HTTPRoutes to the `https` listener in [cafe-routes.yaml](./cafe-routes.yaml) using the [`parentReference`](https://gateway-api.sigs.k8s.io/references/spec/#gateway.networking.k8s.io/v1beta1.ParentReference) field:
75
+
To configure HTTPS termination for our cafe application, we will bind our `coffee` and `tea` HTTPRoutes to
76
+
the `https` listener in [cafe-routes.yaml](./cafe-routes.yaml) using
77
+
the [`parentReference`](https://gateway-api.sigs.k8s.io/references/spec/#gateway.networking.k8s.io/v1beta1.ParentReference)
78
+
field:
66
79
67
80
```yaml
68
81
parentRefs:
69
82
- name: gateway
70
83
sectionName: https
71
84
```
72
85
73
-
To configure an HTTPS redirect from port 80 to 443, we will bind the special `cafe-tls-redirect` HTTPRoute with a [`HTTPRequestRedirectFilter`](https://gateway-api.sigs.k8s.io/references/spec/#gateway.networking.k8s.io/v1beta1.HTTPRequestRedirectFilter) to the `http` listener:
86
+
To configure an HTTPS redirect from port 80 to 443, we will bind the special `cafe-tls-redirect` HTTPRoute with
87
+
a [`HTTPRequestRedirectFilter`](https://gateway-api.sigs.k8s.io/references/spec/#gateway.networking.k8s.io/v1beta1.HTTPRequestRedirectFilter)
88
+
to the `http` listener:
74
89
75
90
```yaml
76
91
parentRefs:
@@ -80,13 +95,16 @@ In this example, we expand on the simple [cafe-example](../cafe-example) by addi
80
95
81
96
## 4. Test the Application
82
97
83
-
To access the application, we will use `curl` to send requests to the `coffee` and `tea` Services. First, we will access the application over HTTP to test that the HTTPS redirect works. Then we will use HTTPS.
98
+
To access the application, we will use `curl` to send requests to the `coffee` and `tea` Services. First, we will access
99
+
the application over HTTP to test that the HTTPS redirect works. Then we will use HTTPS.
84
100
85
101
### 4.1 Test HTTPS Redirect
86
102
87
-
To test that NGINX sends an HTTPS redirect, we will send requests to the `coffee` and `tea` Services on HTTP port. We will use curl's `--include` option to print the response headers (we are interested in the `Location` header).
103
+
To test that NGINX sends an HTTPS redirect, we will send requests to the `coffee` and `tea` Services on HTTP port. We
104
+
will use curl's `--include` option to print the response headers (we are interested in the `Location` header).
Now we will access the application over HTTPS. Since our certificate is self-signed, we will use curl's `--insecure` option to turn off certificate verification.
128
+
Now we will access the application over HTTPS. Since our certificate is self-signed, we will use curl's `--insecure`
0 commit comments