Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Set AppProtocol on Services (#14757)" #14805

Merged
merged 1 commit into from
Jan 17, 2024
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
19 changes: 8 additions & 11 deletions pkg/reconciler/route/resources/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,9 @@ func MakeK8sPlaceholderService(ctx context.Context, route *v1.Route, tagName str
ExternalName: domainName,
SessionAffinity: corev1.ServiceAffinityNone,
Ports: []corev1.ServicePort{{
Name: netapi.ServicePortNameH2C,
AppProtocol: &netapi.AppProtocolH2C,
Port: int32(80),
TargetPort: intstr.FromInt(80),
Name: netapi.ServicePortNameH2C,
Port: int32(80),
TargetPort: intstr.FromInt(80),
}},
},
}, nil
Expand Down Expand Up @@ -102,10 +101,9 @@ func MakeK8sService(ctx context.Context, route *v1.Route, tagName string, ingres
ObjectMeta: makeServiceObjectMeta(hostname, route),
Spec: corev1.ServiceSpec{
Ports: []corev1.ServicePort{{
Name: netapi.ServicePortNameH2C,
AppProtocol: &netapi.AppProtocolH2C,
Port: int32(80),
TargetPort: intstr.FromInt(80),
Name: netapi.ServicePortNameH2C,
Port: int32(80),
TargetPort: intstr.FromInt(80),
}},
},
},
Expand All @@ -130,9 +128,8 @@ func MakeK8sService(ctx context.Context, route *v1.Route, tagName string, ingres
IP: balancer.IP,
}},
Ports: []corev1.EndpointPort{{
Name: netapi.ServicePortNameH2C,
AppProtocol: &netapi.AppProtocolH2C,
Port: int32(80),
Name: netapi.ServicePortNameH2C,
Port: int32(80),
}},
}},
}
Expand Down
24 changes: 10 additions & 14 deletions pkg/reconciler/route/resources/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,9 @@ var (
}

expectedPorts = []corev1.ServicePort{{
Name: netapi.ServicePortNameH2C,
AppProtocol: &netapi.AppProtocolH2C,
Port: int32(80),
TargetPort: intstr.FromInt(80),
Name: netapi.ServicePortNameH2C,
Port: int32(80),
TargetPort: intstr.FromInt(80),
}}
)

