-
Notifications
You must be signed in to change notification settings - Fork 147
/
const.go
342 lines (293 loc) · 18.1 KB
/
const.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
/*
Copyright (C) 2022-2023 ApeCloud Co., Ltd
This file is part of KubeBlocks project
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package constant
const (
// config keys used in viper, DON'T refactor the value without careful inspections
CfgKeyServerInfo = "_KUBE_SERVER_INFO"
CfgKeyCtrlrMgrNS = "CM_NAMESPACE"
CfgKeyCtrlrMgrAffinity = "CM_AFFINITY"
CfgKeyCtrlrMgrNodeSelector = "CM_NODE_SELECTOR"
CfgKeyCtrlrMgrTolerations = "CM_TOLERATIONS"
CfgKeyCtrlrReconcileRetryDurationMS = "CM_RECON_RETRY_DURATION_MS" // accept time
CfgRecoverVolumeExpansionFailure = "RECOVER_VOLUME_EXPANSION_FAILURE" // refer to feature gates RecoverVolumeExpansionFailure of k8s.
CfgKeyProvider = "KUBE_PROVIDER"
CfgHostPortConfigMapName = "HOST_PORT_CM_NAME"
CfgHostPortIncludeRanges = "HOST_PORT_INCLUDE_RANGES"
CfgHostPortExcludeRanges = "HOST_PORT_EXCLUDE_RANGES"
// addon config keys
CfgKeyAddonJobTTL = "ADDON_JOB_TTL"
CfgAddonJobImgPullPolicy = "ADDON_JOB_IMAGE_PULL_POLICY"
// data plane config key
CfgKeyDataPlaneTolerations = "DATA_PLANE_TOLERATIONS"
CfgKeyDataPlaneAffinity = "DATA_PLANE_AFFINITY"
// storage config keys
CfgKeyDefaultStorageClass = "DEFAULT_STORAGE_CLASS"
// customized encryption key for encrypting the password of connection credential.
CfgKeyDPEncryptionKey = "DP_ENCRYPTION_KEY"
CfgKBReconcileWorkers = "KUBEBLOCKS_RECONCILE_WORKERS"
CfgClientQPS = "CLIENT_QPS"
CfgClientBurst = "CLIENT_BURST"
)
const (
// TODO: deprecated, will be removed later.
KBConnCredentialPlaceHolder = "$(CONN_CREDENTIAL_SECRET_NAME)"
KBComponentEnvCMPlaceHolder = "$(COMP_ENV_CM_NAME)"
KBToolsImagePlaceHolder = "$(KUBEBLOCKS_TOOLS_IMAGE)"
)
const (
KBPrefix = "KB"
KBLowerPrefix = "kb"
)
const (
KBServiceAccountName = "KUBEBLOCKS_SERVICEACCOUNT_NAME"
KBToolsImage = "KUBEBLOCKS_TOOLS_IMAGE"
KBImagePullPolicy = "KUBEBLOCKS_IMAGE_PULL_POLICY"
KBDataScriptClientsImage = "KUBEBLOCKS_DATASCRIPT_CLIENTS_IMAGE"
)
const (
APIGroup = "kubeblocks.io"
AppName = "kubeblocks"
// K8S recommended well-known labels and annotation keys
// AppInstanceLabelKey refer cluster.Name
AppInstanceLabelKey = "app.kubernetes.io/instance"
// AppNameLabelKey refer clusterDefinition.Name before KubeBlocks Version 0.8.0 or refer ComponentDefinition.Name after KubeBlocks Version 0.8.0 (TODO:Pending)
AppNameLabelKey = "app.kubernetes.io/name"
// AppComponentLabelKey refer clusterDefinition.Spec.ComponentDefs[*].Name before KubeBlocks Version 0.8.0 or refer ComponentDefinition.Name after KubeBlocks Version 0.8.0
AppComponentLabelKey = "app.kubernetes.io/component"
// AppVersionLabelKey refer clusterVersion.Name before KubeBlocks Version 0.8.0 or refer ComponentDefinition.Name after KubeBlocks Version 0.8.0
AppVersionLabelKey = "app.kubernetes.io/version"
AppManagedByLabelKey = "app.kubernetes.io/managed-by"
RegionLabelKey = "topology.kubernetes.io/region"
ZoneLabelKey = "topology.kubernetes.io/zone"
// kubeblocks.io labels
BackupProtectionLabelKey = "kubeblocks.io/backup-protection" // BackupProtectionLabelKey Backup delete protection policy label
AddonProviderLabelKey = "kubeblocks.io/provider" // AddonProviderLabelKey marks the addon provider
RoleLabelKey = "kubeblocks.io/role" // RoleLabelKey consensusSet and replicationSet role label key
ReadyWithoutPrimaryKey = "kubeblocks.io/ready-without-primary"
VolumeTypeLabelKey = "kubeblocks.io/volume-type"
ClusterAccountLabelKey = "account.kubeblocks.io/name"
KBAppClusterUIDLabelKey = "apps.kubeblocks.io/cluster-uid"
KBAppComponentLabelKey = "apps.kubeblocks.io/component-name"
KBAppShardingNameLabelKey = "apps.kubeblocks.io/sharding-name"
KBAppComponentDefRefLabelKey = "apps.kubeblocks.io/component-def-ref" // refer clusterDefinition.Spec.ComponentDefs[*].Name before KubeBlocks Version 0.8.0 or refer ComponentDefinition.Name after KubeBlocks Version 0.8.0
KBAppClusterDefTypeLabelKey = "apps.kubeblocks.io/cluster-type" // refer clusterDefinition.Spec.Type (deprecated)
AppConfigTypeLabelKey = "apps.kubeblocks.io/config-type"
KBManagedByKey = "apps.kubeblocks.io/managed-by" // KBManagedByKey marks resources that auto created
PVCNameLabelKey = "apps.kubeblocks.io/pvc-name"
VolumeClaimTemplateNameLabelKey = "apps.kubeblocks.io/vct-name"
VolumeClaimTemplateNameLabelKeyForLegacy = "vct.kubeblocks.io/name" // Deprecated: only compatible with version 0.5, will be removed in 0.7
WorkloadTypeLabelKey = "apps.kubeblocks.io/workload-type"
ClassProviderLabelKey = "class.kubeblocks.io/provider"
ClusterDefLabelKey = "clusterdefinition.kubeblocks.io/name"
ClusterVerLabelKey = "clusterversion.kubeblocks.io/name"
ComponentDefinitionLabelKey = "componentdefinition.kubeblocks.io/name"
CMConfigurationSpecProviderLabelKey = "config.kubeblocks.io/config-spec" // CMConfigurationSpecProviderLabelKey is ComponentConfigSpec name
CMConfigurationCMKeysLabelKey = "config.kubeblocks.io/configmap-keys" // CMConfigurationCMKeysLabelKey Specify configmap keys
CMConfigurationTemplateNameLabelKey = "config.kubeblocks.io/config-template-name"
CMTemplateNameLabelKey = "config.kubeblocks.io/template-name"
CMConfigurationTypeLabelKey = "config.kubeblocks.io/config-type"
CMInsConfigurationHashLabelKey = "config.kubeblocks.io/config-hash"
CMInsCurrentConfigurationHashLabelKey = "config.kubeblocks.io/update-config-hash"
CMConfigurationConstraintsNameLabelKey = "config.kubeblocks.io/config-constraints-name"
CMConfigurationTemplateVersion = "config.kubeblocks.io/config-template-version"
ConsensusSetAccessModeLabelKey = "cs.apps.kubeblocks.io/access-mode"
AddonNameLabelKey = "extensions.kubeblocks.io/addon-name"
OpsRequestTypeLabelKey = "ops.kubeblocks.io/ops-type"
OpsRequestNameLabelKey = "ops.kubeblocks.io/ops-name"
OpsRequestNamespaceLabelKey = "ops.kubeblocks.io/ops-namespace"
ServiceDescriptorNameLabelKey = "servicedescriptor.kubeblocks.io/name"
RestoreForHScaleLabelKey = "apps.kubeblocks.io/restore-for-hscale"
ResourceConstraintProviderLabelKey = "resourceconstraint.kubeblocks.io/provider"
// StatefulSetPodNameLabelKey is used to mark the pod name of the StatefulSet
StatefulSetPodNameLabelKey = "statefulset.kubernetes.io/pod-name"
// kubeblocks.io annotations
ClusterSnapshotAnnotationKey = "kubeblocks.io/cluster-snapshot" // ClusterSnapshotAnnotationKey saves the snapshot of cluster.
DefaultClusterVersionAnnotationKey = "kubeblocks.io/is-default-cluster-version" // DefaultClusterVersionAnnotationKey specifies the default cluster version.
OpsRequestAnnotationKey = "kubeblocks.io/ops-request" // OpsRequestAnnotationKey OpsRequest annotation key in Cluster
ReconcileAnnotationKey = "kubeblocks.io/reconcile" // ReconcileAnnotationKey Notify k8s object to reconcile
RestartAnnotationKey = "kubeblocks.io/restart" // RestartAnnotationKey the annotation which notices the StatefulSet/DeploySet to restart
RestoreFromBackupAnnotationKey = "kubeblocks.io/restore-from-backup" // RestoreFromBackupAnnotationKey specifies the component to recover from the backup.
SnapShotForStartAnnotationKey = "kubeblocks.io/snapshot-for-start"
ComponentReplicasAnnotationKey = "apps.kubeblocks.io/component-replicas" // ComponentReplicasAnnotationKey specifies the number of pods in replicas
BackupPolicyTemplateAnnotationKey = "apps.kubeblocks.io/backup-policy-template"
LastAppliedClusterAnnotationKey = "apps.kubeblocks.io/last-applied-cluster"
PVLastClaimPolicyAnnotationKey = "apps.kubeblocks.io/pv-last-claim-policy"
HaltRecoveryAllowInconsistentCVAnnotKey = "clusters.apps.kubeblocks.io/allow-inconsistent-cv"
HaltRecoveryAllowInconsistentResAnnotKey = "clusters.apps.kubeblocks.io/allow-inconsistent-resource"
PrimaryAnnotationKey = "rs.apps.kubeblocks.io/primary"
DisableUpgradeInsConfigurationAnnotationKey = "config.kubeblocks.io/disable-reconfigure"
LastAppliedConfigAnnotationKey = "config.kubeblocks.io/last-applied-configuration"
LastAppliedOpsCRAnnotationKey = "config.kubeblocks.io/last-applied-ops-name"
UpgradePolicyAnnotationKey = "config.kubeblocks.io/reconfigure-policy"
KBParameterUpdateSourceAnnotationKey = "config.kubeblocks.io/reconfigure-source"
UpgradeRestartAnnotationKey = "config.kubeblocks.io/restart"
ConfigAppliedVersionAnnotationKey = "config.kubeblocks.io/config-applied-version"
KubeBlocksGenerationKey = "kubeblocks.io/generation"
ExtraEnvAnnotationKey = "kubeblocks.io/extra-env"
LastRoleSnapshotVersionAnnotationKey = "apps.kubeblocks.io/last-role-snapshot-version"
HostPortAnnotationKey = "kubeblocks.io/host-port"
HostPortIncludeAnnotationKey = "network.kubeblocks.io/host-ports-include"
HostPortExcludeAnnotationKey = "network.kubeblocks.io/host-ports-exclude"
DisableHAAnnotationKey = "kubeblocks.io/disable-ha"
// EnabledNodePortSvcAnnotationKey defines the feature gate of NodePort Service defined in ComponentDefinition.Spec.Services.
// Components defined in the annotation value, their all services of type NodePort defined in ComponentDefinition will be created; otherwise, they will be ignored.
// Multiple components are separated by ','. for example: "kubeblocks.io/enabled-node-port-svc: comp1,comp2"
EnabledNodePortSvcAnnotationKey = "kubeblocks.io/enabled-node-port-svc"
// EnabledPodOrdinalSvcAnnotationKey defines the feature gate of PodOrdinal Service defined in ComponentDefinition.Spec.Services.
// Components defined in the annotation value, their all Services defined in the ComponentDefinition with the GeneratePodOrdinalService attribute set to true will be created; otherwise, they will be ignored.
// This can generate a corresponding Service for each Pod, which can be used in certain specific scenarios: for example, creating a dedicated access service for each read-only Pod.
// Multiple components are separated by ','. for example: "kubeblocks.io/enabled-pod-ordinal-svc: comp1,comp2"
EnabledPodOrdinalSvcAnnotationKey = "kubeblocks.io/enabled-pod-ordinal-svc"
// DisabledClusterIPSvcAnnotationKey defines whether the feature gate of ClusterIp Service defined in ComponentDefinition.Spec.Services will be effected.
// Components defined in the annotation value, their all services of type ClusterIp defined in ComponentDefinition will be ignored; otherwise, they will be created.
// Multiple components are separated by ','. for example: "kubeblocks.io/disabled-cluster-ip-svc: comp1,comp2"
DisabledClusterIPSvcAnnotationKey = "kubeblocks.io/disabled-cluster-ip-svc"
// ShardSvcAnnotationKey defines the feature gate of creating service for each shard.
// Sharding name defined in the annotation value, a set of Service defined in Cluster.Spec.Services with the ShardingSelector will be automatically generated for each shard when Cluster.Spec.ShardingSpecs[x].shards is not nil.
// Multiple sharding names are separated by ','. for example: "kubeblocks.io/enabled-shard-svc: proxy-shard,db-shard"
ShardSvcAnnotationKey = "kubeblocks.io/enabled-shard-svc"
// kubeblocks.io well-known finalizers
DBClusterFinalizerName = "cluster.kubeblocks.io/finalizer"
DBComponentFinalizerName = "component.kubeblocks.io/finalizer"
DBComponentDefinitionFinalizerName = "componentdefinition.kubeblocks.io/finalizer"
ConfigurationTemplateFinalizerName = "config.kubeblocks.io/finalizer"
ServiceDescriptorFinalizerName = "servicedescriptor.kubeblocks.io/finalizer"
OpsRequestFinalizerName = "opsrequest.kubeblocks.io/finalizer"
// ConfigurationTplLabelPrefixKey clusterVersion or clusterdefinition using tpl
ConfigurationTplLabelPrefixKey = "config.kubeblocks.io/tpl"
ConfigurationConstraintsLabelPrefixKey = "config.kubeblocks.io/constraints"
// CMInsLastReconfigurePhaseKey defines the current phase
CMInsLastReconfigurePhaseKey = "config.kubeblocks.io/last-applied-reconfigure-phase"
// ConfigurationRevision defines the current revision
// TODO support multi version
ConfigurationRevision = "config.kubeblocks.io/configuration-revision"
LastConfigurationRevisionPhase = "config.kubeblocks.io/revision-reconcile-phase"
// Deprecated: only compatible with version 0.6, will be removed in 0.8
// CMInsEnableRerenderTemplateKey is used to enable rerender template
CMInsEnableRerenderTemplateKey = "config.kubeblocks.io/enable-rerender"
// IgnoreResourceConstraint is used to specify whether to ignore the resource constraint
IgnoreResourceConstraint = "resource.kubeblocks.io/ignore-constraint"
RBACRoleName = "kubeblocks-cluster-pod-role"
RBACClusterRoleName = "kubeblocks-volume-protection-pod-role"
// FeatureReconciliationInCompactModeAnnotationKey indicates that the controller should run in compact mode,
// means to try the best to cutoff useless objects.
FeatureReconciliationInCompactModeAnnotationKey = "kubeblocks.io/compact-mode"
)
const (
// ReasonNotFoundCR referenced custom resource not found
ReasonNotFoundCR = "NotFound"
// ReasonRefCRUnavailable referenced custom resource is unavailable
ReasonRefCRUnavailable = "Unavailable"
// ReasonDeletedCR deleted custom resource
ReasonDeletedCR = "DeletedCR"
// ReasonDeletingCR deleting custom resource
ReasonDeletingCR = "DeletingCR"
// ReasonCreatedCR created custom resource
ReasonCreatedCR = "CreatedCR"
// ReasonRunTaskFailed run task failed
ReasonRunTaskFailed = "RunTaskFailed"
// ReasonDeleteFailed delete failed
ReasonDeleteFailed = "DeleteFailed"
)
const (
DeploymentKind = "Deployment"
StatefulSetKind = "StatefulSet"
RSMKind = "ReplicatedStateMachine"
PodKind = "Pod"
PersistentVolumeClaimKind = "PersistentVolumeClaim"
CronJobKind = "CronJob"
JobKind = "Job"
ReplicaSetKind = "ReplicaSet"
VolumeSnapshotKind = "VolumeSnapshot"
ServiceKind = "Service"
ConfigMapKind = "ConfigMap"
DaemonSetKind = "DaemonSet"
)
const (
// BackupRetain always retained, unless manually deleted by the user
BackupRetain = "Retain"
// BackupRetainUntilExpired retains backup till it expires
BackupRetainUntilExpired = "RetainUntilExpired"
// BackupDelete (default) deletes backup immediately when cluster's terminationPolicy is WipeOut
BackupDelete = "Delete"
)
const (
// Container port name
LorryHTTPPortName = "lorry-http-port"
LorryGRPCPortName = "lorry-grpc-port"
LorryContainerName = "lorry"
LorryInitContainerName = "init-lorry"
ProbeInitContainerName = "kb-initprobe"
RoleProbeContainerName = "kb-checkrole"
StatusProbeContainerName = "kb-checkstatus"
RunningProbeContainerName = "kb-checkrunning"
VolumeProtectionProbeContainerName = "kb-volume-protection"
LorryRoleProbePath = "/v1.0/checkrole"
LorryVolumeProtectPath = "/v1.0/volumeprotection"
// the filedpath name used in event.InvolvedObject.FieldPath
ProbeCheckStatusPath = "spec.containers{" + StatusProbeContainerName + "}"
ProbeCheckRunningPath = "spec.containers{" + RunningProbeContainerName + "}"
)
const (
ConfigSidecarName = "config-manager"
ConfigManagerGPRCPortEnv = "CONFIG_MANAGER_GRPC_PORT"
ConfigManagerLogLevel = "CONFIG_MANAGER_LOG_LEVEL"
PodMinReadySecondsEnv = "POD_MIN_READY_SECONDS"
ConfigTemplateType = "tpl"
ConfigInstanceType = "instance"
ReconfigureManagerSource = "manager"
ReconfigureUserSource = "ops"
ReconfigureTemplateSource = "external-template"
ConfigManagerPortName = "config-manager"
)
const (
Primary = "primary"
Secondary = "secondary"
Leader = "leader"
Follower = "follower"
Learner = "learner"
)
// username and password are keys in created secrets for others to refer to.
const (
AccountNameForSecret = "username"
AccountPasswdForSecret = "password"
)
const (
FeatureGateReplicatedStateMachine = "REPLICATED_STATE_MACHINE" // enable rsm
)
const (
KubernetesClusterDomainEnv = "KUBERNETES_CLUSTER_DOMAIN"
DefaultDNSDomain = "cluster.local"
)
const (
ServiceDescriptorUsernameKey = "username"
ServiceDescriptorPasswordKey = "password"
ServiceDescriptorEndpointKey = "endpoint"
ServiceDescriptorPortKey = "port"
)
const (
BackupNameKeyForRestore = "name"
BackupNamespaceKeyForRestore = "namespace"
VolumeRestorePolicyKeyForRestore = "volumeRestorePolicy"
DoReadyRestoreAfterClusterRunning = "doReadyRestoreAfterClusterRunning"
RestoreTimeKeyForRestore = "restoreTime"
ConnectionPassword = "connectionPassword"
)
const (
KBAppMultiClusterPlacementKey = "apps.kubeblocks.io/multi-cluster-placement"
)
const (
KBGeneratedVirtualCompDefPrefix = "KB_GENERATED_VIRTUAL_COMP_DEF"
)