-
Notifications
You must be signed in to change notification settings - Fork 200
/
nodegroup_types.go
122 lines (102 loc) · 4.2 KB
/
nodegroup_types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/*
Copyright 2021 The SuperEdge authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v1alpha1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
type WorkloadType string
const (
WorkloadPod WorkloadType = "Pod"
WorkloadJob WorkloadType = "Job"
WorkloadCronjob WorkloadType = "CronJob"
WorkloadDeploy WorkloadType = "Deployment"
WorkloadService WorkloadType = "Service"
WorkloadReplicaSet WorkloadType = "ReplicaSet"
WorkloadDaemonset WorkloadType = "DaemonSet"
WorkloadStatuefulset WorkloadType = "StatuefulSet"
)
type Workload struct {
// workload name
// +optional
Name string `json:"name" protobuf:"bytes,2,opt,name=name"`
// workload type, Value can be pod, deploy, ds, service, job, st
// +optional
Type WorkloadType `json:"type" protobuf:"bytes,2,opt,name=type"`
// If specified, Label selector for workload.
// +optional
Selector *Selector `json:"selector" protobuf:"bytes,2,opt,name=selector"`
}
// NodeGroupSpec defines the desired state of NodeGroup
type NodeGroupSpec struct {
// If specified, If nodeUnit exists, join NodeGroup directly
// +optional
NodeUnits []string `json:"nodeunits,omitempty" protobuf:"bytes,12,opt,name=nodeunits"`
// If specified, Label selector for nodeUnit.
// +optional
Selector *Selector `json:"selector,omitempty" protobuf:"bytes,2,opt,name=selector"`
// If specified, create new NodeUnits based on node have same label keys, for different values will create different nodeunites
// +optional
AutoFindNodeKeys []string `json:"autofindnodekeys,omitempty" protobuf:"bytes,12,opt,name=autofindnodekeys"`
// If specified, Nodegroup bound workload
// +optional
Workload []Workload `json:"workload,omitempty" protobuf:"bytes,12,opt,name=workload"`
}
// NodeGroupStatus defines the observed state of NodeGroup
type WorkloadStatus struct {
// workload Name
// +optional
WorkloadName string `json:"workloadname,omitempty" protobuf:"bytes,12,opt,name=workloadname"`
// workload Ready Units
// +optional
ReadyUnit []string `json:"readyunit,omitempty" protobuf:"bytes,12,opt,name=readyunit"`
// workload NotReady Units
// +optional
NotReadyUnit []string `json:"notreadyunit,omitempty" protobuf:"bytes,12,opt,name=notreadyunit"`
}
// NodeGroupStatus defines the observed state of NodeGroup
type NodeGroupStatus struct {
// NodeUnit that is number in nodegroup
//+kubebuilder:default=0
// +optional
UnitNumber int `json:"unitnumber" protobuf:"bytes,2,rep,name=unitnumber"`
// Nodeunit contained in nodegroup
// +optional
NodeUnits []string `json:"nodeunits,omitempty" protobuf:"bytes,12,opt,name=nodeunits"`
// The status of the workload in the nodegroup in each nodeunit
// +optional
WorkloadStatus []WorkloadStatus `json:"workloadstatus,omitempty" protobuf:"bytes,12,opt,name=workloadstatus"`
}
// +genclient
// +genclient:nonNamespaced
//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
//+kubebuilder:resource:shortName=ng,scope=Cluster,path=nodegroups,categories=all
//+kubebuilder:printcolumn:name="UNITS",type="integer",JSONPath=`.status.unitnumber`
//+kubebuilder:printcolumn:name="AGE",type="date",JSONPath=".metadata.creationTimestamp"
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type NodeGroup struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec NodeGroupSpec `json:"spec,omitempty"`
Status NodeGroupStatus `json:"status,omitempty"`
}
//+kubebuilder:object:root=true
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type NodeGroupList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []NodeGroup `json:"items"`
}
//func init() {
// SchemeBuilder.Register(&NodeGroup{}, &NodeGroupList{})
//}