Detect port collision and allow custom configuration

This commit is contained in:
Manuel de Brito Fontes 2017-07-02 17:40:17 -04:00
parent 24d78cae8e
commit 5fc8c4cfe9
3 changed files with 25 additions and 2 deletions

View file

@ -145,6 +145,8 @@ type Configuration struct {
UpdateStatus bool
ElectionID string
UpdateStatusOnShutdown bool
ControllerPorts ingress.ControllerPorts
}
// newIngressController creates an Ingress controller

View file

@ -90,9 +90,14 @@ func NewIngressController(backend ingress.Controller) *GenericController {
`Force namespace isolation. This flag is required to avoid the reference of secrets or
configmaps located in a different namespace than the specified in the flag --watch-namespace.`)
UpdateStatusOnShutdown = flags.Bool("update-status-on-shutdown", true, `Indicates if the
updateStatusOnShutdown = flags.Bool("update-status-on-shutdown", true, `Indicates if the
ingress controller should update the Ingress status IP/hostname when the controller
is being stopped. Default is true`)
httpPort = flags.Int("http-port", 80, `Indicates the TCP port to use for HTTP traffic`)
httpsPort = flags.Int("https-port", 443, `Indicates the TCP port to use for HTTPS traffic`)
statusPort = flags.Int("https-port", 18080, `Indicates the TCP port to use for exposing the status of the backend`)
)
flags.AddGoFlagSet(flag.CommandLine)
@ -151,6 +156,13 @@ func NewIngressController(backend ingress.Controller) *GenericController {
glog.Errorf("Failed to mkdir SSL directory: %v", err)
}
ports := ingress.ControllerPorts{
HTTP: *httpPort,
HTTPS: *httpsPort,
Health: *healthzPort,
Status: *statusPort,
}
config := &Configuration{
UpdateStatus: *updateStatus,
ElectionID: *electionID,
@ -168,7 +180,8 @@ func NewIngressController(backend ingress.Controller) *GenericController {
PublishService: *publishSvc,
Backend: backend,
ForceNamespaceIsolation: *forceIsolation,
UpdateStatusOnShutdown: *UpdateStatusOnShutdown,
UpdateStatusOnShutdown: *updateStatusOnShutdown,
ControllerPorts: ports,
}
ic := newIngressController(config)

View file

@ -320,3 +320,11 @@ type L4Backend struct {
Namespace string `json:"namespace"`
Protocol api.Protocol `json:"protocol"`
}
// ControllerPorts describe the ports required to run the Ingress controller
type ControllerPorts struct {
HTTP int
HTTPS int
Status int
Health int
}