-
Notifications
You must be signed in to change notification settings - Fork 53
/
opnicluster_types.go
275 lines (237 loc) · 12 KB
/
opnicluster_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
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
/*
Copyright 2021.
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.
*/
// +kubebuilder:validation:Optional
package v1beta2
import (
opnimeta "github.com/rancher/opni/pkg/util/meta"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
)
// +kubebuilder:validation:Enum=username;nkey
type NatsAuthMethod string
const (
NatsAuthUsername NatsAuthMethod = "username"
NatsAuthNkey NatsAuthMethod = "nkey"
)
type OpniClusterState string
const (
OpniClusterStateError OpniClusterState = "Error"
OpniClusterStateWorking OpniClusterState = "Working"
OpniClusterStateReady OpniClusterState = "Ready"
)
// OpniClusterSpec defines the desired state of OpniCluster
type OpniClusterSpec struct {
// +kubebuilder:default:=latest
Version string `json:"version"`
// +optional
DefaultRepo *string `json:"defaultRepo,omitempty"`
Services ServicesSpec `json:"services,omitempty"`
Opensearch OpensearchClusterSpec `json:"opensearch,omitempty"`
Nats NatsSpec `json:"nats,omitempty"`
S3 S3Spec `json:"s3,omitempty"`
NulogHyperparameters map[string]intstr.IntOrString `json:"nulogHyperparameters,omitempty"`
DeployLogCollector *bool `json:"deployLogCollector"`
GlobalNodeSelector map[string]string `json:"globalNodeSelector,omitempty"`
GlobalTolerations []corev1.Toleration `json:"globalTolerations,omitempty"`
}
// OpniClusterStatus defines the observed state of OpniCluster
type OpniClusterStatus struct {
Conditions []string `json:"conditions,omitempty"`
State OpniClusterState `json:"state,omitempty"`
OpensearchState OpensearchStatus `json:"opensearchState,omitempty"`
LogCollectorState OpniClusterState `json:"logState,omitempty"`
NatsReplicas int32 `json:"natsReplicas,omitempty"`
Auth AuthStatus `json:"auth,omitempty"`
PrometheusRuleNamespace string `json:"prometheusRuleNamespace,omitempty"`
}
type AuthStatus struct {
NKeyUser string `json:"nKeyUser,omitempty"`
NatsAuthSecretKeyRef *corev1.SecretKeySelector `json:"natsAuthSecretKeyRef,omitempty"`
GenerateOpensearchHash *bool `json:"generateOpensearchHash"`
OpensearchAuthSecretKeyRef *corev1.SecretKeySelector `json:"opensearchAuthSecretKeyRef,omitempty"`
S3Endpoint string `json:"s3Endpoint,omitempty"`
S3AccessKey *corev1.SecretKeySelector `json:"s3AccessKey,omitempty"`
S3SecretKey *corev1.SecretKeySelector `json:"s3SecretKey,omitempty"`
}
type OpensearchStatus struct {
IndexState OpniClusterState `json:"indexState,omitempty"`
Version *string `json:"version,omitempty"`
Initialized bool `json:"initialized,omitempty"`
}
//+kubebuilder:webhook:path=/highlander-opni-io-v1beta1-opnicluster,mutating=false,failurePolicy=fail,sideEffects=None,groups=opni.io,resources=opniclusters,verbs=create;update,versions={v1beta1,v1beta2},name=highlander.opni.io,admissionReviewVersions={v1,v1beta1}
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`
// +kubebuilder:printcolumn:name="State",type=boolean,JSONPath=`.status.state`
// +kubebuilder:storageversion
// OpniCluster is the Schema for the opniclusters API
type OpniCluster struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec OpniClusterSpec `json:"spec,omitempty"`
Status OpniClusterStatus `json:"status,omitempty"`
}
type ServicesSpec struct {
Drain DrainServiceSpec `json:"drain,omitempty"`
Inference InferenceServiceSpec `json:"inference,omitempty"`
Preprocessing PreprocessingServiceSpec `json:"preprocessing,omitempty"`
PayloadReceiver PayloadReceiverServiceSpec `json:"payloadReceiver,omitempty"`
GPUController GPUControllerServiceSpec `json:"gpuController,omitempty"`
Metrics MetricsServiceSpec `json:"metrics,omitempty"`
OpensearchUpdate OpensearchUpdateServiceSpec `json:"opensearchUpdate,omitempty"`
}
type DrainServiceSpec struct {
opnimeta.ImageSpec `json:",inline,omitempty"`
Enabled *bool `json:"enabled,omitempty"`
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`
Replicas *int32 `json:"replicas,omitempty"`
}
type InferenceServiceSpec struct {
opnimeta.ImageSpec `json:",inline,omitempty"`
Enabled *bool `json:"enabled,omitempty"`
PretrainedModels []corev1.LocalObjectReference `json:"pretrainedModels,omitempty"`
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`
}
type PreprocessingServiceSpec struct {
opnimeta.ImageSpec `json:",inline,omitempty"`
Enabled *bool `json:"enabled,omitempty"`
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`
Replicas *int32 `json:"replicas,omitempty"`
}
type PayloadReceiverServiceSpec struct {
opnimeta.ImageSpec `json:",inline,omitempty"`
Enabled *bool `json:"enabled,omitempty"`
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`
}
type GPUControllerServiceSpec struct {
opnimeta.ImageSpec `json:",inline,omitempty"`
Enabled *bool `json:"enabled,omitempty"`
RuntimeClass *string `json:"runtimeClass,omitempty"`
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`
}
type MetricsServiceSpec struct {
opnimeta.ImageSpec `json:",inline,omitempty"`
Enabled *bool `json:"enabled,omitempty"`
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`
ExtraVolumeMounts []opnimeta.ExtraVolumeMount `json:"extraVolumeMounts,omitempty"`
PrometheusEndpoint string `json:"prometheusEndpoint,omitempty"`
PrometheusReference *opnimeta.PrometheusReference `json:"prometheus,omitempty"`
}
type InsightsServiceSpec struct {
opnimeta.ImageSpec `json:",inline,omitempty"`
Enabled *bool `json:"enabled,omitempty"`
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`
}
type UIServiceSpec struct {
opnimeta.ImageSpec `json:",inline,omitempty"`
Enabled *bool `json:"enabled,omitempty"`
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`
}
type OpensearchUpdateServiceSpec struct {
opnimeta.ImageSpec `json:",inline,omitempty"`
Enabled *bool `json:"enabled,omitempty"`
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`
}
type OpensearchClusterSpec struct {
ExternalOpensearch *opnimeta.OpensearchClusterRef `json:"externalOpensearch"`
Version string `json:"version"`
Workloads OpensearchWorkloadSpec `json:"workloads,omitempty"`
DefaultRepo *string `json:"defaultRepo,omitempty"`
Image *opnimeta.ImageSpec `json:"image,omitempty"`
DashboardsImage *opnimeta.ImageSpec `json:"dashboardsImage,omitempty"`
Persistence *opnimeta.PersistenceSpec `json:"persistence,omitempty"`
EnableLogIndexManagement *bool `json:"enableLogIndexManagement"`
EnableIngestPreprocessing bool `json:"enableIngestPreprocessing,omitempty"`
// Secret containing an item "logging.yml" with the contents of the
// elasticsearch logging config.
ConfigSecret *corev1.LocalObjectReference `json:"configSecret,omitempty"`
// Reference to a secret containing the desired admin password
AdminPasswordFrom *corev1.SecretKeySelector `json:"adminPasswordFrom,omitempty"`
}
type OpensearchWorkloadSpec struct {
Master OpensearchWorkloadOptions `json:"master,omitempty"`
Data OpensearchWorkloadOptions `json:"data,omitempty"`
Client OpensearchWorkloadOptions `json:"client,omitempty"`
Dashboards OpensearchWorkloadOptions `json:"dashboards,omitempty"`
}
type OpensearchWorkloadOptions struct {
Replicas *int32 `json:"replicas,omitempty"`
Resources *corev1.ResourceRequirements `json:"resources,omitempty"`
Affinity *corev1.Affinity `json:"affinity,omitempty"`
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`
}
type S3Spec struct {
// If set, Opni will deploy an S3 pod to use internally.
// Cannot be set at the same time as `external`.
Internal *InternalSpec `json:"internal,omitempty"`
// If set, Opni will connect to an external S3 endpoint.
// Cannot be set at the same time as `internal`.
External *ExternalSpec `json:"external,omitempty"`
// Bucket used to persist nulog models. If not set will use
// opni-nulog-models.
NulogS3Bucket string `json:"nulogS3Bucket,omitempty"`
// Bucket used to persiste drain models. It not set will use
// opni-drain-models
DrainS3Bucket string `json:"drainS3Bucket,omitempty"`
}
type InternalSpec struct {
// Persistence configuration for internal S3 deployment. If unset, internal
// S3 storage is not persistent.
Persistence *opnimeta.PersistenceSpec `json:"persistence,omitempty"`
}
type ExternalSpec struct {
// +kubebuilder:validation:Required
// External S3 endpoint URL.
Endpoint string `json:"endpoint,omitempty"`
// +kubebuilder:validation:Required
// Reference to a secret containing "accessKey" and "secretKey" items. This
// secret must already exist if specified.
Credentials *corev1.SecretReference `json:"credentials,omitempty"`
}
type NatsSpec struct {
// +kubebuilder:validation:Required
// +kubebuilder:default:=username
AuthMethod NatsAuthMethod `json:"authMethod,omitempty"`
// Username to use for authentication, if username auth is specified in
// AuthMethod. If empty, defaults to "nats-user". If AuthMethod is "nkey",
// this field is ignored.
Username string `json:"username,omitempty"`
// Number of nats server replicas. If not set, defaults to 3.
Replicas *int32 `json:"replicas,omitempty"`
// A secret containing a "password" item. This secret must already exist
// if specified.
PasswordFrom *corev1.SecretKeySelector `json:"passwordFrom,omitempty"`
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`
}
// +kubebuilder:object:root=true
// OpniClusterList contains a list of OpniCluster
type OpniClusterList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []OpniCluster `json:"items"`
}
func init() {
SchemeBuilder.Register(&OpniCluster{}, &OpniClusterList{})
}