Documentation ¶
Index ¶
- func NewResourceLock(config *rest.Config, eventRecorder resourcelock.EventRecorder, options Options) (resourcelock.Interface, error)
- type LeaseLock
- func (ll *LeaseLock) Create(ctx context.Context, ler resourcelock.LeaderElectionRecord) error
- func (ll *LeaseLock) Describe() string
- func (ll *LeaseLock) Get(ctx context.Context) (*resourcelock.LeaderElectionRecord, []byte, error)
- func (ll *LeaseLock) Identity() string
- func (ll *LeaseLock) RecordEvent(s string)
- func (ll *LeaseLock) Update(ctx context.Context, ler resourcelock.LeaderElectionRecord) error
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewResourceLock ¶
func NewResourceLock(config *rest.Config, eventRecorder resourcelock.EventRecorder, options Options) (resourcelock.Interface, error)
NewResourceLock returns a new resource lock that implements the shard lease. Pass this to the leader elector, e.g., leaderelection.LeaderElectionConfig.Lock (if using plain client-go) or manager.Options.LeaderElectionResourceLockInterface (if using controller-runtime).
Types ¶
type LeaseLock ¶
type LeaseLock struct { // LeaseMeta should contain a Name and a Namespace of a // LeaseMeta object that the LeaderElector will attempt to lead. LeaseMeta metav1.ObjectMeta Client coordinationv1client.LeasesGetter LockConfig resourcelock.ResourceLockConfig Labels map[string]string // contains filtered or unexported fields }
LeaseLock implements resourcelock.Interface but is able to add labels to the Lease. The implementation is based resourclock.LeaseLock and shares some helper functions with it. nolint:revive // don't rename LeaseLock to stay close to the original implementation in client-go.
func (*LeaseLock) Create ¶
func (ll *LeaseLock) Create(ctx context.Context, ler resourcelock.LeaderElectionRecord) error
Create attempts to create a Lease
func (*LeaseLock) Describe ¶
Describe is used to convert details on current resource lock into a string
func (*LeaseLock) Get ¶
func (ll *LeaseLock) Get(ctx context.Context) (*resourcelock.LeaderElectionRecord, []byte, error)
Get returns the election record from a Lease spec
func (*LeaseLock) RecordEvent ¶
RecordEvent in leader election while adding meta-data
func (*LeaseLock) Update ¶
func (ll *LeaseLock) Update(ctx context.Context, ler resourcelock.LeaderElectionRecord) error
Update will update an existing Lease spec.
type Options ¶
type Options struct { // ClusterRingName specifies the name of the ClusterRing that the shard belongs to. ClusterRingName string // LeaseNamespace determines the namespace in which the shard lease will be created. // Defaults to the pod's namespace if running in-cluster. LeaseNamespace string // ShardName determines the name of the shard. This will be used as the lease name as well as the lease's // holderIdentity. // Defaults to os.Hostname(). ShardName string }
Options provides the required configuration to create a new shard lease.