Expand Down Expand Up @@ -124,9 +123,8 @@ func TestMakeK8SService(t *testing.T) {
IP: "some-ip",
}},
Ports: []corev1.EndpointPort{{
Name: netapi.ServicePortNameH2C,
AppProtocol: &netapi.AppProtocolH2C,
Port: int32(80),
Name: netapi.ServicePortNameH2C,
Port: int32(80),
}},
}},
}, {
Expand Down Expand Up @@ -202,9 +200,8 @@ func TestMakeK8SService(t *testing.T) {
IP: "some-ip",
}},
Ports: []corev1.EndpointPort{{
Name: netapi.ServicePortNameH2C,
AppProtocol: &netapi.AppProtocolH2C,
Port: int32(80),
Name: netapi.ServicePortNameH2C,
Port: int32(80),
}},
}},
}, {
Expand Down Expand Up @@ -395,10 +392,9 @@ func TestMakePlaceholderService(t *testing.T) {
ExternalName: tt.expectedExternalName,
SessionAffinity: corev1.ServiceAffinityNone,
Ports: []corev1.ServicePort{{
Name: netapi.ServicePortNameH2C,
AppProtocol: &netapi.AppProtocolH2C,
Port: int32(80),
TargetPort: intstr.FromInt(80),
Name: netapi.ServicePortNameH2C,
Port: int32(80),
TargetPort: intstr.FromInt(80),
}},
}

Expand Down
16 changes: 7 additions & 9 deletions pkg/reconciler/serverlessservice/resources/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,10 @@ func MakePublicService(sks *v1alpha1.ServerlessService) *corev1.Service {

func makePublicServicePorts(sks *v1alpha1.ServerlessService) []corev1.ServicePort {
ports := []corev1.ServicePort{{
Name: pkgnet.ServicePortName(sks.Spec.ProtocolType),
Protocol: corev1.ProtocolTCP,
AppProtocol: pkgnet.AppProtocol(sks.Spec.ProtocolType),
Port: int32(pkgnet.ServicePort(sks.Spec.ProtocolType)),
TargetPort: targetPort(sks),
Name: pkgnet.ServicePortName(sks.Spec.ProtocolType),
Protocol: corev1.ProtocolTCP,
Port: int32(pkgnet.ServicePort(sks.Spec.ProtocolType)),
TargetPort: targetPort(sks),
}, {
// The HTTPS port is used when activator-ca is enabled.
// Although it is not used by default, we put it here as it should be harmless
Expand Down Expand Up @@ -145,10 +144,9 @@ func MakePrivateService(sks *v1alpha1.ServerlessService, selector map[string]str
},
Spec: corev1.ServiceSpec{
Ports: []corev1.ServicePort{{
Name: pkgnet.ServicePortName(sks.Spec.ProtocolType),
Protocol: corev1.ProtocolTCP,
AppProtocol: pkgnet.AppProtocol(sks.Spec.ProtocolType),
Port: pkgnet.ServiceHTTPPort,
Name: pkgnet.ServicePortName(sks.Spec.ProtocolType),
Protocol: corev1.ProtocolTCP,
Port: pkgnet.ServiceHTTPPort,
// This one is matching the public one, since this is the
// port queue-proxy listens on.
TargetPort: targetPort(sks),
Expand Down
36 changes: 16 additions & 20 deletions pkg/reconciler/serverlessservice/resources/services_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,10 @@ func TestMakePublicService(t *testing.T) {
}),
want: svc(networking.ServiceTypePublic, func(s *corev1.Service) {
s.Spec.Ports = []corev1.ServicePort{{
Name: pkgnet.ServicePortNameH2C,
Protocol: corev1.ProtocolTCP,
AppProtocol: &pkgnet.AppProtocolH2C,
Port: pkgnet.ServiceHTTP2Port,
TargetPort: intstr.FromInt(networking.BackendHTTP2Port),
Name: pkgnet.ServicePortNameH2C,
Protocol: corev1.ProtocolTCP,
Port: pkgnet.ServiceHTTP2Port,
TargetPort: intstr.FromInt(networking.BackendHTTP2Port),
}, {
Name: pkgnet.ServicePortNameHTTPS,
Protocol: corev1.ProtocolTCP,
Expand All @@ -203,11 +202,10 @@ func TestMakePublicService(t *testing.T) {
}),
want: svc(networking.ServiceTypePublic, func(s *corev1.Service) {
s.Spec.Ports = []corev1.ServicePort{{
Name: pkgnet.ServicePortNameH2C,
Protocol: corev1.ProtocolTCP,
AppProtocol: &pkgnet.AppProtocolH2C,
Port: pkgnet.ServiceHTTP2Port,
TargetPort: intstr.FromInt(networking.BackendHTTP2Port),
Name: pkgnet.ServicePortNameH2C,
Protocol: corev1.ProtocolTCP,
Port: pkgnet.ServiceHTTP2Port,
TargetPort: intstr.FromInt(networking.BackendHTTP2Port),
}, {
Name: pkgnet.ServicePortNameHTTPS,
Protocol: corev1.ProtocolTCP,
Expand All @@ -224,11 +222,10 @@ func TestMakePublicService(t *testing.T) {
}),
want: svc(networking.ServiceTypePublic, func(s *corev1.Service) {
s.Spec.Ports = []corev1.ServicePort{{
Name: pkgnet.ServicePortNameH2C,
Protocol: corev1.ProtocolTCP,
AppProtocol: &pkgnet.AppProtocolH2C,
Port: pkgnet.ServiceHTTP2Port,
TargetPort: intstr.FromInt(networking.BackendHTTP2Port),
Name: pkgnet.ServicePortNameH2C,
Protocol: corev1.ProtocolTCP,
Port: pkgnet.ServiceHTTP2Port,
TargetPort: intstr.FromInt(networking.BackendHTTP2Port),
}, {
Name: pkgnet.ServicePortNameHTTPS,
Protocol: corev1.ProtocolTCP,
Expand Down Expand Up @@ -473,11 +470,10 @@ func TestMakePrivateService(t *testing.T) {
}, privateSvcMod, func(s *corev1.Service) {
// And now patch port to be http2.
s.Spec.Ports[0] = corev1.ServicePort{
Name: pkgnet.ServicePortNameH2C,
Protocol: corev1.ProtocolTCP,
AppProtocol: &pkgnet.AppProtocolH2C,
Port: pkgnet.ServiceHTTPPort,
TargetPort: intstr.FromInt(networking.BackendHTTP2Port),
Name: pkgnet.ServicePortNameH2C,
Protocol: corev1.ProtocolTCP,
Port: pkgnet.ServiceHTTPPort,
TargetPort: intstr.FromInt(networking.BackendHTTP2Port),
}
s.Spec.Ports[5] = corev1.ServicePort{
Name: pkgnet.ServicePortNameH2C + "-istio",
Expand Down
2 changes: 0 additions & 2 deletions pkg/reconciler/serverlessservice/serverlessservice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,6 @@ func deploy(namespace, name string, opts ...deploymentOption) *appsv1.Deployment
func withHTTP2Priv(svc *corev1.Service) {
svc.Spec.Ports[0].Name = "http2"
svc.Spec.Ports[0].TargetPort = intstr.FromInt(networking.BackendHTTP2Port)
svc.Spec.Ports[0].AppProtocol = &pkgnet.AppProtocolH2C

svc.Spec.Ports[5].Name = "http2-istio"
svc.Spec.Ports[5].Port = networking.BackendHTTP2Port
Expand All @@ -813,7 +812,6 @@ func withHTTP2Priv(svc *corev1.Service) {
func withHTTP2(svc *corev1.Service) {
svc.Spec.Ports[0].Port = pkgnet.ServiceHTTP2Port
svc.Spec.Ports[0].Name = "http2"
svc.Spec.Ports[0].AppProtocol = &pkgnet.AppProtocolH2C
svc.Spec.Ports[0].TargetPort = intstr.FromInt(networking.BackendHTTP2Port)
}

Expand Down
7 changes: 3 additions & 4 deletions pkg/testing/functional.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,9 @@ func WithExternalName(name string) K8sServiceOption {
return func(svc *corev1.Service) {
svc.Spec.ExternalName = name
svc.Spec.Ports = []corev1.ServicePort{{
Name: networking.ServicePortNameH2C,
AppProtocol: &networking.AppProtocolH2C,
Port: int32(80),
TargetPort: intstr.FromInt(80),
Name: networking.ServicePortNameH2C,
Port: int32(80),
TargetPort: intstr.FromInt(80),
}}
}
}
Expand Down
Loading