Skip to content

Commit

Permalink
fix(parser) include port in upstream names
Browse files Browse the repository at this point in the history
Include the port in upstream names, such that the format is
serviceName.namespace.port.svc, e.g. fooserv.default.80.svc. This
correctly handles cases where a service exposes multiple ports, whereas
previously both would attempt the same upstream and conflict.

Fix #335
  • Loading branch information
Travis Raines committed Sep 17, 2019
1 parent 273a566 commit 3d081c7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions internal/ingress/controller/parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ func (p *Parser) parseIngressRules(
service = Service{
Service: kong.Service{
Name: kong.String(serviceName),
Host: kong.String(rule.Backend.ServiceName + "." + ingress.Namespace + ".svc"),
Host: kong.String(rule.Backend.ServiceName + "." + ingress.Namespace + "." + rule.Backend.ServicePort.String() + ".svc"),
Port: kong.Int(80),
Protocol: kong.String("http"),
Path: kong.String("/"),
Expand Down Expand Up @@ -409,7 +409,7 @@ func (p *Parser) parseIngressRules(
service = Service{
Service: kong.Service{
Name: kong.String(serviceName),
Host: kong.String(defaultBackend.ServiceName + "." + ingress.Namespace + ".svc"),
Host: kong.String(defaultBackend.ServiceName + "." + ingress.Namespace + "." + defaultBackend.ServicePort.String() + ".svc"),
Port: kong.Int(80),
},
Namespace: ingress.Namespace,
Expand Down Expand Up @@ -555,7 +555,7 @@ func overrideUpstream(upstream *Upstream,
func (p *Parser) getUpstreams(serviceMap map[string]Service) ([]Upstream, error) {
var upstreams []Upstream
for _, service := range serviceMap {
upstreamName := service.Backend.ServiceName + "." + service.Namespace + ".svc"
upstreamName := service.Backend.ServiceName + "." + service.Namespace + "." + service.Backend.ServicePort.String() + ".svc"
upstream := Upstream{
Upstream: kong.Upstream{
Name: kong.String(upstreamName),
Expand Down

0 comments on commit 3d081c7

Please sign in to comment.