leaderelection

package
Version: v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package leaderelection provides a set of utility functions for running a highly available controller component.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunOrDie

func RunOrDie(opt Option)

RunOrDie starts the leader election code loop with the provided config or panics if the config fails to validate. A wrapper of Kubernetes leaderelection package, more info here: https://github.com/caicloud/leader-election-example

Types

type Option

type Option struct {
	// LeaseLockName is the lease lock resource name, recommended to use the component name.
	LeaseLockName string
	// LeaseLockNamespace is the lease lock resource namespace, recommended to use the component namespace.
	LeaseLockNamespace string
	// ID is the the holder identity name, recommended to use the component pod name.
	// If not set, the value of the POD_NAME environment variable will be used
	// +optional
	ID string
	// KubeClient is the kube client of a cluster.
	KubeClient kubernetes.Interface
	// Run is the main controller code loop starter.
	Run func(ctx context.Context)
	// LivenessChecker defines the liveness healthz checker.
	// +optional
	LivenessChecker func(req *http.Request) error
	// Port is the healthz server port.
	Port int
	// StopCh is the stop channel used to shut down the component
	StopCh <-chan struct{}
}

Option defines the parameters required to start the leader election component.

Jump to

Keyboard shortcuts

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