/
elasticsearch_types.go
164 lines (132 loc) · 6.11 KB
/
elasticsearch_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
/*
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 (
"gomodules.xyz/encoding/json/types"
apps "k8s.io/api/apps/v1"
core "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
mona "kmodules.xyz/monitoring-agent-api/api/v1"
ofst "kmodules.xyz/offshoot-api/api/v1"
)
const (
ResourceCodeElasticsearch = "es"
ResourceKindElasticsearch = "Elasticsearch"
ResourceSingularElasticsearch = "elasticsearch"
ResourcePluralElasticsearch = "elasticsearches"
)
// Elasticsearch defines a Elasticsearch database.
//
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
//
// +kubebuilder:object:root=true
// +kubebuilder:skipversion
type Elasticsearch struct {
metav1.TypeMeta `json:",inline,omitempty"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec ElasticsearchSpec `json:"spec,omitempty"`
Status ElasticsearchStatus `json:"status,omitempty"`
}
type ElasticsearchSpec struct {
// Version of Elasticsearch to be deployed.
Version types.StrYo `json:"version"`
// Number of instances to deploy for a Elasticsearch database.
Replicas *int32 `json:"replicas,omitempty"`
// Elasticsearch topology for node specification
Topology *ElasticsearchClusterTopology `json:"topology,omitempty"`
// To enable ssl in transport & http layer
EnableSSL bool `json:"enableSSL,omitempty"`
// Secret with SSL certificates
CertificateSecret *core.SecretVolumeSource `json:"certificateSecret,omitempty"`
// Authentication plugin used by Elasticsearch cluster. If unset, defaults to SearchGuard.
AuthPlugin ElasticsearchAuthPlugin `json:"authPlugin,omitempty"`
// Database authentication secret
DatabaseSecret *core.SecretVolumeSource `json:"databaseSecret,omitempty"`
// StorageType can be durable (default) or ephemeral
StorageType StorageType `json:"storageType,omitempty"`
// Storage to specify how storage shall be used.
Storage *core.PersistentVolumeClaimSpec `json:"storage,omitempty"`
// Init is used to initialize database
// +optional
Init *InitSpec `json:"init,omitempty"`
// BackupSchedule spec to specify how database backup will be taken
// +optional
BackupSchedule *BackupScheduleSpec `json:"backupSchedule,omitempty"`
// Monitor is used monitor database instance
// +optional
Monitor *mona.AgentSpec `json:"monitor,omitempty"`
// ConfigSource is an optional field to provide custom configuration file for database.
// If specified, this file will be used as configuration file otherwise default configuration file will be used.
ConfigSource *core.VolumeSource `json:"configSource,omitempty"`
// PodTemplate is an optional configuration for pods used to expose database
// +optional
PodTemplate ofst.PodTemplateSpec `json:"podTemplate,omitempty"`
// ServiceTemplate is an optional configuration for service used to expose database
// +optional
ServiceTemplate ofst.ServiceTemplateSpec `json:"serviceTemplate,omitempty"`
// An eviction is allowed if at most "maxUnavailable" pods selected by
// "selector" are unavailable after the eviction, i.e. even in absence of
// the evicted pod. For example, one can prevent all voluntary evictions
// by specifying 0. This is a mutually exclusive setting with "minAvailable".
// +optional
MaxUnavailable *intstr.IntOrString `json:"maxUnavailable,omitempty"`
// updateStrategy indicates the StatefulSetUpdateStrategy that will be
// employed to update Pods in the StatefulSet when a revision is made to
// Template.
UpdateStrategy apps.StatefulSetUpdateStrategy `json:"updateStrategy,omitempty"`
// TerminationPolicy controls the delete operation for database
// +optional
TerminationPolicy TerminationPolicy `json:"terminationPolicy,omitempty"`
}
type ElasticsearchClusterTopology struct {
Master ElasticsearchNode `json:"master"`
Data ElasticsearchNode `json:"data"`
Client ElasticsearchNode `json:"client"`
}
type ElasticsearchNode struct {
// Replicas represents number of replica for this specific type of node
Replicas *int32 `json:"replicas,omitempty"`
Prefix string `json:"prefix,omitempty"`
// Storage to specify how storage shall be used.
Storage *core.PersistentVolumeClaimSpec `json:"storage,omitempty"`
// Compute Resources required by the sidecar container.
Resources core.ResourceRequirements `json:"resources,omitempty"`
// An eviction is allowed if at most "maxUnavailable" pods selected by
// "selector" are unavailable after the eviction, i.e. even in absence of
// the evicted pod. For example, one can prevent all voluntary evictions
// by specifying 0. This is a mutually exclusive setting with "minAvailable".
// +optional
MaxUnavailable *intstr.IntOrString `json:"maxUnavailable,omitempty"`
}
type ElasticsearchStatus struct {
Phase DatabasePhase `json:"phase,omitempty"`
Reason string `json:"reason,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 *types.IntHash `json:"observedGeneration,omitempty"`
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type ElasticsearchList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
// Items is a list of Elasticsearch CRD objects
Items []Elasticsearch `json:"items,omitempty"`
}
type ElasticsearchAuthPlugin string
const (
ElasticsearchAuthPluginSearchGuard ElasticsearchAuthPlugin = "SearchGuard" // Default
ElasticsearchAuthPluginNone ElasticsearchAuthPlugin = "None"
ElasticsearchAuthPluginXpack ElasticsearchAuthPlugin = "X-Pack"
)