Detect if the ingress controller is running with multiple replicas
@@ -111,6 +111,11 @@ func (s statusSync) Shutdown() {
return
}
+ if s.isRunningMultiplePods() {
+ glog.V(2).Infof("skipping Ingress status update (multiple pods running - another one will be elected as master)")
+ return
+ }
+
glog.Infof("removing address from ingress status (%v)", addrs)
s.updateStatus([]api_v1.LoadBalancerIngress{})
}
@@ -232,6 +237,17 @@ func (s *statusSync) runningAddresess() ([]string, error) {
return addrs, nil
}
+func (s *statusSync) isRunningMultiplePods() bool {
+ pods, err := s.Client.Core().Pods(s.pod.Namespace).List(meta_v1.ListOptions{
+ LabelSelector: labels.SelectorFromSet(s.pod.Labels).String(),
+ })
+ if err != nil {
+ return false
+ }
+
+ return len(pods.Items) > 1
+}
+
// sliceToStatus converts a slice of IP and/or hostnames to LoadBalancerIngress
func sliceToStatus(endpoints []string) []api_v1.LoadBalancerIngress {
lbi := []api_v1.LoadBalancerIngress{}
