Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EVEREST-496 Multi namespace support #169

Merged
merged 42 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
759eed9
EVEREST-496 Playing with reconcilers
gen1us2k Nov 16, 2023
88dd7e3
EVEREST-496 Playing with reconcilers
gen1us2k Nov 16, 2023
7e9e48c
EVEREST-496 still playing
gen1us2k Nov 17, 2023
55b714c
EVEREST-496 cool stuff
gen1us2k Nov 17, 2023
14f2728
EVEREST-496 added controllers
gen1us2k Nov 20, 2023
df8be18
EVEREST-496 Reconcile backup storages
gen1us2k Nov 20, 2023
008a5dc
EVEREST-496 handle deletion of secrets
gen1us2k Nov 21, 2023
7cb42e8
EVEREST-496 small refactoring
gen1us2k Nov 21, 2023
652ba32
EVEREST-496 check existence of the namespaces
gen1us2k Nov 21, 2023
52e7724
EVEREST-496 multins support for engines
gen1us2k Nov 21, 2023
6c22ac2
EVEREST-496 Working PoC for the secrets management
gen1us2k Nov 21, 2023
dd69de2
EVEREST-496 Fixed cleanup logic
gen1us2k Nov 22, 2023
4778a0e
EVEREST-496 cleanup
gen1us2k Nov 22, 2023
5e3f826
EVEREST-496 Small fixes
gen1us2k Nov 22, 2023
8800abd
EVEREST-496 linter fixes
gen1us2k Nov 22, 2023
286f2df
Merge
gen1us2k Nov 22, 2023
287d472
Merge
gen1us2k Nov 22, 2023
4d36502
Merge
gen1us2k Nov 22, 2023
266a998
Missed controller
gen1us2k Nov 22, 2023
d6bcee9
EVEREST-496 Fixed build
gen1us2k Nov 23, 2023
b8d4f4e
EVEREST-496 Fixed build
gen1us2k Nov 23, 2023
e60d5b0
Update controllers/databasecluster_controller.go
gen1us2k Nov 23, 2023
1b96a72
Update controllers/databasecluster_controller.go
gen1us2k Nov 23, 2023
3f438e8
Update controllers/databasecluster_controller.go
gen1us2k Nov 23, 2023
0d7c3e1
Update controllers/databasecluster_controller.go
gen1us2k Nov 23, 2023
23e5614
EVEREST-496 shut up linter
gen1us2k Nov 23, 2023
4a72d33
EVEREST-496 tests
gen1us2k Nov 23, 2023
0a4bf34
EVEREST-496 tests
gen1us2k Nov 23, 2023
a730a5b
EVEREST-496 Fixed build
gen1us2k Nov 23, 2023
240fb5a
EVEREST-496 psmdb tests
gen1us2k Nov 23, 2023
31b8745
EVEREST-496 psmdb tests
gen1us2k Nov 23, 2023
56c2fbf
EVEREST-496 restore pipeline
gen1us2k Nov 23, 2023
939796c
EVEREST-496 release
gen1us2k Nov 23, 2023
c1540d9
Revert "EVEREST-496 restore pipeline"
gen1us2k Nov 23, 2023
17b625b
u
gen1us2k Nov 23, 2023
acfd53e
EVEREST-496 cleanup backupstorages
gen1us2k Nov 23, 2023
af30eef
EVEREST-496 u
gen1us2k Nov 23, 2023
2a6aba0
u
gen1us2k Nov 23, 2023
2b7528b
Revert "EVEREST-496 cleanup backupstorages"
gen1us2k Nov 23, 2023
2fbe058
u
gen1us2k Nov 23, 2023
3535b3e
Revert "Revert "EVEREST-496 restore pipeline""
gen1us2k Nov 23, 2023
c0418a8
u
gen1us2k Nov 23, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ resources:
- api:
crdVersion: v1
namespaced: true
controller: true
domain: percona.com
group: everest
kind: BackupStorage
Expand All @@ -58,6 +59,7 @@ resources:
- api:
crdVersion: v1
namespaced: true
controller: true
domain: percona.com
group: everest
kind: MonitoringConfig
Expand Down
44 changes: 43 additions & 1 deletion api/v1alpha1/backupstorage_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,14 @@ type BackupStorageSpec struct {
Description string `json:"description,omitempty"`
// CredentialsSecretName is the name of the secret with credentials.
CredentialsSecretName string `json:"credentialsSecretName"`
// TargetNamespaces is the list of namespaces where the operator will copy secrets provided in the CredentialsSecretsName.
TargetNamespaces []string `json:"targetNamespaces,omitempty"`
recharte marked this conversation as resolved.
Show resolved Hide resolved
}

