/
constants.go
382 lines (328 loc) · 16.3 KB
/
constants.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
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
/*
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 v1alpha2
import (
"time"
"kubedb.dev/apimachinery/apis/kubedb"
core "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
)
const (
// Deprecated
DatabaseNamePrefix = "kubedb"
KubeDBOrganization = "kubedb"
LabelRole = kubedb.GroupName + "/role"
ReplicationModeDetectorContainerName = "replication-mode-detector"
DatabasePodPrimary = "primary"
DatabasePodStandby = "standby"
ComponentDatabase = "database"
ComponentConnectionPooler = "connection-pooler"
RoleStats = "stats"
DefaultStatsPath = "/metrics"
DefaultPasswordLength = 16
HealthCheckInterval = 10 * time.Second
ContainerExporterName = "exporter"
LocalHost = "localhost"
LocalHostIP = "127.0.0.1"
DBCustomConfigName = "custom-config"
DefaultVolumeClaimTemplateName = "data"
DBTLSVolume = "tls-volume"
DBExporterTLSVolume = "exporter-tls-volume"
// =========================== Database key Constants ============================
PostgresKey = ResourceSingularPostgres + "." + kubedb.GroupName
ElasticsearchKey = ResourceSingularElasticsearch + "." + kubedb.GroupName
MySQLKey = ResourceSingularMySQL + "." + kubedb.GroupName
MariaDBKey = ResourceSingularMariaDB + "." + kubedb.GroupName
PerconaXtraDBKey = ResourceSingularPerconaXtraDB + "." + kubedb.GroupName
MongoDBKey = ResourceSingularMongoDB + "." + kubedb.GroupName
RedisKey = ResourceSingularRedis + "." + kubedb.GroupName
MemcachedKey = ResourceSingularMemcached + "." + kubedb.GroupName
EtcdKey = ResourceSingularEtcd + "." + kubedb.GroupName
ProxySQLKey = ResourceSingularProxySQL + "." + kubedb.GroupName
// =========================== Elasticsearch Constants ============================
ElasticsearchRestPort = 9200
ElasticsearchRestPortName = "http"
ElasticsearchTransportPort = 9300
ElasticsearchTransportPortName = "transport"
ElasticsearchPerformanceAnalyzerPort = 9600
ElasticsearchPerformanceAnalyzerPortName = "analyzer"
ElasticsearchNodeRoleSet = "set"
ElasticsearchConfigDir = "/usr/share/elasticsearch/config"
ElasticsearchOpenSearchConfigDir = "/usr/share/opensearch/config"
ElasticsearchSecureSettingsDir = "/elasticsearch/secure-settings"
ElasticsearchTempConfigDir = "/elasticsearch/temp-config"
ElasticsearchCustomConfigDir = "/elasticsearch/custom-config"
ElasticsearchDataDir = "/usr/share/elasticsearch/data"
ElasticsearchOpenSearchDataDir = "/usr/share/opensearch/data"
ElasticsearchOpendistroSecurityConfigDir = "/usr/share/elasticsearch/plugins/opendistro_security/securityconfig"
ElasticsearchOpenSearchSecurityConfigDir = "/usr/share/opensearch/plugins/opensearch-security/securityconfig"
ElasticsearchSearchGuardSecurityConfigDir = "/usr/share/elasticsearch/plugins/search-guard-%v/sgconfig"
ElasticsearchOpendistroReadallMonitorRole = "readall_and_monitor"
ElasticsearchOpenSearchReadallMonitorRole = "readall_and_monitor"
ElasticsearchSearchGuardReadallMonitorRoleV7 = "SGS_READALL_AND_MONITOR"
ElasticsearchSearchGuardReadallMonitorRoleV6 = "sg_readall_and_monitor"
ElasticsearchStatusGreen = "green"
ElasticsearchStatusYellow = "yellow"
ElasticsearchStatusRed = "red"
ElasticsearchInitSysctlContainerName = "init-sysctl"
ElasticsearchInitConfigMergerContainerName = "config-merger"
ElasticsearchContainerName = "elasticsearch"
ElasticsearchExporterContainerName = "exporter"
ElasticsearchSearchGuardRolesMappingFileName = "sg_roles_mapping.yml"
ElasticsearchSearchGuardInternalUserFileName = "sg_internal_users.yml"
ElasticsearchOpendistroRolesMappingFileName = "roles_mapping.yml"
ElasticsearchOpendistroInternalUserFileName = "internal_users.yml"
ElasticsearchJavaOptsEnv = "ES_JAVA_OPTS"
ElasticsearchOpenSearchJavaOptsEnv = "OPENSEARCH_JAVA_OPTS"
// Ref:
// - https://www.elastic.co/guide/en/elasticsearch/reference/7.6/heap-size.html#heap-size
// - no more than 50% of your physical RAM
// - no more than 32GB that the JVM uses for compressed object pointers (compressed oops)
// - no more than 26GB for zero-based compressed oops;
// 26 GB is safe on most systems
ElasticsearchMaxHeapSize = 26 * 1024 * 1024 * 1024
// 128MB
ElasticsearchMinHeapSize = 128 * 1024 * 1024
// =========================== Memcached Constants ============================
MemcachedDatabasePortName = "db"
MemcachedPrimaryServicePortName = "primary"
MemcachedDatabasePort = 11211
// =========================== MongoDB Constants ============================
MongoDBDatabasePortName = "db"
MongoDBPrimaryServicePortName = "primary"
MongoDBDatabasePort = 27017
MongoDBKeyFileSecretSuffix = "-key"
MongoDBRootUsername = "root"
MongoDBCustomConfigFile = "mongod.conf"
MongoDBReplicaSetConfig = "replicaset.json"
MongoDBConfigurationJSFile = "configuration.js"
NodeTypeMongos = "mongos"
NodeTypeShard = "shard"
NodeTypeConfig = "configsvr"
NodeTypeArbiter = "arbiter"
NodeTypeReplica = "replica"
NodeTypeStandalone = "standalone"
MongoDBWorkDirectoryName = "workdir"
MongoDBWorkDirectoryPath = "/work-dir"
MongoDBCertDirectoryName = "certdir"
MongoDBDataDirectoryName = "datadir"
MongoDBDataDirectoryPath = "/data/db"
MongoDBInitInstallContainerName = "copy-config"
MongoDBInitBootstrapContainerName = "bootstrap"
MongoDBConfigDirectoryName = "config"
MongoDBConfigDirectoryPath = "/data/configdb"
MongoDBInitialConfigDirectoryName = "configdir"
MongoDBInitialConfigDirectoryPath = "/configdb-readonly"
MongoDBInitScriptDirectoryName = "init-scripts"
MongoDBInitScriptDirectoryPath = "/init-scripts"
MongoDBInitialDirectoryName = "initial-script"
MongoDBInitialDirectoryPath = "/docker-entrypoint-initdb.d"
MongoDBClientCertDirectoryName = "client-cert"
MongoDBClientCertDirectoryPath = "/client-cert"
MongoDBServerCertDirectoryName = "server-cert"
MongoDBServerCertDirectoryPath = "/server-cert"
MongoDBInitialKeyDirectoryName = "keydir"
MongoDBInitialKeyDirectoryPath = "/keydir-readonly"
MongoDBContainerName = ResourceSingularMongoDB
MongoDBDefaultVolumeClaimTemplateName = MongoDBDataDirectoryName
MongodbUser = "root"
MongoDBKeyForKeyFile = "key.txt"
MongoDBAuthSecretSuffix = "-auth"
// =========================== MySQL Constants ============================
MySQLMetricsExporterConfigSecretSuffix = "metrics-exporter-config"
MySQLDatabasePortName = "db"
MySQLRouterReadWritePortName = "rw"
MySQLRouterReadOnlyPortName = "ro"
MySQLPrimaryServicePortName = "primary"
MySQLStandbyServicePortName = "standby"
MySQLDatabasePort = 3306
MySQLRouterReadWritePort = 6446
MySQLRouterReadOnlyPort = 6447
MySQLGroupComPort = 33060
MySQLMaxGroupMembers = 9
// The recommended MySQL server version for group replication (GR)
MySQLGRRecommendedVersion = "8.0.23"
MySQLDefaultGroupSize = 3
MySQLRootUserName = "MYSQL_ROOT_USERNAME"
MySQLRootPassword = "MYSQL_ROOT_PASSWORD"
MySQLName = "MYSQL_NAME"
MySQLTLSConfigCustom = "custom"
MySQLTLSConfigSkipVerify = "skip-verify"
MySQLTLSConfigTrue = "true"
MySQLTLSConfigFalse = "false"
MySQLTLSConfigPreferred = "preferred"
MySQLRouterContainerName = "mysql-router"
MySQLRouterInitScriptDirectoryName = "init-scripts"
MySQLRouterInitScriptDirectoryPath = "/scripts"
MySQLRouterConfigDirectoryName = "router-config-secret"
MySQLRouterConfigDirectoryPath = "/etc/mysqlrouter"
MySQLRouterTLSDirectoryName = "router-tls-volume"
MySQLRouterTLSDirectoryPath = "/etc/mysql/certs"
MySQLReplicationUser = "repl"
MySQLComponentKey = MySQLKey + "/component"
MySQLComponentDB = "database"
MySQLComponentRouter = "router"
// =========================== PerconaXtraDB Constants ============================
PerconaXtraDBClusterRecommendedVersion = "5.7"
PerconaXtraDBMaxClusterNameLength = 32
PerconaXtraDBStandaloneReplicas = 1
PerconaXtraDBDefaultClusterSize = 3
PerconaXtraDBDataMountPath = "/var/lib/mysql"
PerconaXtraDBDataLostFoundPath = PerconaXtraDBDataMountPath + "lost+found"
PerconaXtraDBInitDBMountPath = "/docker-entrypoint-initdb.d"
PerconaXtraDBCustomConfigMountPath = "/etc/percona-server.conf.d/"
PerconaXtraDBClusterCustomConfigMountPath = "/etc/percona-xtradb-cluster.conf.d/"
// =========================== MariaDB Constants ============================
MariaDBMaxClusterNameLength = 32
MariaDBStandaloneReplicas = 1
MariaDBDefaultClusterSize = 3
MariaDBDataMountPath = "/var/lib/mysql"
MariaDBDataLostFoundPath = MariaDBDataMountPath + "lost+found"
MariaDBInitDBVolumeName = "initial-script"
MariaDBInitDBMountPath = "/docker-entrypoint-initdb.d"
MariaDBCustomConfigMountPath = "/etc/mysql/conf.d/"
MariaDBClusterCustomConfigMountPath = "/etc/mysql/custom.conf.d/"
MariaDBCustomConfigVolumeName = "custom-config"
MariaDBTLSConfigCustom = "custom"
MariaDBInitContainerName = "mariadb-init"
MariaDBCoordinatorContainerName = "md-coordinator"
MariaDBRunScriptVolumeName = "run-script"
MariaDBRunScriptVolumeMountPath = "/run-script"
MariaDBInitScriptVolumeName = "init-scripts"
MariaDBInitScriptVolumeMountPath = "/scripts"
MariaDBContainerName = ResourceSingularMariaDB
// =========================== PostgreSQL Constants ============================
PostgresDatabasePortName = "db"
PostgresPrimaryServicePortName = "primary"
PostgresStandbyServicePortName = "standby"
PostgresDatabasePort = 5432
PostgresPodPrimary = "primary"
PostgresPodStandby = "standby"
EnvPostgresUser = "POSTGRES_USER"
EnvPostgresPassword = "POSTGRES_PASSWORD"
PostgresCoordinatorContainerName = "pg-coordinator"
PostgresCoordinatorPort = 2380
PostgresCoordinatorPortName = "coordinator"
PostgresCoordinatorClientPort = 2379
PostgresCoordinatorClientPortName = "coordinatclient"
PostgresRunScriptMountPath = "/run_scripts"
PostgresRunScriptVolumeName = "scripts"
PostgresKeyFileSecretSuffix = "key"
PostgresPEMSecretSuffix = "pem"
PostgresDefaultUsername = "postgres"
PostgresPgCoordinatorStatus = "Coordinator/Status"
// to pause the failover for postgres. this is helpful for ops request
PostgresPgCoordinatorStatusPause = "Pause"
// to resume the failover for postgres. this is helpful for ops request
PostgresPgCoordinatorStatusResume = "Resume"
// when we need to resume pg-coordinator as non transferable we are going to set this state.
// this is useful when we have set a node as primary and you don't want other node rather then this node to become primary.
PostgresPgCoordinatorStatusResumeNonTransferable = "NonTransferableResume"
// =========================== ProxySQL Constants ============================
LabelProxySQLName = ProxySQLKey + "/name"
LabelProxySQLLoadBalance = ProxySQLKey + "/load-balance"
ProxySQLDatabasePort = 6033
ProxySQLDatabasePortName = "db"
ProxySQLPrimaryServicePortName = "db"
ProxySQLAdminPort = 6032
ProxySQLAdminPortName = "admin"
ProxySQLDataMountPath = "/var/lib/proxysql"
ProxySQLCustomConfigMountPath = "/etc/custom-config"
// =========================== Redis Constants ============================
RedisConfigKey = "redis.conf" // RedisConfigKey is going to create for the customize redis configuration
// DefaultConfigKey is going to create for the default redis configuration
DefaultConfigKey = "default.conf"
RedisShardKey = RedisKey + "/shard"
RedisDatabasePortName = "db"
RedisPrimaryServicePortName = "primary"
RedisDatabasePort = 6379
RedisGossipPortName = "gossip"
RedisGossipPort = 16379
RedisSentinelPortName = "sentinel"
RedisScriptVolumeName = "script-vol"
RedisScriptVolumePath = "/scripts"
RedisSentinelPort = 26379
RedisKeyFileSecretSuffix = "key"
RedisPEMSecretSuffix = "pem"
RedisRootUsername = "root"
EnvRedisUser = "USERNAME"
EnvRedisPassword = "REDISCLI_AUTH"
// =========================== PgBouncer Constants ============================
PgBouncerUpstreamServerCA = "upstream-server-ca.crt"
PgBouncerDatabasePortName = "db"
PgBouncerPrimaryServicePortName = "primary"
PgBouncerDatabasePort = 5432
PgBouncerConfigFile = "pgbouncer.ini"
PgBouncerAdminUsername = "kubedb"
)
// List of possible condition types for a KubeDB object
const (
// used for Databases that have started provisioning
DatabaseProvisioningStarted = "ProvisioningStarted"
// used for Databases which completed provisioning
DatabaseProvisioned = "Provisioned"
// used for Databases that are currently being initialized using stash
DatabaseDataRestoreStarted = "DataRestoreStarted"
// used for Databases that have been initialized using stash
DatabaseDataRestored = "DataRestored"
// used for Databases whose pods are ready
DatabaseReplicaReady = "ReplicaReady"
// used for Databases that are currently accepting connection
DatabaseAcceptingConnection = "AcceptingConnection"
// used for Databases that report status OK (also implies that we can connect to it)
DatabaseReady = "Ready"
// used for database that reports ok when all the instances are available
ServerReady = "ServerReady"
// used for Databases that are paused
DatabasePaused = "Paused"
// used for Databases that are halted
DatabaseHalted = "Halted"
// Condition reasons
DataRestoreStartedByExternalInitializer = "DataRestoreStartedByExternalInitializer"
DatabaseSuccessfullyRestored = "SuccessfullyDataRestored"
FailedToRestoreData = "FailedToRestoreData"
AllReplicasAreReady = "AllReplicasReady"
SomeReplicasAreNotReady = "SomeReplicasNotReady"
DatabaseAcceptingConnectionRequest = "DatabaseAcceptingConnectionRequest"
DatabaseNotAcceptingConnectionRequest = "DatabaseNotAcceptingConnectionRequest"
ReadinessCheckSucceeded = "ReadinessCheckSucceeded"
ReadinessCheckFailed = "ReadinessCheckFailed"
DatabaseProvisioningStartedSuccessfully = "DatabaseProvisioningStartedSuccessfully"
DatabaseSuccessfullyProvisioned = "DatabaseSuccessfullyProvisioned"
DatabaseHaltedSuccessfully = "DatabaseHaltedSuccessfully"
)
// Resource kind related constants
const (
ResourceKindStatefulSet = "StatefulSet"
)
var (
DefaultResources = core.ResourceRequirements{
Requests: core.ResourceList{
core.ResourceCPU: resource.MustParse(".500"),
core.ResourceMemory: resource.MustParse("1024Mi"),
},
Limits: core.ResourceList{
core.ResourceMemory: resource.MustParse("1024Mi"),
},
}
// CoordinatorDefaultResources must be used for raft backed coordinators to avoid unintended leader switches
CoordinatorDefaultResources = core.ResourceRequirements{
Requests: core.ResourceList{
core.ResourceCPU: resource.MustParse(".200"),
core.ResourceMemory: resource.MustParse("256Mi"),
},
Limits: core.ResourceList{
core.ResourceMemory: resource.MustParse("256Mi"),
},
}
)