Fix port collision checks for TCP and UDP
This commit is contained in:
parent
311d286a34
commit
e2b74db389
2 changed files with 19 additions and 6 deletions
|
@ -35,7 +35,6 @@ import (
|
||||||
"k8s.io/apimachinery/pkg/util/intstr"
|
"k8s.io/apimachinery/pkg/util/intstr"
|
||||||
"k8s.io/apimachinery/pkg/util/sets"
|
"k8s.io/apimachinery/pkg/util/sets"
|
||||||
clientset "k8s.io/client-go/kubernetes"
|
clientset "k8s.io/client-go/kubernetes"
|
||||||
"k8s.io/kubernetes/pkg/kubelet/util/sliceutils"
|
|
||||||
|
|
||||||
"k8s.io/ingress-nginx/pkg/ingress"
|
"k8s.io/ingress-nginx/pkg/ingress"
|
||||||
"k8s.io/ingress-nginx/pkg/ingress/annotations/class"
|
"k8s.io/ingress-nginx/pkg/ingress/annotations/class"
|
||||||
|
@ -56,9 +55,6 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// list of ports that cannot be used by TCP or UDP services
|
|
||||||
reservedPorts = []string{"80", "443", "8181", "18080"}
|
|
||||||
|
|
||||||
cloner *conversion.Cloner
|
cloner *conversion.Cloner
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -260,8 +256,16 @@ func (n *NGINXController) getStreamServices(configmapName string, proto apiv1.Pr
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// this ports used by the backend
|
rp := []int{
|
||||||
if sliceutils.StringInSlice(k, reservedPorts) {
|
n.cfg.ListenPorts.HTTP,
|
||||||
|
n.cfg.ListenPorts.HTTPS,
|
||||||
|
n.cfg.ListenPorts.SSLProxy,
|
||||||
|
n.cfg.ListenPorts.Status,
|
||||||
|
n.cfg.ListenPorts.Health,
|
||||||
|
n.cfg.ListenPorts.Default,
|
||||||
|
}
|
||||||
|
|
||||||
|
if intInSlice(externalPort, rp) {
|
||||||
glog.Warningf("port %v cannot be used for TCP or UDP services. It is reserved for the Ingress controller", k)
|
glog.Warningf("port %v cannot be used for TCP or UDP services. It is reserved for the Ingress controller", k)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,3 +49,12 @@ func sysctlFSFileMax() int {
|
||||||
}
|
}
|
||||||
return int(rLimit.Max)
|
return int(rLimit.Max)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func intInSlice(i int, list []int) bool {
|
||||||
|
for _, v := range list {
|
||||||
|
if v == i {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue