Skip to content

Commit eae5a24

Browse files
authored
fix: secure by default (defaults from Gateway), working sectionName for HTTPRoute (#7901)
1 parent 37230d2 commit eae5a24

67 files changed

Lines changed: 996 additions & 779 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,19 @@ Adding a new version? You'll need three changes:
122122
- [0.0.5](#005)
123123
- [0.0.4 and prior](#004-and-prior)
124124

125+
## Unreleased
126+
127+
> Release date: TBD
128+
129+
### Fixed
130+
131+
- **Changed (potentially breaking):** As part of our secure-by-default initiative, everything out of the box relies on
132+
defaults from Kong Gateway. It may break existing configurations that relied on previous implicit protocol behavior
133+
(access via http will result `426` status code.), when version of Kong Gateway will change.
134+
- For `HTTPRoute`, protocol now matches the attached Gateway listener protocol (and when `parentRef.sectionName` is set, it must match that specific listener). When `parentRef.sectionName` is not specified it binds to all `Gateway`s listeners.
135+
- For `Ingress`, default protocol relies on Kong Gateway, can be set explicitly via `konghq.com/protocols: "http"` (or `https`)
136+
annotation on particular `Ingress`.
137+
125138
## [3.5.6]
126139

127140
> Release date: 2026-03-31

examples/gateway-httproute-broken-plugin-fallback.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ metadata:
107107
spec:
108108
gatewayClassName: kong
109109
listeners:
110-
- name: http
111-
protocol: HTTP
112-
port: 80
110+
- name: https
111+
protocol: HTTPS
112+
port: 443
113113
---
114114
apiVersion: gateway.networking.k8s.io/v1
115115
kind: HTTPRoute

examples/gateway-httproute-rewrite-path.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ metadata:
7474
spec:
7575
gatewayClassName: kong
7676
listeners:
77-
- name: http
78-
protocol: HTTP
79-
port: 80
77+
- name: https
78+
protocol: HTTPS
79+
port: 443
8080
---
8181
apiVersion: gateway.networking.k8s.io/v1
8282
kind: HTTPRoute

examples/gateway-httproute.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ metadata:
108108
spec:
109109
gatewayClassName: kong
110110
listeners:
111+
- name: https
112+
protocol: HTTPS
113+
port: 443
111114
- name: http
112115
protocol: HTTP
113116
port: 80
@@ -121,6 +124,7 @@ metadata:
121124
spec:
122125
parentRefs:
123126
- name: kong
127+
sectionName: https
124128
rules:
125129
- matches:
126130
- path:
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
# Usage:
2-
# -----
3-
# go run internal/cmd/main.go
4-
# kubectl apply -f examples/httpbin.yaml
5-
# kubectl get secrets kong-config -o=go-template='{{index .data "networking.k8s.io-v1-Ingress-default-httpbin-ingress" }}' | base64 -d
1+
# By default Ingress relies on Kong Gateway default setting, which differ by version.
2+
# To ensure HTTP, add annotation `konghq.com/protocols: "http"` on Ingress resource.
3+
# See examples/ingress-https.yaml for a HTTPS example .
64
---
75
apiVersion: apps/v1
86
kind: Deployment
@@ -47,6 +45,7 @@ metadata:
4745
name: httpbin-ingress
4846
annotations:
4947
konghq.com/strip-path: "true"
48+
konghq.com/protocols: "http"
5049
spec:
5150
ingressClassName: kong
5251
rules:

examples/ingress-https.yaml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# By default Ingress relies on Kong Gateway default setting, which differ by version.
2+
# To ensure HTTPS, add annotation `konghq.com/protocols: "https"` on Ingress resource.
3+
# See examples/ingress-http.yaml for a HTTP example .
4+
---
5+
apiVersion: apps/v1
6+
kind: Deployment
7+
metadata:
8+
name: httpbin-deployment
9+
labels:
10+
app: httpbin
11+
spec:
12+
replicas: 1
13+
selector:
14+
matchLabels:
15+
app: httpbin
16+
template:
17+
metadata:
18+
labels:
19+
app: httpbin
20+
spec:
21+
containers:
22+
- name: httpbin
23+
image: kong/httpbin:0.1.0
24+
ports:
25+
- containerPort: 80
26+
---
27+
apiVersion: v1
28+
kind: Service
29+
metadata:
30+
labels:
31+
app: httpbin
32+
name: httpbin-deployment
33+
spec:
34+
ports:
35+
- port: 80
36+
protocol: TCP
37+
targetPort: 80
38+
selector:
39+
app: httpbin
40+
type: ClusterIP
41+
---
42+
apiVersion: networking.k8s.io/v1
43+
kind: Ingress
44+
metadata:
45+
name: httpbin-ingress
46+
annotations:
47+
konghq.com/protocols: "https"
48+
konghq.com/strip-path: "true"
49+
spec:
50+
ingressClassName: kong
51+
rules:
52+
- http:
53+
paths:
54+
- path: /
55+
pathType: Prefix
56+
backend:
57+
service:
58+
name: httpbin-deployment
59+
port:
60+
number: 80

internal/dataplane/testdata/golden/fallback-config-ingress/default_golden.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ services:
1919
paths:
2020
- ~/valid$
2121
preserve_host: true
22-
protocols:
23-
- http
24-
- https
2522
regex_priority: 0
2623
request_buffering: true
2724
response_buffering: true

internal/dataplane/testdata/golden/fallback-config-kong-custom-entities-ee/default_golden.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@ services:
3535
paths:
3636
- /
3737
preserve_host: true
38-
protocols:
39-
- http
40-
- https
4138
regex_priority: 0
4239
request_buffering: true
4340
response_buffering: true

internal/dataplane/testdata/golden/fallback-config-service/default_golden.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ services:
1919
paths:
2020
- ~/valid$
2121
preserve_host: true
22-
protocols:
23-
- http
24-
- https
2522
regex_priority: 0
2623
request_buffering: true
2724
response_buffering: true

internal/dataplane/testdata/golden/host-header-annotation-httproute/default_golden.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ services:
1717
- ~/httpbin$
1818
- /httpbin/
1919
preserve_host: true
20-
protocols:
21-
- http
22-
- https
2320
strip_path: true
2421
tags:
2522
- k8s-name:httpbin

0 commit comments

Comments
 (0)