Skip to content

Commit

Permalink
wip: try adding both 443 and 80 to service
Browse files Browse the repository at this point in the history
  • Loading branch information
KauzClay committed Jan 30, 2023
1 parent a790854 commit 0af4f35
Showing 1 changed file with 24 additions and 17 deletions.
41 changes: 24 additions & 17 deletions pkg/reconciler/route/resources/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func MakeK8sPlaceholderService(ctx context.Context, route *v1.Route, tagName str
Type: corev1.ServiceTypeExternalName,
ExternalName: domainName,
SessionAffinity: corev1.ServiceAffinityNone,
Ports: []corev1.ServicePort{makeServicePort(netcfg.InternalEncryption)},
Ports: makeServicePorts(netcfg.InternalEncryption),
},
}, nil
}
Expand Down Expand Up @@ -101,7 +101,7 @@ func MakeK8sService(ctx context.Context, route *v1.Route, tagName string, ingres
Service: &corev1.Service{
ObjectMeta: makeServiceObjectMeta(hostname, route),
Spec: corev1.ServiceSpec{
Ports: []corev1.ServicePort{makeServicePort(netcfg.InternalEncryption)},
Ports: makeServicePorts(netcfg.InternalEncryption),
},
},
Endpoints: nil,
Expand All @@ -124,7 +124,7 @@ func MakeK8sService(ctx context.Context, route *v1.Route, tagName string, ingres
Addresses: []corev1.EndpointAddress{{
IP: balancer.IP,
}},
Ports: []corev1.EndpointPort{makeEndpointPort(netcfg.InternalEncryption)},
Ports: makeEndpointPorts(netcfg.InternalEncryption),
}},
}
case balancer.DomainInternal != "":
Expand Down Expand Up @@ -172,27 +172,34 @@ func makeServiceObjectMeta(hostname string, route *v1.Route) metav1.ObjectMeta {
}
}

func makeServicePort(internalEncryption bool) (sp corev1.ServicePort) {
func makeServicePorts(internalEncryption bool) (sps []corev1.ServicePort) {
sps = append(sps, corev1.ServicePort{
Port: int32(80),
TargetPort: intstr.FromInt(80),
Name: netapi.ServicePortNameH2C,
})

if internalEncryption {
sp.Port = int32(netapi.ServiceHTTPSPort)
sp.TargetPort = intstr.FromInt(netapi.ServiceHTTPSPort)
sp.Name = netapi.ServicePortNameHTTPS
} else {
sp.Port = int32(80)
sp.TargetPort = intstr.FromInt(80)
sp.Name = netapi.ServicePortNameH2C
sps = append(sps, corev1.ServicePort{
Port: int32(netapi.ServiceHTTPSPort),
TargetPort: intstr.FromInt(netapi.ServiceHTTPSPort),
Name: netapi.ServicePortNameHTTPS,
})
}

return
}

func makeEndpointPort(internalEncryption bool) (ep corev1.EndpointPort) {
func makeEndpointPorts(internalEncryption bool) (eps []corev1.EndpointPort) {
eps = append(eps, corev1.EndpointPort{
Port: int32(80),
Name: netapi.ServicePortNameH2C,
})
if internalEncryption {
ep.Port = int32(netapi.ServiceHTTPSPort)
ep.Name = netapi.ServicePortNameHTTPS
} else {
ep.Port = int32(80)
ep.Name = netapi.ServicePortNameH2C
eps = append(eps, corev1.EndpointPort{
Port: int32(netapi.ServiceHTTPSPort),
Name: netapi.ServicePortNameHTTPS,
})
}

return
Expand Down

0 comments on commit 0af4f35

Please sign in to comment.