Add flags to customize listen ports and detect port collisions
This commit is contained in:
parent
02e20eb81a
commit
0459674931
12 changed files with 127 additions and 47 deletions
|
|
@ -569,13 +569,13 @@ func (ic *GenericController) getDefaultUpstream() *ingress.Backend {
|
|||
svcObj, svcExists, err := ic.svcLister.Store.GetByKey(svcKey)
|
||||
if err != nil {
|
||||
glog.Warningf("unexpected error searching the default backend %v: %v", ic.cfg.DefaultService, err)
|
||||
upstream.Endpoints = append(upstream.Endpoints, newDefaultServer())
|
||||
upstream.Endpoints = append(upstream.Endpoints, ic.cfg.Backend.DefaultEndpoint())
|
||||
return upstream
|
||||
}
|
||||
|
||||
if !svcExists {
|
||||
glog.Warningf("service %v does not exist", svcKey)
|
||||
upstream.Endpoints = append(upstream.Endpoints, newDefaultServer())
|
||||
upstream.Endpoints = append(upstream.Endpoints, ic.cfg.Backend.DefaultEndpoint())
|
||||
return upstream
|
||||
}
|
||||
|
||||
|
|
@ -583,7 +583,7 @@ func (ic *GenericController) getDefaultUpstream() *ingress.Backend {
|
|||
endps := ic.getEndpoints(svc, &svc.Spec.Ports[0], api.ProtocolTCP, &healthcheck.Upstream{})
|
||||
if len(endps) == 0 {
|
||||
glog.Warningf("service %v does not have any active endpoints", svcKey)
|
||||
endps = []ingress.Endpoint{newDefaultServer()}
|
||||
endps = []ingress.Endpoint{ic.cfg.Backend.DefaultEndpoint()}
|
||||
}
|
||||
|
||||
upstream.Service = svc
|
||||
|
|
@ -760,7 +760,7 @@ func (ic *GenericController) getBackendServers() ([]*ingress.Backend, []*ingress
|
|||
for _, value := range upstreams {
|
||||
if len(value.Endpoints) == 0 {
|
||||
glog.V(3).Infof("upstream %v does not have any active endpoints. Using default backend", value.Name)
|
||||
value.Endpoints = append(value.Endpoints, newDefaultServer())
|
||||
value.Endpoints = append(value.Endpoints, ic.cfg.Backend.DefaultEndpoint())
|
||||
}
|
||||
aUpstreams = append(aUpstreams, value)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -90,11 +90,11 @@ 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`)
|
||||
|
||||
SortBackends = flags.Bool("sort-backends", false,
|
||||
sortBackends = flags.Bool("sort-backends", false,
|
||||
`Defines if backends and it's endpoints should be sorted`)
|
||||
)
|
||||
|
||||
|
|
@ -175,8 +175,8 @@ func NewIngressController(backend ingress.Controller) *GenericController {
|
|||
PublishService: *publishSvc,
|
||||
Backend: backend,
|
||||
ForceNamespaceIsolation: *forceIsolation,
|
||||
UpdateStatusOnShutdown: *UpdateStatusOnShutdown,
|
||||
SortBackends: *SortBackends,
|
||||
UpdateStatusOnShutdown: *updateStatusOnShutdown,
|
||||
SortBackends: *sortBackends,
|
||||
}
|
||||
|
||||
ic := newIngressController(config)
|
||||
|
|
|
|||
|
|
@ -28,11 +28,6 @@ import (
|
|||
// DeniedKeyName name of the key that contains the reason to deny a location
|
||||
const DeniedKeyName = "Denied"
|
||||
|
||||
// newDefaultServer return an BackendServer to be use as default server that returns 503.
|
||||
func newDefaultServer() ingress.Endpoint {
|
||||
return ingress.Endpoint{Address: "127.0.0.1", Port: "8181", Target: &api.ObjectReference{}}
|
||||
}
|
||||
|
||||
// newUpstream creates an upstream without servers.
|
||||
func newUpstream(name string) *ingress.Backend {
|
||||
return &ingress.Backend{
|
||||
|
|
|
|||
|
|
@ -98,6 +98,10 @@ type Controller interface {
|
|||
// This allows custom implementations
|
||||
// If the function returns nil the standard functions will be executed.
|
||||
UpdateIngressStatus(*extensions.Ingress) []api.LoadBalancerIngress
|
||||
// DefaultEndpoint returns the Endpoint to use as default when the
|
||||
// referenced service does not exists. This should return the content
|
||||
// of to the default backend
|
||||
DefaultEndpoint() Endpoint
|
||||
}
|
||||
|
||||
// StoreLister returns the configured stores for ingresses, services,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue