/
elasticsearch_ops_types.go
221 lines (199 loc) · 10.1 KB
/
elasticsearch_ops_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
/*
Copyright AppsCode Inc. and Contributors
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 (
core "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
kmapi "kmodules.xyz/client-go/api/v1"
)
const (
ResourceCodeElasticsearchOpsRequest = "esops"
ResourceKindElasticsearchOpsRequest = "ElasticsearchOpsRequest"
ResourceSingularElasticsearchOpsRequest = "elasticsearchopsrequest"
ResourcePluralElasticsearchOpsRequest = "elasticsearchopsrequests"
)
// ElasticsearchOpsRequest defines a Elasticsearch DBA operation.
// +genclient
// +k8s:openapi-gen=true
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:object:root=true
// +kubebuilder:resource:path=elasticsearchopsrequests,singular=elasticsearchopsrequest,shortName=esops,categories={datastore,kubedb,appscode}
// +kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="Type",type="string",JSONPath=".spec.type"
// +kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.phase"
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
type ElasticsearchOpsRequest struct {
metav1.TypeMeta `json:",inline,omitempty"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec ElasticsearchOpsRequestSpec `json:"spec,omitempty"`
Status ElasticsearchOpsRequestStatus `json:"status,omitempty"`
}
// ElasticsearchOpsRequestSpec is the spec for ElasticsearchOpsRequest
type ElasticsearchOpsRequestSpec struct {
// Specifies the Elasticsearch reference
DatabaseRef core.LocalObjectReference `json:"databaseRef"`
// Specifies the ops request type: Upgrade, HorizontalScaling, VerticalScaling etc.
Type OpsRequestType `json:"type"`
// Specifies information necessary for upgrading Elasticsearch
Upgrade *ElasticsearchUpgradeSpec `json:"upgrade,omitempty"`
// Specifies information necessary for horizontal scaling
HorizontalScaling *ElasticsearchHorizontalScalingSpec `json:"horizontalScaling,omitempty"`
// Specifies information necessary for vertical scaling
VerticalScaling *ElasticsearchVerticalScalingSpec `json:"verticalScaling,omitempty"`
// Specifies information necessary for volume expansion
VolumeExpansion *ElasticsearchVolumeExpansionSpec `json:"volumeExpansion,omitempty"`
// Specifies information necessary for custom configuration of Elasticsearch
Configuration *ElasticsearchCustomConfigurationSpec `json:"configuration,omitempty"`
// Specifies information necessary for configuring TLS
TLS *TLSSpec `json:"tls,omitempty"`
// Specifies information necessary for restarting database
Restart *RestartSpec `json:"restart,omitempty"`
// Timeout for each step of the ops request in second. If a step doesn't finish within the specified timeout, the ops request will result in failure.
Timeout *metav1.Duration `json:"timeout,omitempty"`
}
type ElasticsearchUpgradeSpec struct {
// Specifies the target version name from catalog
TargetVersion string `json:"targetVersion,omitempty"`
}
// ElasticsearchHorizontalScalingSpec contains the horizontal scaling information of an Elasticsearch cluster
type ElasticsearchHorizontalScalingSpec struct {
// Number of combined (i.e. master, data, ingest) node
Node *int32 `json:"node,omitempty"`
// Node topology specification
Topology *ElasticsearchHorizontalScalingTopologySpec `json:"topology,omitempty"`
}
// ElasticsearchHorizontalScalingTopologySpec contains the horizontal scaling information in cluster topology mode
type ElasticsearchHorizontalScalingTopologySpec struct {
// Number of master nodes
Master *int32 `json:"master,omitempty"`
// Number of ingest nodes
Ingest *int32 `json:"ingest,omitempty"`
// Number of data nodes
Data *int32 `json:"data,omitempty"`
DataContent *int32 `json:"dataContent,omitempty"`
DataHot *int32 `json:"dataHot,omitempty"`
DataWarm *int32 `json:"dataWarm,omitempty"`
DataCold *int32 `json:"dataCold,omitempty"`
DataFrozen *int32 `json:"dataFrozen,omitempty"`
ML *int32 `json:"ml,omitempty"`
Transform *int32 `json:"transform,omitempty"`
Coordinating *int32 `json:"coordinating,omitempty"`
}
// ElasticsearchVerticalScalingSpec is the spec for Elasticsearch vertical scaling
type ElasticsearchVerticalScalingSpec struct {
// Resource spec for combined nodes
Node *core.ResourceRequirements `json:"node,omitempty"`
// Resource spec for exporter sidecar
Exporter *core.ResourceRequirements `json:"exporter,omitempty"`
// Specifies the resource spec for cluster in topology mode
Topology *ElasticsearchVerticalScalingTopologySpec `json:"topology,omitempty"`
}
// ElasticsearchVerticalScalingTopologySpec is the resource spec in the cluster topology mode
type ElasticsearchVerticalScalingTopologySpec struct {
Master *core.ResourceRequirements `json:"master,omitempty"`
Ingest *core.ResourceRequirements `json:"ingest,omitempty"`
Data *core.ResourceRequirements `json:"data,omitempty"`
DataContent *core.ResourceRequirements `json:"dataContent,omitempty"`
DataHot *core.ResourceRequirements `json:"dataHot,omitempty"`
DataWarm *core.ResourceRequirements `json:"dataWarm,omitempty"`
DataCold *core.ResourceRequirements `json:"dataCold,omitempty"`
DataFrozen *core.ResourceRequirements `json:"dataFrozen,omitempty"`
ML *core.ResourceRequirements `json:"ml,omitempty"`
Transform *core.ResourceRequirements `json:"transform,omitempty"`
Coordinating *core.ResourceRequirements `json:"coordinating,omitempty"`
}
// ElasticsearchVolumeExpansionSpec is the spec for Elasticsearch volume expansion
type ElasticsearchVolumeExpansionSpec struct {
// +kubebuilder:default:="Online"
Mode *VolumeExpansionMode `json:"mode,omitempty"`
// volume specification for combined nodes
Node *resource.Quantity `json:"node,omitempty"`
// volume specification for nodes in cluster topology
Topology *ElasticsearchVolumeExpansionTopologySpec `json:"topology,omitempty"`
}
// ElasticsearchVolumeExpansionTopologySpec is the spec for Elasticsearch volume expansion in topology mode
type ElasticsearchVolumeExpansionTopologySpec struct {
// volume specification for master nodes
Master *resource.Quantity `json:"master,omitempty"`
// volume specification for ingest nodes
Ingest *resource.Quantity `json:"ingest,omitempty"`
// volume specification for data nodes
Data *resource.Quantity `json:"data,omitempty"`
DataContent *resource.Quantity `json:"dataContent,omitempty"`
DataHot *resource.Quantity `json:"dataHot,omitempty"`
DataWarm *resource.Quantity `json:"dataWarm,omitempty"`
DataCold *resource.Quantity `json:"dataCold,omitempty"`
DataFrozen *resource.Quantity `json:"dataFrozen,omitempty"`
ML *resource.Quantity `json:"ml,omitempty"`
Transform *resource.Quantity `json:"transform,omitempty"`
Coordinating *resource.Quantity `json:"coordinating,omitempty"`
}
// ElasticsearchCustomConfigurationSpec is the spec for Reconfiguring the Elasticsearch Settings
type ElasticsearchCustomConfigurationSpec struct {
// ConfigSecret is an optional field to provide custom configuration file for database.
// +optional
ConfigSecret *core.LocalObjectReference `json:"configSecret,omitempty"`
// SecureConfigSecret is an optional field to provide secure settings for database.
// - Ref: https://www.elastic.co/guide/en/elasticsearch/reference/7.14/secure-settings.html
// +optional
SecureConfigSecret *core.LocalObjectReference `json:"secureConfigSecret,omitempty"`
// ApplyConfig is an optional field to provide Elasticsearch configuration.
// Provided configuration will be applied to config files stored in ConfigSecret.
// If the ConfigSecret is missing, the operator will create a new k8s secret by the
// following naming convention: {db-name}-user-config .
// Expected input format:
// applyConfig:
// file-name.yml: |
// key: value
// elasticsearch.yml: |
// thread_pool:
// write:
// size: 30
// +optional
ApplyConfig map[string]string `json:"applyConfig,omitempty"`
// If set to "true", the user provided configuration will be removed.
// The Elasticsearch cluster will start will default configuration that is generated by the operator.
// +optional
RemoveCustomConfig bool `json:"removeCustomConfig,omitempty"`
// If set to "true", the user provided secure settings will be removed.
// The elasticsearch.keystore will start will default password (i.e. "").
// +optional
RemoveSecureCustomConfig bool `json:"removeSecureCustomConfig,omitempty"`
}
type ElasticsearchCustomConfiguration struct {
ConfigMap *core.LocalObjectReference `json:"configMap,omitempty"`
Data map[string]string `json:"data,omitempty"`
Remove bool `json:"remove,omitempty"`
}
// ElasticsearchOpsRequestStatus is the status for ElasticsearchOpsRequest
type ElasticsearchOpsRequestStatus struct {
// Specifies the current phase of the ops request
// +optional
Phase OpsRequestPhase `json:"phase,omitempty"`
// observedGeneration is the most recent generation observed for this resource. It corresponds to the
// resource's generation, which is updated on mutation by the API Server.
// +optional
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
// Conditions applied to the request, such as approval or denial.
// +optional
Conditions []kmapi.Condition `json:"conditions,omitempty"`
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// ElasticsearchOpsRequestList is a list of ElasticsearchOpsRequests
type ElasticsearchOpsRequestList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
// Items is a list of ElasticsearchOpsRequest CRD objects
Items []ElasticsearchOpsRequest `json:"items,omitempty"`
}