Skip to content

Commit fad4594

Browse files
committed
Add LeaseCandidate v1beta1
1 parent 341df1a commit fad4594

File tree

4 files changed

+78
-0
lines changed

4 files changed

+78
-0
lines changed

pkg/apis/coordination/types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ type LeaseCandidate struct {
108108
// LeaseCandidateSpec is a specification of a Lease.
109109
type LeaseCandidateSpec struct {
110110
// LeaseName is the name of the lease for which this candidate is contending.
111+
// The limits on this field are the same as on Lease.name. Multiple lease candidates
112+
// may reference the same Lease.name.
111113
// This field is immutable.
112114
// +required
113115
LeaseName string

pkg/controlplane/apiserver/aggregator.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ func DefaultGenericAPIServicePriorities() map[schema.GroupVersion]APIServicePrio
284284
{Group: "admissionregistration.k8s.io", Version: "v1beta1"}: {Group: 16700, Version: 12},
285285
{Group: "admissionregistration.k8s.io", Version: "v1alpha1"}: {Group: 16700, Version: 9},
286286
{Group: "coordination.k8s.io", Version: "v1"}: {Group: 16500, Version: 15},
287+
{Group: "coordination.k8s.io", Version: "v1beta1"}: {Group: 16500, Version: 13},
287288
{Group: "coordination.k8s.io", Version: "v1alpha2"}: {Group: 16500, Version: 12},
288289
{Group: "discovery.k8s.io", Version: "v1"}: {Group: 16200, Version: 15},
289290
{Group: "discovery.k8s.io", Version: "v1beta1"}: {Group: 16200, Version: 12},

pkg/controlplane/instance.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import (
3939
certificatesv1alpha1 "k8s.io/api/certificates/v1alpha1"
4040
coordinationapiv1 "k8s.io/api/coordination/v1"
4141
coordinationv1alpha2 "k8s.io/api/coordination/v1alpha2"
42+
coordinationv1beta1 "k8s.io/api/coordination/v1beta1"
4243
apiv1 "k8s.io/api/core/v1"
4344
discoveryv1 "k8s.io/api/discovery/v1"
4445
eventsv1 "k8s.io/api/events/v1"
@@ -457,6 +458,7 @@ var (
457458
betaAPIGroupVersionsDisabledByDefault = []schema.GroupVersion{
458459
admissionregistrationv1beta1.SchemeGroupVersion,
459460
authenticationv1beta1.SchemeGroupVersion,
461+
coordinationv1beta1.SchemeGroupVersion,
460462
storageapiv1beta1.SchemeGroupVersion,
461463
flowcontrolv1beta1.SchemeGroupVersion,
462464
flowcontrolv1beta2.SchemeGroupVersion,

staging/src/k8s.io/api/coordination/v1beta1/types.go

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,76 @@ type LeaseList struct {
9191
// items is a list of schema objects.
9292
Items []Lease `json:"items" protobuf:"bytes,2,rep,name=items"`
9393
}
94+
95+
// +genclient
96+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
97+
// +k8s:prerelease-lifecycle-gen:introduced=1.33
98+
99+
// LeaseCandidate defines a candidate for a Lease object.
100+
// Candidates are created such that coordinated leader election will pick the best leader from the list of candidates.
101+
type LeaseCandidate struct {
102+
metav1.TypeMeta `json:",inline"`
103+
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
104+
// +optional
105+
metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
106+
107+
// spec contains the specification of the Lease.
108+
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
109+
// +optional
110+
Spec LeaseCandidateSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
111+
}
112+
113+
// LeaseCandidateSpec is a specification of a Lease.
114+
type LeaseCandidateSpec struct {
115+
// LeaseName is the name of the lease for which this candidate is contending.
116+
// The limits on this field are the same as on Lease.name. Multiple lease candidates
117+
// may reference the same Lease.name.
118+
// This field is immutable.
119+
// +required
120+
LeaseName string `json:"leaseName" protobuf:"bytes,1,name=leaseName"`
121+
// PingTime is the last time that the server has requested the LeaseCandidate
122+
// to renew. It is only done during leader election to check if any
123+
// LeaseCandidates have become ineligible. When PingTime is updated, the
124+
// LeaseCandidate will respond by updating RenewTime.
125+
// +optional
126+
PingTime *metav1.MicroTime `json:"pingTime,omitempty" protobuf:"bytes,2,opt,name=pingTime"`
127+
// RenewTime is the time that the LeaseCandidate was last updated.
128+
// Any time a Lease needs to do leader election, the PingTime field
129+
// is updated to signal to the LeaseCandidate that they should update
130+
// the RenewTime.
131+
// Old LeaseCandidate objects are also garbage collected if it has been hours
132+
// since the last renew. The PingTime field is updated regularly to prevent
133+
// garbage collection for still active LeaseCandidates.
134+
// +optional
135+
RenewTime *metav1.MicroTime `json:"renewTime,omitempty" protobuf:"bytes,3,opt,name=renewTime"`
136+
// BinaryVersion is the binary version. It must be in a semver format without leading `v`.
137+
// This field is required.
138+
// +required
139+
BinaryVersion string `json:"binaryVersion" protobuf:"bytes,4,name=binaryVersion"`
140+
// EmulationVersion is the emulation version. It must be in a semver format without leading `v`.
141+
// EmulationVersion must be less than or equal to BinaryVersion.
142+
// This field is required when strategy is "OldestEmulationVersion"
143+
// +optional
144+
EmulationVersion string `json:"emulationVersion,omitempty" protobuf:"bytes,5,opt,name=emulationVersion"`
145+
// Strategy is the strategy that coordinated leader election will use for picking the leader.
146+
// If multiple candidates for the same Lease return different strategies, the strategy provided
147+
// by the candidate with the latest BinaryVersion will be used. If there is still conflict,
148+
// this is a user error and coordinated leader election will not operate the Lease until resolved.
149+
// +required
150+
Strategy v1.CoordinatedLeaseStrategy `json:"strategy,omitempty" protobuf:"bytes,6,opt,name=strategy"`
151+
}
152+
153+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
154+
// +k8s:prerelease-lifecycle-gen:introduced=1.33
155+
156+
// LeaseCandidateList is a list of Lease objects.
157+
type LeaseCandidateList struct {
158+
metav1.TypeMeta `json:",inline"`
159+
// Standard list metadata.
160+
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
161+
// +optional
162+
metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
163+
164+
// items is a list of schema objects.
165+
Items []LeaseCandidate `json:"items" protobuf:"bytes,2,rep,name=items"`
166+
}

0 commit comments

Comments
 (0)