// BackupStorageStatus defines the observed state of BackupStorage.
type BackupStorageStatus struct{}
type BackupStorageStatus struct {
UsedNamespaces map[string]bool `json:"usedNamespaces"`
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
Expand All @@ -74,3 +78,41 @@ type BackupStorageList struct {
func init() {
SchemeBuilder.Register(&BackupStorage{}, &BackupStorageList{})
}

// UpdateNamespacesList updates the list of namespaces that use the backupStorage.
func (b *BackupStorage) UpdateNamespacesList(namespace string) bool {
if b.Status.UsedNamespaces == nil {
b.Status.UsedNamespaces = make(map[string]bool)
}
if _, ok := b.Status.UsedNamespaces[namespace]; ok {
return false
}
b.Status.UsedNamespaces[namespace] = true
return true
}

// DeleteUsedNamespace deletes the namespace from the usedNamespaces list.
func (b *BackupStorage) DeleteUsedNamespace(namespace string) bool {
if b.Status.UsedNamespaces == nil {
return false
}
if _, ok := b.Status.UsedNamespaces[namespace]; ok {
delete(b.Status.UsedNamespaces, namespace)
return true
}
return false
}

// IsNamespaceAllowed checks the namespace against targetNamespaces and returns if it's allowed to use.
func (b *BackupStorage) IsNamespaceAllowed(namespace string) bool {
oksana-grishchenko marked this conversation as resolved.
Show resolved Hide resolved
if len(b.Spec.TargetNamespaces) == 0 {
return true
}
for _, ns := range b.Spec.TargetNamespaces {
ns := ns
if ns == namespace {
return true
}
}
return false
}
44 changes: 43 additions & 1 deletion api/v1alpha1/monitoringconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ type MonitoringConfigSpec struct {
Type MonitoringType `json:"type"`
// CredentialsSecretName is the name of the secret with credentials.
CredentialsSecretName string `json:"credentialsSecretName"`
// TargetNamespaces is the list of namespaces where the operator will copy secrets provided in the CredentialsSecretsName.
TargetNamespaces []string `json:"targetNamespaces,omitempty"`
// PMM is configuration for the PMM monitoring type.
PMM PMMConfig `json:"pmm,omitempty"`
}
Expand All @@ -47,7 +49,9 @@ type PMMConfig struct {
}

// MonitoringConfigStatus defines the observed state of MonitoringConfig.
type MonitoringConfigStatus struct{}
type MonitoringConfigStatus struct {
UsedNamespaces map[string]bool `json:"usedNamespaces"`
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
Expand All @@ -74,3 +78,41 @@ type MonitoringConfigList struct {
func init() {
SchemeBuilder.Register(&MonitoringConfig{}, &MonitoringConfigList{})
}

// UpdateNamespacesList updates the list of namespaces that use the monitoring config.
func (m *MonitoringConfig) UpdateNamespacesList(namespace string) bool {
if m.Status.UsedNamespaces == nil {
m.Status.UsedNamespaces = make(map[string]bool)
}
if _, ok := m.Status.UsedNamespaces[namespace]; ok {
return false
}
m.Status.UsedNamespaces[namespace] = true
return true
}

// DeleteUsedNamespace deletes the namespace from the usedNamespaces list.
func (m *MonitoringConfig) DeleteUsedNamespace(namespace string) bool {
if m.Status.UsedNamespaces == nil {
return false
}
if _, ok := m.Status.UsedNamespaces[namespace]; ok {
delete(m.Status.UsedNamespaces, namespace)
return true
}
return false
}

// IsNamespaceAllowed checks the namespace against targetNamespaces and returns if it's allowed to use.
func (m *MonitoringConfig) IsNamespaceAllowed(namespace string) bool {
if len(m.Spec.TargetNamespaces) == 0 {
return true
}
for _, ns := range m.Spec.TargetNamespaces {
ns := ns
if ns == namespace {
return true
}
}
return false
}
32 changes: 28 additions & 4 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 33 additions & 5 deletions bundle/manifests/everest-operator.clusterserviceversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ metadata:
}
]
capabilities: Basic Install
createdAt: "2023-11-22T14:28:14Z"
createdAt: "2023-11-23T07:10:37Z"
operators.operatorframework.io/builder: operator-sdk-v1.32.0
operators.operatorframework.io/project_layout: go.kubebuilder.io/v3
name: everest-operator.v0.5.0-dev2
Expand Down Expand Up @@ -193,6 +193,20 @@ spec:
- patch
- update
- watch
- apiGroups:
- everest.percona.com
resources:
- backupstorages/finalizers
verbs:
- update
- apiGroups:
- everest.percona.com
resources:
- backupstorages/status
verbs:
- get
- patch
- update
- apiGroups:
- everest.percona.com
resources:
Expand Down Expand Up @@ -309,6 +323,20 @@ spec:
- patch
- update
- watch
- apiGroups:
- everest.percona.com
resources:
- monitoringconfigs/finalizers
verbs:
- update
- apiGroups:
- everest.percona.com
resources:
- monitoringconfigs/status
verbs:
- get
- patch
- update
- apiGroups:
- pgv2.percona.com
resources:
Expand Down Expand Up @@ -512,10 +540,10 @@ spec:
command:
- /manager
env:
- name: WATCH_NAMESPACE
- name: DEFAULT_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.annotations['olm.targetNamespaces']
fieldPath: metadata.namespace
image: docker.io/perconalab/everest-operator:0.5.0-dev2
livenessProbe:
httpGet:
Expand Down Expand Up @@ -586,9 +614,9 @@ spec:
type: OwnNamespace
- supported: true
type: SingleNamespace
- supported: false
type: MultiNamespace
- supported: true
type: MultiNamespace
- supported: false
type: AllNamespaces
keywords:
- everest
Expand Down
13 changes: 13 additions & 0 deletions bundle/manifests/everest.percona.com_backupstorages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ spec:
region:
description: Region is a region where the bucket is located.
type: string
targetNamespaces:
description: TargetNamespaces is the list of namespaces where the
operator will copy secrets provided in the CredentialsSecretsName.
items:
type: string
type: array
type:
description: Type is a type of backup storage.
enum:
Expand All @@ -63,6 +69,13 @@ spec:
type: object
status:
description: BackupStorageStatus defines the observed state of BackupStorage.
properties:
usedNamespaces:
additionalProperties:
type: boolean
type: object
required:
- usedNamespaces
type: object
type: object
served: true
Expand Down
13 changes: 13 additions & 0 deletions bundle/manifests/everest.percona.com_monitoringconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ spec:
- image
- url
type: object
targetNamespaces:
description: TargetNamespaces is the list of namespaces where the
operator will copy secrets provided in the CredentialsSecretsName.
items:
type: string
type: array
type:
description: Type is type of monitoring.
enum:
Expand All @@ -68,6 +74,13 @@ spec:
type: object
status:
description: MonitoringConfigStatus defines the observed state of MonitoringConfig.
properties:
usedNamespaces:
additionalProperties:
type: boolean
type: object
required:
- usedNamespaces
type: object
type: object
served: true
Expand Down
13 changes: 13 additions & 0 deletions config/crd/bases/everest.percona.com_backupstorages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ spec:
region:
description: Region is a region where the bucket is located.
type: string
targetNamespaces:
description: TargetNamespaces is the list of namespaces where the
operator will copy secrets provided in the CredentialsSecretsName.
items:
type: string
type: array
type:
description: Type is a type of backup storage.
enum:
Expand All @@ -64,6 +70,13 @@ spec:
type: object
status:
description: BackupStorageStatus defines the observed state of BackupStorage.
properties:
usedNamespaces:
additionalProperties:
type: boolean
type: object
required:
- usedNamespaces
type: object
type: object
served: true
Expand Down
13 changes: 13 additions & 0 deletions config/crd/bases/everest.percona.com_monitoringconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ spec:
- image
- url
type: object
targetNamespaces:
description: TargetNamespaces is the list of namespaces where the
operator will copy secrets provided in the CredentialsSecretsName.
items:
type: string
type: array
type:
description: Type is type of monitoring.
enum:
Expand All @@ -69,6 +75,13 @@ spec:
type: object
status:
description: MonitoringConfigStatus defines the observed state of MonitoringConfig.
properties:
usedNamespaces:
additionalProperties:
type: boolean
type: object
required:
- usedNamespaces
type: object
type: object
served: true
Expand Down
Loading
Loading