Skip to content

Commit

Permalink
Merge pull request #4 from cybozu-go/rename-rbdpvc-to-mantle
Browse files Browse the repository at this point in the history
core: rename everyting from rbdpvc to mantle
  • Loading branch information
cupnes authored Apr 16, 2024
2 parents 91a0112 + fd5398b commit 7abbc9a
Show file tree
Hide file tree
Showing 36 changed files with 411 additions and 395 deletions.
25 changes: 16 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

# Image URL to use all building/pushing image targets
IMG ?= controller:latest
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
ENVTEST_K8S_VERSION = 1.28.3
# K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
K8S_VERSION = 1.28.3

# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
Expand Down Expand Up @@ -62,7 +62,7 @@ vet: ## Run go vet against code.

.PHONY: test
test: manifests generate fmt vet envtest ## Run tests.
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test ./... -coverprofile cover.out
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test ./... -coverprofile cover.out

GOLANGCI_LINT = $(shell pwd)/bin/golangci-lint
GOLANGCI_LINT_VERSION ?= v1.54.2
Expand Down Expand Up @@ -124,21 +124,22 @@ ifndef ignore-not-found
ignore-not-found = false
endif


.PHONY: install
install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
install: manifests kustomize kubectl ## Install CRDs into the K8s cluster specified in ~/.kube/config.
$(KUSTOMIZE) build config/crd | $(KUBECTL) apply -f -

.PHONY: uninstall
uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
uninstall: manifests kustomize kubectl ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
$(KUSTOMIZE) build config/crd | $(KUBECTL) delete --ignore-not-found=$(ignore-not-found) -f -

.PHONY: deploy
deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
deploy: manifests kustomize kubectl ## Deploy controller to the K8s cluster specified in ~/.kube/config.
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
$(KUSTOMIZE) build config/default | $(KUBECTL) apply -f -

.PHONY: undeploy
undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
undeploy: kubectl ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
$(KUSTOMIZE) build config/default | $(KUBECTL) delete --ignore-not-found=$(ignore-not-found) -f -

##@ Build Dependencies
Expand All @@ -149,14 +150,14 @@ $(LOCALBIN):
mkdir -p $(LOCALBIN)

## Tool Binaries
KUBECTL ?= kubectl
KUBECTL ?= $(LOCALBIN)/kubectl
KUSTOMIZE ?= $(LOCALBIN)/kustomize
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
ENVTEST ?= $(LOCALBIN)/setup-envtest

## Tool Versions
KUSTOMIZE_VERSION ?= v5.2.1
CONTROLLER_TOOLS_VERSION ?= v0.13.0
CONTROLLER_TOOLS_VERSION ?= v0.14.0

.PHONY: kustomize
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary. If wrong version is installed, it will be removed before downloading.
Expand All @@ -177,3 +178,9 @@ $(CONTROLLER_GEN): $(LOCALBIN)
envtest: $(ENVTEST) ## Download envtest-setup locally if necessary.
$(ENVTEST): $(LOCALBIN)
test -s $(LOCALBIN)/setup-envtest || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest

.PHONY: kubectl
kubectl: $(KUBECTL) # Download kubectl if necessary.
$(KUBECTL): $(LOCALBIN)
curl https://storage.googleapis.com/kubernetes-release/release/v$(K8S_VERSION)/bin/linux/amd64/kubectl -o $(KUBECTL)
chmod 755 $(KUBECTL)
12 changes: 6 additions & 6 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
# This file is used to track the info used to scaffold your project
# and allow the plugins properly work.
# More info: https://book.kubebuilder.io/reference/project-config.html
domain: cybozu.com
domain: cybozu.io
layout:
- go.kubebuilder.io/v4
projectName: rbd-backup-system
repo: github.com/cybozu-go/rbd-backup-system
projectName: mantle
repo: github.com/cybozu-go/mantle
resources:
- api:
crdVersion: v1
namespaced: true
controller: true
domain: cybozu.com
domain: cybozu.io
group: backup
kind: RBDPVCBackup
path: github.com/cybozu-go/rbd-backup-system/api/v1
kind: MantleBackup
path: github.com/cybozu-go/mantle/api/v1
version: v1
version: "3"
25 changes: 14 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,32 @@
# rbd-backup-system
# mantle

The system for backup RBD PVC managed by Rook/Ceph. It can also copy the backup data to another Rook/Ceph cluster in another data center.

## Description

Users can manage backups by `RBDPVCBackup` resources.
Users can manage backups by `MantleBackup` resources.

## Getting Started

If you want to try rbd-backup-system on your local machine, see [e2e](e2e/) directory which provides scripts to run rbd-backup-system on [minikube][kind].
If you want to try mantle on your local machine, see [e2e](e2e/) directory which provides scripts to run mantle on [minikube].

To use rbd-backup-system on your real kubernetes cluster, read following sections.
To use mantle on your real kubernetes cluster, read following sections.

### Prerequisites
- go version v1.21.0+
- docker version 20.10+
- kubectl version v1.27.10+
- Access to a Kubernetes v1.27.10+ cluster
- Rook v1.13.1+
- Deploy
- Kubernetes cluster: v1.27.10+
- Rook: v1.13.1+
- build
- go: v1.21.0+
- docker: 20.10+
- kubectl: v1.27.10+
- kubebuilder: 3.14.0+

