@@ -17,25 +17,111 @@ limitations under the License.
17
17
package v1alpha1
18
18
19
19
import (
20
+ v1 "k8s.io/api/core/v1"
20
21
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21
- )
22
+ "k8s.io/apimachinery/pkg/util/intstr"
22
23
23
- // EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
24
- // NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
24
+ // let's temporarily use godel scheduler's definition, consider to switch to community definitions
25
+ schedv1alpha1 "github.com/kubewharf/godel-scheduler-api/pkg/apis/scheduling/v1alpha1"
26
+ )
25
27
26
28
// RoleSetSpec defines the desired state of RoleSet
27
29
type RoleSetSpec struct {
28
- // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
29
- // Important: Run "make" to regenerate code after modifying this file
30
+ Roles []RoleSpec `json:"roles,omitempty"`
31
+
32
+ // +optional
33
+ UpdateStrategy RoleSetUpdateStrategyType `json:"updateStrategy,omitempty"`
34
+
35
+ // +optional
36
+ SchedulingStrategy SchedulingStrategy `json:"schedulingStrategy,omitempty"`
37
+ }
30
38
31
- // Foo is an example field of RoleSet. Edit roleset_types.go to remove/update
32
- Foo string `json:"foo,omitempty"`
39
+ // +enum
40
+ type SchedulingStrategy struct {
41
+ PodGroup * schedv1alpha1.PodGroupSpec `json:"podGroup,omitempty"`
42
+ }
43
+
44
+ // +enum
45
+ type RoleSetUpdateStrategyType string
46
+
47
+ const (
48
+ // ParallelRoleSetUpdateStrategyType update all roles in parallel
49
+ ParallelRoleSetUpdateStrategyType RoleSetUpdateStrategyType = "Parallel"
50
+ // SequentialRoleSetStrategyType update all roles in sequential
51
+ SequentialRoleSetStrategyType RoleSetUpdateStrategyType = "Sequential"
52
+ // InterleaveRoleSetStrategyType update all roles in interleave, follow the rolling step defined in roles
53
+ InterleaveRoleSetStrategyType RoleSetUpdateStrategyType = "Interleave"
54
+ )
55
+
56
+ type DisruptionTolerance struct {
57
+ MaxUnavailable * intstr.IntOrString `json:"maxUnavailable,omitempty"`
58
+ }
59
+
60
+ type RoleSpec struct {
61
+ Name string `json:"name,omitempty"`
62
+
63
+ // Replicas is the number of desired replicas.
64
+ // +optional
65
+ Replicas * int32 `json:"replicas,omitempty"`
66
+
67
+ // +optional
68
+ // +patchStrategy=retainKeys
69
+ UpdateStrategy RoleUpdateStrategy `json:"updateStrategy,omitempty"`
70
+
71
+ // +optional
72
+ Stateful bool `json:"stateful,omitempty"`
73
+
74
+ // +optional
75
+ Template v1.PodTemplateSpec `json:"template,omitempty"`
76
+
77
+ // DisruptionTolerance indicates how many pods can be unavailable during the preemption/eviction.
78
+ // +optional
79
+ DisruptionTolerance DisruptionTolerance `json:"disruptionTolerance,omitempty"`
80
+ }
81
+
82
+ // +enum
83
+ type RoleUpdateStrategy struct {
84
+ // +optional
85
+ MaxUnavailable * intstr.IntOrString `json:"maxUnavailable,omitempty" protobuf:"bytes,1,opt,name=maxUnavailable"`
86
+
87
+ // +optional
88
+ MaxSurge * intstr.IntOrString `json:"maxSurge,omitempty" protobuf:"bytes,2,opt,name=maxSurge"`
33
89
}
34
90
35
91
// RoleSetStatus defines the observed state of RoleSet
36
92
type RoleSetStatus struct {
37
- // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
38
- // Important: Run "make" to regenerate code after modifying this file
93
+ Roles []RoleStatus `json:"roles,omitempty"`
94
+ // +optional
95
+ // +patchMergeKey=type
96
+ // +patchStrategy=merge
97
+ Conditions Conditions `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"`
98
+ }
99
+
100
+ // These are valid conditions of roleSet.
101
+ const (
102
+ // RoleSetReady means the roleSet meeting the minimal requirements for the roleSet to be considered ready.
103
+ RoleSetReady ConditionType = "Ready"
104
+ RoleSetReplicaFailure ConditionType = "ReplicaFailure"
105
+ RoleSetProgressing ConditionType = "Progressing"
106
+ )
107
+
108
+ type RoleStatus struct {
109
+ Name string `json:"name,omitempty"`
110
+
111
+ // Replicas is the most recently oberved number of replicas.
112
+ Replicas int32 `json:"replicas"`
113
+
114
+ // +optional
115
+ ReadyReplicas int32 `json:"readyReplicas,omitempty"`
116
+
117
+ // +optional
118
+ NotReadyReplicas int32 `json:"notReadyReplicas,omitempty"`
119
+
120
+ // +optional
121
+ UpdatedReplicas int32 `json:"updatedReplicas,omitempty"`
122
+
123
+ // +optional
124
+ UpdatedReadyReplicas int32 `json:"updatedReadyReplicas,omitempty"`
39
125
}
40
126
41
127
//+kubebuilder:object:root=true
0 commit comments