Add publish-status-address flag (#2148)

* Add publish-status-address flag

If this flag is set, status of ingress resources will be updated
with this address.

* Address aledbf's comment
This commit is contained in:
Qiu Jian 2018-02-27 11:02:19 +08:00 committed by Manuel Alejandro de Brito Fontes
parent 3c67976969
commit 56036ddc57
6 changed files with 40 additions and 3 deletions

View file

@ -65,6 +65,8 @@ type Config struct {
PublishService string
PublishStatusAddress string
ElectionID string
UpdateStatusOnShutdown bool
@ -81,7 +83,9 @@ type Config struct {
// in all the defined rules. To simplify the process leader election is used so the update
// is executed only in one node (Ingress controllers can be scaled to more than one)
// If the controller is running with the flag --publish-service (with a valid service)
// the IP address behind the service is used, if not the source is the IP/s of the node/s
// the IP address behind the service is used, if it is running with the flag
// --publish-status-address, the address specified in the flag is used, if neither of the
// two flags are set, the source is the IP/s of the node/s
type statusSync struct {
Config
// pod contains runtime information about this pod
@ -251,6 +255,11 @@ func (s *statusSync) runningAddresses() ([]string, error) {
return addrs, nil
}
if s.PublishStatusAddress != "" {
addrs = append(addrs, s.PublishStatusAddress)
return addrs, nil
}
// get information about all the pods running the ingress controller
pods, err := s.Client.CoreV1().Pods(s.pod.Namespace).List(metav1.ListOptions{
LabelSelector: labels.SelectorFromSet(s.pod.Labels).String(),