### To Deploy on the cluster
**Build and push your image to the location specified by `IMG`:**

```sh
make docker-build docker-push IMG=<some-registry>/rbd-backup-system:tag
make docker-build docker-push IMG=<some-registry>/mantle:tag
```

**NOTE:** This image ought to be published in the personal registry you specified.
Expand All @@ -39,7 +42,7 @@ make install
**Deploy the Manager to the cluster with the image specified by `IMG`:**

```sh
make deploy IMG=<some-registry>/rbd-backup-system:tag
make deploy IMG=<some-registry>/mantle:tag
```

> **NOTE**: If you encounter RBAC errors, you may need to grant yourself cluster-admin
Expand Down
2 changes: 1 addition & 1 deletion TODO
Original file line number Diff line number Diff line change
@@ -1 +1 @@
The `CephBlockPool` and `StorageClass` in config/samples/backup_v1_rbdpvcbackup.yaml are copies of https://github.com/rook/rook/blob/2ae319eebce7d525be90b5aed6baba1afe1e2e6e/deploy/examples/csi/rbd/storageclass-test.yaml.
The `CephBlockPool` and `StorageClass` in config/samples/backup_v1_mantlebackup.yaml are copies of https://github.com/rook/rook/blob/2ae319eebce7d525be90b5aed6baba1afe1e2e6e/deploy/examples/csi/rbd/storageclass-test.yaml.
4 changes: 2 additions & 2 deletions api/v1/groupversion_info.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Package v1 contains API Schema definitions for the backup v1 API group
// +kubebuilder:object:generate=true
// +groupName=backup.cybozu.com
// +groupName=mantle.cybozu.io
package v1

import (
Expand All @@ -10,7 +10,7 @@ import (

var (
// GroupVersion is group version used to register these objects
GroupVersion = schema.GroupVersion{Group: "backup.cybozu.com", Version: "v1"}
GroupVersion = schema.GroupVersion{Group: "mantle.cybozu.io", Version: "v1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
Expand Down
24 changes: 12 additions & 12 deletions api/v1/rbdpvcbackup_types.go → api/v1/mantlebackup_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// RBDPVCBackupSpec defines the desired state of RBDPVCBackup
type RBDPVCBackupSpec struct {
// MantleBackupSpec defines the desired state of MantleBackup
type MantleBackupSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file

Expand All @@ -21,8 +21,8 @@ type RBDPVCBackupSpec struct {
Namespace string `json:"namespace,omitempty"`
}

// RBDPVCBackupStatus defines the observed state of RBDPVCBackup
type RBDPVCBackupStatus struct {
// MantleBackupStatus defines the observed state of MantleBackup
type MantleBackupStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file

Expand All @@ -44,24 +44,24 @@ const (
//+kubebuilder:object:root=true
//+kubebuilder:subresource:status

// RBDPVCBackup is the Schema for the rbdpvcbackups API
type RBDPVCBackup struct {
// MantleBackup is the Schema for the mantlebackups API
type MantleBackup struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec RBDPVCBackupSpec `json:"spec,omitempty"`
Status RBDPVCBackupStatus `json:"status,omitempty"`
Spec MantleBackupSpec `json:"spec,omitempty"`
Status MantleBackupStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

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

func init() {
SchemeBuilder.Register(&RBDPVCBackup{}, &RBDPVCBackupList{})
SchemeBuilder.Register(&MantleBackup{}, &MantleBackupList{})
}
38 changes: 19 additions & 19 deletions api/v1/zz_generated.deepcopy.go

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

10 changes: 5 additions & 5 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import (
"sigs.k8s.io/controller-runtime/pkg/log/zap"
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"

backupv1 "github.com/cybozu-go/rbd-backup-system/api/v1"
"github.com/cybozu-go/rbd-backup-system/internal/controller"
backupv1 "github.com/cybozu-go/mantle/api/v1"
"github.com/cybozu-go/mantle/internal/controller"
//+kubebuilder:scaffold:imports
)

Expand Down Expand Up @@ -55,7 +55,7 @@ func main() {
Metrics: metricsserver.Options{BindAddress: metricsAddr},
HealthProbeBindAddress: probeAddr,
LeaderElection: enableLeaderElection,
LeaderElectionID: "cfdaa833.cybozu.com",
LeaderElectionID: "cfdaa833.cybozu.io",
// LeaderElectionReleaseOnCancel defines if the leader should step down voluntarily
// when the Manager ends. This requires the binary to immediately end when the
// Manager is stopped, otherwise, this setting is unsafe. Setting this significantly
Expand All @@ -73,11 +73,11 @@ func main() {
os.Exit(1)
}

if err = (&controller.RBDPVCBackupReconciler{
if err = (&controller.MantleBackupReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "RBDPVCBackup")
setupLog.Error(err, "unable to create controller", "controller", "MantleBackup")
os.Exit(1)
}
//+kubebuilder:scaffold:builder
Expand Down
Loading

0 comments on commit 7abbc9a

Please sign in to comment.