Fix ports collision when hostNetwork=true (#4617)

This commit is contained in:
Manuel Alejandro de Brito Fontes 2019-09-28 17:30:57 -03:00 committed by GitHub
parent 9ecec0de63
commit d5d2b4037c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 40 additions and 8 deletions

View file

@ -261,17 +261,21 @@ func (n *NGINXController) getStreamServices(configmapName string, proto apiv1.Pr
klog.Errorf("Error getting ConfigMap %q: %v", configmapName, err)
return []ingress.L4Service{}
}
var svcs []ingress.L4Service
var svcProxyProtocol ingress.ProxyProtocol
rp := []int{
n.cfg.ListenPorts.HTTP,
n.cfg.ListenPorts.HTTPS,
n.cfg.ListenPorts.SSLProxy,
n.cfg.ListenPorts.Health,
n.cfg.ListenPorts.Default,
10255, // profiling port
nginx.ProfilerPort,
nginx.StatusPort,
nginx.StreamPort,
}
reserverdPorts := sets.NewInt(rp...)
// svcRef format: <(str)namespace>/<(str)service>:<(intstr)port>[:<("PROXY")decode>:<("PROXY")encode>]
for port, svcRef := range configmap.Data {

View file

@ -31,6 +31,11 @@ import (
"k8s.io/klog"
)
// TODO: Check https://github.com/kubernetes/kubernetes/blob/master/pkg/master/ports/ports.go for ports already being used
// ProfilerPort port used by the ingress controller to expose the Go Profiler when it is enabled.
var ProfilerPort = 10245
// TemplatePath path of the NGINX template
var TemplatePath = "/etc/nginx/template/nginx.tmpl"
@ -38,7 +43,7 @@ var TemplatePath = "/etc/nginx/template/nginx.tmpl"
var PID = "/tmp/nginx.pid"
// StatusPort port used by NGINX for the status server
var StatusPort = 10256
var StatusPort = 10246
// HealthPath defines the path used to define the health check location in NGINX
var HealthPath = "/healthz"
@ -51,7 +56,7 @@ var HealthCheckTimeout = 10 * time.Second
var StatusPath = "/nginx_status"
// StreamPort defines the port used by NGINX for the NGINX stream configuration socket
var StreamPort = 10257
var StreamPort = 10247
// NewGetStatusRequest creates a new GET request to the internal NGINX status server
func NewGetStatusRequest(path string) (int, []byte, error) {