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

Implement RemoteNodeSet controllers #179

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
c19e804
impl remoteNodeSet api objects
kobzonega Jan 23, 2024
18e5378
remoteSpec to define region and zone
kobzonega Jan 23, 2024
7e8b3b2
processing remoteNodeSet objects in storage/database controllers
kobzonega Jan 23, 2024
3c27d7a
append remoteNodeSet builders in storage/database resources
kobzonega Jan 24, 2024
a29603f
fix resourceBuilders for remote resources
kobzonega Jan 26, 2024
030edf2
fix nested if
kobzonega Feb 6, 2024
f402f0e
update rbac for remoteNodeSet objects
kobzonega Feb 6, 2024
c907552
fixes tests
kobzonega Feb 6, 2024
c70ba20
use only cluster field for remote
kobzonega Feb 8, 2024
41f7938
impl remote controllers
kobzonega Feb 8, 2024
534ba72
Merge branch 'master' into YDBOPS-9039
kobzonega Feb 8, 2024
97f2096
add remoteFinalizer to wait resource deletion
kobzonega Feb 9, 2024
2f49d90
fixes tests
kobzonega Feb 6, 2024
98b294f
fix go.mod
kobzonega Feb 8, 2024
1d85876
fix e2e tests check running and ready pods (#177)
kobzonega Feb 6, 2024
0a82ea2
remove useless constants
kobzonega Feb 9, 2024
d4fd3f2
use apiutil to recognize resource Kind
kobzonega Feb 12, 2024
ed19e24
update crds and generated deepcopy
kobzonega Feb 12, 2024
b770066
fixes tests
kobzonega Feb 6, 2024
fcfe3af
get resource kind by gvk apiutil
kobzonega Feb 12, 2024
10ed733
ut tests for deletion
kobzonega Feb 12, 2024
a9c9fbc
fix golangci lint errors
kobzonega Feb 12, 2024
3855260
fix ut tests
kobzonega Feb 12, 2024
e5b3c3f
update unit-tests
kobzonega Feb 13, 2024
fb28a33
using cluster cache instead of manager
kobzonega Feb 13, 2024
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
11 changes: 9 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and Cust
cp config/crd/bases/ydb.tech_databases.yaml deploy/ydb-operator/crds/database.yaml
cp config/crd/bases/ydb.tech_storagenodesets.yaml deploy/ydb-operator/crds/storagenodeset.yaml
cp config/crd/bases/ydb.tech_databasenodesets.yaml deploy/ydb-operator/crds/databasenodeset.yaml
cp config/crd/bases/ydb.tech_remotestoragenodesets.yaml deploy/ydb-operator/crds/remotestoragenodeset.yaml
cp config/crd/bases/ydb.tech_remotedatabasenodesets.yaml deploy/ydb-operator/crds/remotedatabasenodeset.yaml
cp config/crd/bases/ydb.tech_databasemonitorings.yaml deploy/ydb-operator/crds/databasemonitoring.yaml
cp config/crd/bases/ydb.tech_storagemonitorings.yaml deploy/ydb-operator/crds/storagemonitoring.yaml

Expand All @@ -75,9 +77,14 @@ kind-load:
docker tag cr.yandex/yc/ydb-operator:latest kind/ydb-operator:current
kind load docker-image kind/ydb-operator:current --name kind-ydb-operator

unit-test: manifests generate fmt vet envtest ## Run unit tests
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test -v -timeout 1800s -p 1 ./internal/controllers/... -ginkgo.vv -coverprofile cover.out

e2e-test: docker-build kind-init kind-load ## Run e2e tests
go test -v -timeout 1800s -p 1 ./e2e/... -args -ginkgo.vv

.PHONY: test
test: manifests generate fmt vet docker-build kind-init kind-load envtest ## Run tests.
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test -timeout 1800s -p 1 ./... -ginkgo.v -coverprofile cover.out
test: unit-test test ## Run all tests

.PHONY: clean
clean:
Expand Down
6 changes: 6 additions & 0 deletions api/v1alpha1/common_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,9 @@ type PodImage struct {
// +optional
PullSecret *string `json:"pullSecret,omitempty"`
}

type RemoteSpec struct {
// Remote cluster to deploy NodeSet into
// +required
Cluster string `json:"cluster"`
}
7 changes: 3 additions & 4 deletions api/v1alpha1/databasenodeset_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ type DatabaseNodeSetSpec struct {

// DatabaseNodeSetStatus defines the observed state
type DatabaseNodeSetStatus struct {
State constants.ClusterState `json:"state"`
Conditions []metav1.Condition `json:"conditions,omitempty"`
ObservedDatabaseGeneration int64 `json:"observedDatabaseGeneration,omitempty"`
State constants.ClusterState `json:"state"`
Conditions []metav1.Condition `json:"conditions,omitempty"`
}

// DatabaseNodeSetSpecInline describes an group nodes object inside parent object
Expand All @@ -32,7 +31,7 @@ type DatabaseNodeSetSpecInline struct {

// (Optional) Object should be reference to remote object
// +optional
Remote bool `json:"remote,omitempty"`
Remote *RemoteSpec `json:"remote,omitempty"`

DatabaseNodeSpec `json:",inline"`
}
Expand Down
35 changes: 35 additions & 0 deletions api/v1alpha1/remotedatabasenodeset_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
//+kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.state",description="The status of this RemoteDatabaseNodeSet"
//+kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"

// RemoteDatabaseNodeSet declares NodeSet spec and status for objects in remote cluster
type RemoteDatabaseNodeSet struct {
metav1.TypeMeta `json:",inline"`
// +optional
metav1.ObjectMeta `json:"metadata,omitempty"`
// +optional
Spec DatabaseNodeSetSpec `json:"spec,omitempty"`
// +optional
// +kubebuilder:default:={state: "Pending"}
Status DatabaseNodeSetStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

// RemoteDatabaseNodeSetList contains a list of RemoteDatabaseNodeSet
type RemoteDatabaseNodeSetList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []RemoteDatabaseNodeSet `json:"items"`
}

func init() {
SchemeBuilder.Register(&RemoteDatabaseNodeSet{}, &RemoteDatabaseNodeSetList{})
}
35 changes: 35 additions & 0 deletions api/v1alpha1/remotestoragenodeset_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
//+kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.state",description="The status of this RemoteStorageNodeSet"
//+kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"

// RemoteStorageNodeSet declares NodeSet spec and status for objects in remote cluster
type RemoteStorageNodeSet struct {
metav1.TypeMeta `json:",inline"`
// +optional
metav1.ObjectMeta `json:"metadata,omitempty"`
// +optional
Spec StorageNodeSetSpec `json:"spec,omitempty"`
// +optional
// +kubebuilder:default:={state: "Pending"}
Status StorageNodeSetStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

// RemoteStorageNodeSetList contains a list of RemoteStorageNodeSet
type RemoteStorageNodeSetList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []RemoteStorageNodeSet `json:"items"`
}

func init() {
SchemeBuilder.Register(&RemoteStorageNodeSet{}, &RemoteStorageNodeSetList{})
}
7 changes: 3 additions & 4 deletions api/v1alpha1/storagenodeset_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ type StorageNodeSetSpec struct {

// StorageNodeSetStatus defines the observed state
type StorageNodeSetStatus struct {
State constants.ClusterState `json:"state"`
Conditions []metav1.Condition `json:"conditions,omitempty"`
ObservedStorageGeneration int64 `json:"observedStorageGeneration,omitempty"`
State constants.ClusterState `json:"state"`
Conditions []metav1.Condition `json:"conditions,omitempty"`
}

// StorageNodeSetSpecInline describes an group nodes object inside parent object
Expand All @@ -32,7 +31,7 @@ type StorageNodeSetSpecInline struct {

// (Optional) Object should be reference to remote object
// +optional
Remote bool `json:"remote,omitempty"`
Remote *RemoteSpec `json:"remote,omitempty"`

StorageNodeSpec `json:",inline"`
}
Expand Down
163 changes: 153 additions & 10 deletions api/v1alpha1/zz_generated.deepcopy.go

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

Loading
Loading