Skip to content

Commit 49ea5a3

Browse files
authored
feat: add ClusterDrain resource (#388)
* add ClusterDrain resource * check if already annotaion set * update controller * fix linter * update rbac * add unit tests * remove chart tests
1 parent c1bed45 commit 49ea5a3

File tree

11 files changed

+1706
-347
lines changed

11 files changed

+1706
-347
lines changed

.github/workflows/lint-and-test.yml

Lines changed: 0 additions & 45 deletions
This file was deleted.

api/v1alpha1/clusterdrain_types.go

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
package v1alpha1
2+
3+
import (
4+
corev1 "k8s.io/api/core/v1"
5+
"k8s.io/apimachinery/pkg/api/meta"
6+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
7+
)
8+
9+
type FlowControl struct {
10+
Percentage *int `json:"percentage,omitempty"`
11+
MaxConcurrency *int `json:"maxConcurrency,omitempty"`
12+
}
13+
14+
// ClusterDrainSpec defines the desired state of ClusterDrain
15+
type ClusterDrainSpec struct {
16+
FlowControl FlowControl `json:"flowControl"`
17+
LabelSelector *metav1.LabelSelector `json:"labelSelector,omitempty"`
18+
}
19+
20+
// ClusterDrainStatus defines the observed state of ClusterDrain
21+
type ClusterDrainStatus struct {
22+
// Represents the observations of a HealthConvert current state.
23+
// +patchMergeKey=type
24+
// +patchStrategy=merge
25+
// +listType=map
26+
// +listMapKey=type
27+
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"`
28+
Progress []Progress `json:"progress,omitempty"`
29+
}
30+
31+
type Progress struct {
32+
Wave int `json:"wave"`
33+
Percentage int `json:"percentage"`
34+
Count int `json:"count"`
35+
Failures []corev1.ObjectReference `json:"failures,omitempty"`
36+
}
37+
38+
//+kubebuilder:object:root=true
39+
//+kubebuilder:subresource:status
40+
41+
// ClusterDrain is the Schema for the ClusterDrain object
42+
type ClusterDrain struct {
43+
metav1.TypeMeta `json:",inline"`
44+
metav1.ObjectMeta `json:"metadata,omitempty"`
45+
46+
Spec ClusterDrainSpec `json:"spec,omitempty"`
47+
Status ClusterDrainStatus `json:"status,omitempty"`
48+
}
49+
50+
//+kubebuilder:object:root=true
51+
52+
// ClusterDrainList contains a list of ClusterDrain
53+
type ClusterDrainList struct {
54+
metav1.TypeMeta `json:",inline"`
55+
metav1.ListMeta `json:"metadata,omitempty"`
56+
Items []ClusterDrain `json:"items"`
57+
}
58+
59+
func init() {
60+
SchemeBuilder.Register(&ClusterDrain{}, &ClusterDrainList{})
61+
}
62+
63+
func (c *ClusterDrain) SetCondition(condition metav1.Condition) {
64+
meta.SetStatusCondition(&c.Status.Conditions, condition)
65+
}

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 154 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)