/
types.go
255 lines (200 loc) · 6.85 KB
/
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
package navigator
import (
"github.com/coreos/go-semver/semver"
"k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/jetstack/navigator/pkg/cassandra/version"
)
// In this file we define the outer containing types for the ElasticsearchCluster
// type. We could import these directly into message types defined in the types.proto
// file, but this is still TODO
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// CassandraCluster describes a specification for an Cassandra cluster
type CassandraCluster struct {
// we embed these types so the CassandraCluster implements runtime.Object
metav1.TypeMeta
metav1.ObjectMeta
Spec CassandraClusterSpec
Status CassandraClusterStatus
}
type CassandraClusterSpec struct {
NavigatorClusterConfig
NodePools []CassandraClusterNodePool
Version version.Version
Image *ImageSpec
}
type CassandraClusterNodePool struct {
Name string
Replicas *int32
Persistence *PersistenceConfig
NodeSelector map[string]string
Rack *string
Datacenter *string
Resources v1.ResourceRequirements
SchedulerName string
}
type CassandraClusterStatus struct {
NodePools map[string]CassandraClusterNodePoolStatus
}
type CassandraClusterNodePoolStatus struct {
ReadyReplicas int32
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// CassandraClusterList defines a List type for our custom CassandraCluster type.
// This is needed in order to make List operations work.
type CassandraClusterList struct {
// we embed these types so that CassandraClusterList implements runtime.Object and List interfaces
metav1.TypeMeta
metav1.ListMeta
Items []CassandraCluster
}
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// ElasticsearchCluster describes a specification for an Elasticsearch cluster
type ElasticsearchCluster struct {
// we embed these types so the ElasticsearchCluster implements runtime.Object
metav1.TypeMeta
metav1.ObjectMeta
Spec ElasticsearchClusterSpec
Status ElasticsearchClusterStatus
}
type ElasticsearchClusterStatus struct {
NodePools map[string]ElasticsearchClusterNodePoolStatus
Health *ElasticsearchClusterHealth
}
type ElasticsearchClusterNodePoolStatus struct {
ReadyReplicas int32
}
type ElasticsearchClusterHealth string
const (
ElasticsearchClusterHealthRed ElasticsearchClusterHealth = "Red"
ElasticsearchClusterHealthYellow ElasticsearchClusterHealth = "Yellow"
ElasticsearchClusterHealthGreen ElasticsearchClusterHealth = "Green"
)
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// ElasticsearchClusterList defines a List type for our custom ElasticsearchCluster type.
// This is needed in order to make List operations work.
type ElasticsearchClusterList struct {
// we embed these types so that ElasticsearchClusterList implements runtime.Object and List interfaces
metav1.TypeMeta
metav1.ListMeta
Items []ElasticsearchCluster
}
type ElasticsearchClusterSpec struct {
NavigatorClusterConfig
Version semver.Version
Image *ImageSpec
Plugins []string
NodePools []ElasticsearchClusterNodePool
MinimumMasters *int32
}
type ElasticsearchClusterNodePool struct {
Name string
Replicas *int32
Roles []ElasticsearchClusterRole
NodeSelector map[string]string
Resources v1.ResourceRequirements
Persistence *PersistenceConfig
SchedulerName string
}
type ElasticsearchClusterRole string
const (
ElasticsearchRoleData ElasticsearchClusterRole = "data"
ElasticsearchRoleMaster ElasticsearchClusterRole = "master"
ElasticsearchRoleIngest ElasticsearchClusterRole = "ingest"
)
type PersistenceConfig struct {
Size resource.Quantity
StorageClass *string
}
type ImageSpec struct {
Repository string
Tag string
PullPolicy v1.PullPolicy
}
type NavigatorClusterConfig struct {
PilotImage ImageSpec
SecurityContext NavigatorSecurityContext
}
type NavigatorSecurityContext struct {
RunAsUser *int64
}
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type Pilot struct {
metav1.TypeMeta
metav1.ObjectMeta
Spec PilotSpec
Status PilotStatus
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type PilotList struct {
metav1.TypeMeta
metav1.ListMeta
Items []Pilot
}
type PilotSpec struct {
}
type PilotStatus struct {
Conditions []PilotCondition
// Contains status information specific to Elasticsearch Pilots
Elasticsearch *ElasticsearchPilotStatus
// Contains status information specific to Cassandra Pilots
Cassandra *CassandraPilotStatus
}
type ElasticsearchPilotStatus struct {
// Documents is the current number of documents on this node. nil indicates
// an unknown number of documents, whereas 0 indicates that the node is
// empty
Documents *int64
Version *semver.Version
}
type CassandraPilotStatus struct {
Version *version.Version
}
// PilotCondition contains condition information for a Pilot.
type PilotCondition struct {
// Type of the condition, currently ('Ready').
Type PilotConditionType
// Status of the condition, one of ('True', 'False', 'Unknown').
Status ConditionStatus
// LastTransitionTime is the timestamp corresponding to the last status
// change of this condition.
LastTransitionTime metav1.Time
// Reason is a brief machine readable explanation for the condition's last
// transition.
Reason string
// Message is a human readable description of the details of the last
// transition, complementing reason.
Message string
}
// PilotConditionType represents a Pilot condition value.
type PilotConditionType string
const (
// PilotConditionReady represents the fact that a given Pilot condition
// is in ready state.
PilotConditionReady PilotConditionType = "Ready"
// PilotConditionStarted represents the fact that a given Pilot condition
// is in started state.
PilotConditionStarted PilotConditionType = "Started"
// PilotConditionStopped represents the fact that a given Pilot
// condition is in a stopped state.
PilotConditionStopped PilotConditionType = "Stopped"
)
// ConditionStatus represents a condition's status.
type ConditionStatus string
// These are valid condition statuses. "ConditionTrue" means a resource is in
// the condition; "ConditionFalse" means a resource is not in the condition;
// "ConditionUnknown" means kubernetes can't decide if a resource is in the
// condition or not. In the future, we could add other intermediate
// conditions, e.g. ConditionDegraded.
const (
// ConditionTrue represents the fact that a given condition is true
ConditionTrue ConditionStatus = "True"
// ConditionFalse represents the fact that a given condition is false
ConditionFalse ConditionStatus = "False"
// ConditionUnknown represents the fact that a given condition is unknown
ConditionUnknown ConditionStatus = "Unknown"
)