Skip to content

Commit

Permalink
xds: should use TCP as default protocol (#3749)
Browse files Browse the repository at this point in the history
  • Loading branch information
zirain committed Jul 4, 2024
1 parent 780704c commit d6b5415
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 14 deletions.
2 changes: 1 addition & 1 deletion internal/gatewayapi/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ func (t *Translator) processBackendRefs(backendRefs []egv1a1.BackendRef, namespa
return nil, err
}

ds := t.processServiceDestinationSetting(ref.BackendObjectReference, ns, ir.GRPC, resources, envoyProxy)
ds := t.processServiceDestinationSetting(ref.BackendObjectReference, ns, ir.TCP, resources, envoyProxy)
result = append(result, ds)
}
if len(result) == 0 {
Expand Down
12 changes: 8 additions & 4 deletions internal/gatewayapi/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -1307,10 +1307,14 @@ func (t *Translator) processServiceDestinationSetting(
}
}

// support HTTPRouteBackendProtocolH2C
if servicePort.AppProtocol != nil &&
*servicePort.AppProtocol == "kubernetes.io/h2c" {
protocol = ir.HTTP2
// support HTTPRouteBackendProtocolH2C/GRPC
if servicePort.AppProtocol != nil {
switch *servicePort.AppProtocol {
case "kubernetes.io/h2c":
protocol = ir.HTTP2
case "grpc":
protocol = ir.GRPC
}
}

// Route to endpoints by default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ services:
ports:
- name: grpc
port: 9000
appProtocol: grpc
protocol: TCP
targetPort: 9000
endpointSlices:
Expand All @@ -123,6 +124,7 @@ endpointSlices:
addressType: IPv4
ports:
- name: grpc
appProtocol: grpc
protocol: TCP
port: 9090
endpoints:
Expand Down
2 changes: 2 additions & 0 deletions internal/gatewayapi/testdata/envoyproxy-accesslog.in.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ services:
ports:
- name: grpc
port: 9000
appProtocol: grpc
protocol: TCP
targetPort: 9000
endpointSlices:
Expand All @@ -132,6 +133,7 @@ endpointSlices:
ports:
- name: grpc
protocol: TCP
appProtocol: grpc
port: 9090
endpoints:
- addresses:
Expand Down
18 changes: 15 additions & 3 deletions internal/gatewayapi/translator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,16 @@ func TestTranslate(t *testing.T) {
ClusterIP: "3.3.3.3",
Ports: []corev1.ServicePort{
{
Name: "grpc",
Port: 4317,
TargetPort: intstr.IntOrString{IntVal: 4317},
Name: "grpc",
Port: 4317,
TargetPort: intstr.IntOrString{IntVal: 4317},
Protocol: corev1.ProtocolTCP,
AppProtocol: ptr.To("grpc"),
},
{
Name: "zipkin",
Port: 9411,
TargetPort: intstr.IntOrString{IntVal: 9411},
Protocol: corev1.ProtocolTCP,
},
},
Expand All @@ -264,6 +271,11 @@ func TestTranslate(t *testing.T) {
Port: ptr.To[int32](4317),
Protocol: ptr.To(corev1.ProtocolTCP),
},
{
Name: ptr.To("zipkin"),
Port: ptr.To[int32](9411),
Protocol: ptr.To(corev1.ProtocolTCP),
},
},
Endpoints: []discoveryv1.Endpoint{
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ tracing:
- endpoints:
- host: "zipkin.default.svc.cluster.local"
port: 9411
protocol: "GRPC"
protocol: "TCP"
provider:
host: zipkin.default.svc.cluster.local
port: 9411
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,3 @@
perConnectionBufferLimitBytes: 32768
respectDnsTtl: true
type: STRICT_DNS
typedExtensionProtocolOptions:
envoy.extensions.upstreams.http.v3.HttpProtocolOptions:
'@type': type.googleapis.com/envoy.extensions.upstreams.http.v3.HttpProtocolOptions
explicitHttpConfig:
http2ProtocolOptions: {}
1 change: 1 addition & 0 deletions test/e2e/base/manifests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1092,6 +1092,7 @@ spec:
ports:
- name: grpc-als
protocol: TCP
appProtocol: grpc
port: 8080
targetPort: 8080
- name: http-monitoring
Expand Down

0 comments on commit d6b5415

Please sign in to comment.