Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelogs/unreleased/6616-Krast76-small.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Contour, support http and https as AppProtocol in k8s' services
4 changes: 4 additions & 0 deletions internal/dag/accessors.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,17 @@ func validateExternalName(svc *core_v1.Service, enableExternalNameSvc bool) erro
const (
protoK8sH2C = "kubernetes.io/h2c"
protoK8sWS = "kubernetes.io/ws"
protoHTTPS = "https"
protoHTTP = "http"
)

func toContourProtocol(appProtocol string) (string, bool) {
proto, ok := map[string]string{
// *NOTE: for gateway-api: the websocket is enabled by default
protoK8sWS: "",
protoK8sH2C: "h2c",
protoHTTP: "",
protoHTTPS: "tls",
}[appProtocol]
return proto, ok
}
Expand Down
22 changes: 22 additions & 0 deletions internal/dag/accessors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,18 @@ func TestBuilderLookupService(t *testing.T) {
AppProtocol: ptr.To("kubernetes.io/wss"),
Port: 8444,
},
{
Name: "iana-https",
Protocol: "TCP",
AppProtocol: ptr.To("https"),
Port: 8445,
},
{
Name: "iana-http",
Protocol: "TCP",
AppProtocol: ptr.To("http"),
Port: 8446,
},
},
},
}
Expand Down Expand Up @@ -218,6 +230,16 @@ func TestBuilderLookupService(t *testing.T) {
port: 8444,
want: appProtcolService(appProtoService, "", 1),
},
"lookup service by port number with supported IANA app protocol: https": {
NamespacedName: types.NamespacedName{Name: appProtoService.Name, Namespace: appProtoService.Namespace},
port: 8445,
want: appProtcolService(appProtoService, "tls", 2),
},
"lookup service by port number with supported IANA app protocol: http": {
NamespacedName: types.NamespacedName{Name: appProtoService.Name, Namespace: appProtoService.Namespace},
port: 8446,
want: appProtcolService(appProtoService, "", 3),
},
}

for name, tc := range tests {
Expand Down