leaderelection

package
v0.2.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 28, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// LeaseDuration is the duration that non-leader candidates will
	// wait to force acquire leadership. This is measured against time of
	// last observed ack.
	//
	// A client needs to wait a full LeaseDuration without observing a change to
	// the record before it can attempt to take over. When all clients are
	// shutdown and a new set of clients are started with different names against
	// the same leader record, they must wait the full LeaseDuration before
	// attempting to acquire the lease. Thus LeaseDuration should be as short as
	// possible (within your tolerance for clock skew rate) to avoid a possible
	// long waits in the scenario.
	//
	LeaseDuration = 15 * time.Second
	// RenewDeadline is the duration that the acting master will retry
	// refreshing leadership before giving up.
	//
	RenewDeadline = 10 * time.Second

	// RetryPeriod is the duration the LeaderElector clients should wait
	// between tries of actions.
	//
	RetryPeriod = 2 * time.Second
)

Variables

View Source
var (
	// GetConfigOrDie creates a *rest.Config for talking to a Kubernetes apiserver.
	// If --kubeconfig is set, will use the kubeconfig file at that location.  Otherwise will assume running
	// in cluster and use the cluster provided kubeconfig.
	//
	// Will log an error and exit if there is an error creating the rest.Config.
	GetConfigOrDie = config.GetConfigOrDie

	// GetConfig creates a *rest.Config for talking to a Kubernetes apiserver.
	// If --kubeconfig is set, will use the kubeconfig file at that location.  Otherwise will assume running
	// in cluster and use the cluster provided kubeconfig.
	//
	// Config precedence
	//
	// * --kubeconfig flag pointing at a file
	//
	// * KUBECONFIG environment variable pointing at a file
	//
	// * In-cluster config if running in cluster
	//
	// * $HOME/.kube/config if exists
	GetConfig = config.GetConfig
)

Functions

func NewConfigMapLock

func NewConfigMapLock(lockName, lockNamespace, id string) (rl.Interface, error)

NewConfigMapLock returns new lock backed by ConfigMap

func NewLock

func NewLock(lockName, lockNamespace, id string) (rl.Interface, error)

NewLock returns new resource lock

func Run

func Run(lock rl.Interface, onStarted func(stop <-chan struct{}), stop <-chan struct{}) error

Run runs leader election and calls onStarted when runner becomes leader

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL