Skip to content

Commit

Permalink
temporary test of port-mapping for envoy
Browse files Browse the repository at this point in the history
  • Loading branch information
missylbytes committed Aug 2, 2023
1 parent b1f8349 commit 9e66a33
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 5 additions & 1 deletion control-plane/api-gateway/common/translation.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,18 @@ func (t ResourceTranslator) toAPIGatewayListener(gateway gwv1beta1.Gateway, list
return api.APIGatewayListener{
Name: string(listener.Name),
Hostname: DerefStringOr(listener.Hostname, ""),
Port: int(listener.Port),
Port: ToContainerPort(listener.Port),
Protocol: listenerProtocolMap[strings.ToLower(string(listener.Protocol))],
TLS: api.APIGatewayTLSConfiguration{
Certificates: certificates,
},
}, true
}

func ToContainerPort(portNumber gwv1beta1.PortNumber) int {
return int(portNumber) + 2000
}

func (t ResourceTranslator) ToHTTPRoute(route gwv1beta1.HTTPRoute, resources *ResourceMap) *api.HTTPRouteConfigEntry {
namespace := t.Namespace(route.Namespace)

Expand Down
6 changes: 4 additions & 2 deletions control-plane/api-gateway/gatekeeper/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package gatekeeper

import (
"context"
"k8s.io/apimachinery/pkg/util/intstr"

"github.com/hashicorp/consul-k8s/control-plane/api-gateway/common"
"github.com/hashicorp/consul-k8s/control-plane/api/v1alpha1"
Expand Down Expand Up @@ -76,8 +77,9 @@ func (g *Gatekeeper) service(gateway gwv1beta1.Gateway, gcc v1alpha1.GatewayClas
ports = append(ports, corev1.ServicePort{
Name: string(listener.Name),
// only TCP-based services are supported for now
Protocol: corev1.ProtocolTCP,
Port: int32(listener.Port),
Protocol: corev1.ProtocolTCP,
Port: int32(listener.Port),
TargetPort: intstr.FromInt(common.ToContainerPort(listener.Port)),
})

seenPorts[listener.Port] = struct{}{}
Expand Down

0 comments on commit 9e66a33

Please sign in to comment.