Enable custom election id for status sync.

This commit is contained in:
shijunqian 2017-02-27 15:35:04 +08:00
parent 85369f87cf
commit 2d526b213c
3 changed files with 7 additions and 1 deletions

View file

@ -134,6 +134,7 @@ type Configuration struct {
Backend ingress.Controller Backend ingress.Controller
UpdateStatus bool UpdateStatus bool
ElectionID string
} }
// newIngressController creates an Ingress controller // newIngressController creates an Ingress controller
@ -303,6 +304,7 @@ func newIngressController(config *Configuration) *GenericController {
Client: config.Client, Client: config.Client,
PublishService: ic.cfg.PublishService, PublishService: ic.cfg.PublishService,
IngressLister: ic.ingLister, IngressLister: ic.ingLister,
ElectionID: config.ElectionID,
}) })
} else { } else {
glog.Warning("Update of ingress status is disabled (flag --update-status=false was specified)") glog.Warning("Update of ingress status is disabled (flag --update-status=false was specified)")

View file

@ -82,6 +82,8 @@ func NewIngressController(backend ingress.Controller) *GenericController {
updateStatus = flags.Bool("update-status", true, `Indicates if the updateStatus = flags.Bool("update-status", true, `Indicates if the
ingress controller should update the Ingress status IP/hostname. Default is true`) ingress controller should update the Ingress status IP/hostname. Default is true`)
electionID = flags.String("election-id", "ingress-controller-leader", `Election id to use for status update.`)
) )
backend.OverrideFlags(flags) backend.OverrideFlags(flags)
@ -137,6 +139,7 @@ func NewIngressController(backend ingress.Controller) *GenericController {
config := &Configuration{ config := &Configuration{
UpdateStatus: *updateStatus, UpdateStatus: *updateStatus,
ElectionID: *electionID,
Client: kubeClient, Client: kubeClient,
ResyncPeriod: *resyncPeriod, ResyncPeriod: *resyncPeriod,
DefaultService: *defaultSvc, DefaultService: *defaultSvc,

View file

@ -52,6 +52,7 @@ type Config struct {
Client clientset.Interface Client clientset.Interface
PublishService string PublishService string
IngressLister cache_store.StoreToIngressLister IngressLister cache_store.StoreToIngressLister
ElectionID string
} }
// statusSync keeps the status IP in each Ingress rule updated executing a periodic check // statusSync keeps the status IP in each Ingress rule updated executing a periodic check
@ -171,7 +172,7 @@ func NewStatusSyncer(config Config) Sync {
} }
st.syncQueue = task.NewCustomTaskQueue(st.sync, st.keyfunc) st.syncQueue = task.NewCustomTaskQueue(st.sync, st.keyfunc)
le, err := NewElection("ingress-controller-leader", le, err := NewElection(config.ElectionID,
pod.Name, pod.Namespace, 30*time.Second, pod.Name, pod.Namespace, 30*time.Second,
st.callback, config.Client) st.callback, config.Client)
if err != nil { if err != nil {