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

support nebula backup and restore #175

Merged
merged 1 commit into from
Feb 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
42 changes: 19 additions & 23 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
CRD_OPTIONS ?= "crd:trivialVersions=true,preserveUnknownFields=false,maxDescLen=0"
CRD_OPTIONS ?= "crd:generateEmbeddedObjectMeta=false,maxDescLen=0"
# Set build symbols
LDFLAGS = $(if $(DEBUGGER),,-s -w) $(shell ./hack/version.sh)

DOCKER_REGISTRY ?= localhost:5000
DOCKER_REGISTRY ?= docker.io
DOCKER_REPO ?= ${DOCKER_REGISTRY}/vesoft
IMAGE_TAG ?= latest
IMAGE_TAG ?= v1.4.0

CHARTS_VERSION ?= 1.4.0

export GO111MODULE := on
GOOS := $(if $(GOOS),$(GOOS),linux)
Expand Down Expand Up @@ -81,7 +83,7 @@ test: manifests generate check ## Run tests.
source ${ENVTEST_ASSETS_DIR}/setup-envtest.sh; fetch_envtest_tools $(ENVTEST_ASSETS_DIR); setup_envtest_env $(ENVTEST_ASSETS_DIR); go test ./pkg/... ./apis/... -coverprofile cover.out

##@ e2e
e2e: $(GOBIN)/ginkgo $(GOBIN)/kind helm
e2e: $(GOBIN)/ginkgo $(GOBIN)/kind
PATH="${GOBIN}:${PATH}" ./hack/e2e.sh

##@ Build
Expand All @@ -90,12 +92,12 @@ build: generate check ## Build binary.
$(GO_BUILD) -ldflags '$(LDFLAGS)' -o images/nebula-operator/bin/controller-manager cmd/controller-manager/main.go
$(GO_BUILD) -ldflags '$(LDFLAGS)' -o images/nebula-operator/bin/scheduler cmd/scheduler/main.go

build-helm: helm
helm repo index charts --url https://vesoft-inc.github.io/nebula-operator/charts
helm package charts/nebula-operator
helm package charts/nebula-cluster
helm-charts:
cp config/crd/bases/*.yaml charts/nebula-operator/crds/
helm package charts/nebula-operator --version $(CHARTS_VERSION)
helm package charts/nebula-cluster --version $(CHARTS_VERSION)
mv nebula-operator-*.tgz nebula-cluster-*.tgz charts/
cp config/crd/bases/apps.nebula-graph.io_nebulaclusters.yaml charts/nebula-operator/crds/nebulacluster.yaml
helm repo index charts/ --url https://github.com/vesoft-inc/nebula-operator/releases/download/v$(CHARTS_VERSION)

run: run-controller-manager

Expand All @@ -108,7 +110,7 @@ run-scheduler: manifests generate check
docker-build: build ## Build docker images.
docker build -t "${DOCKER_REPO}/nebula-operator:${IMAGE_TAG}" images/nebula-operator/

docker-push: docker-build ## Push docker images.
docker-push: ## Push docker images.
docker push "${DOCKER_REPO}/nebula-operator:${IMAGE_TAG}"

docker-manifest: ## Build all docker images and push it to registry.
Expand Down Expand Up @@ -138,8 +140,7 @@ tools: $(GOBIN)/goimports \
$(GOBIN)/controller-gen \
$(GOBIN)/kustomize \
$(GOBIN)/ginkgo \
$(GOBIN)/kind \
helm
$(GOBIN)/kind

$(GOBIN)/goimports:
$(call go-get-tool,$(GOBIN)/goimports,golang.org/x/tools/cmd/goimports)
Expand All @@ -156,26 +157,20 @@ $(GOBIN)/gofumpt:
$(GOBIN)/golangci-lint:
@[ -f $(GOBIN)/golangci-lint ] || { \
set -e ;\
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOBIN) v1.40.1 ;\
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOBIN) v1.51.1 ;\
}

$(GOBIN)/controller-gen:
$(call go-get-tool,$(GOBIN)/controller-gen,sigs.k8s.io/controller-tools/cmd/controller-gen@v0.4.1)
$(call go-get-tool,$(GOBIN)/controller-gen,sigs.k8s.io/controller-tools/cmd/controller-gen@v0.11.3)

$(GOBIN)/kustomize:
$(call go-get-tool,$(GOBIN)/kustomize,sigs.k8s.io/kustomize/kustomize/[email protected].7)
$(call go-get-tool,$(GOBIN)/kustomize,sigs.k8s.io/kustomize/kustomize/[email protected].7)

$(GOBIN)/ginkgo:
$(call go-get-tool,$(GOBIN)/kustomize,github.com/onsi/ginkgo/[email protected].2)
$(call go-get-tool,$(GOBIN)/ginkgo,github.com/onsi/ginkgo/[email protected].5)

$(GOBIN)/kind:
$(call go-get-tool,$(GOBIN)/kustomize,sigs.k8s.io/[email protected])

helm:
@[ -f /usr/local/bin/helm ] || { \
set -e ;\
curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash ;\
}
$(call go-get-tool,$(GOBIN)/kind,sigs.k8s.io/[email protected])

# go-get-tool will 'go get' any package $2 and install it to $1.
define go-get-tool
Expand All @@ -186,6 +181,7 @@ cd $$TMP_DIR ;\
go mod init tmp ;\
echo "Downloading $(2)" ;\
go get $(2) ;\
go install $(2) ;\
rm -rf $$TMP_DIR ;\
}
endef
79 changes: 54 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
# Nebula Operator

Nebula Operator manages [NebulaGraph](https://github.com/vesoft-inc/nebula) clusters on [Kubernetes](https://kubernetes.io) and automates tasks related to operating a NebulaGraph cluster.
It evolved from [NebulaGraph Cloud Service](https://www.nebula-cloud.io/), makes NebulaGraph a truly cloud-native database.
Nebula Operator manages [NebulaGraph](https://github.com/vesoft-inc/nebula) clusters
on [Kubernetes](https://kubernetes.io) and automates tasks related to operating a NebulaGraph cluster.
It evolved from [NebulaGraph Cloud Service](https://www.nebula-cloud.io/), makes NebulaGraph a truly cloud-native
database.

## Quick Start

- [Install Nebula Operator](#install-nebula-operator)
- [Create and Destroy](#create-and-destroy-a-nebula-cluster)
- [Resize](#resize-a-nebula-cluster)
- [Rolling Upgrade](#upgrade-a-nebula-cluster)
- [Backup and Restore](#backup-and-restore-a-nebula-cluster)
- [Failover](#failover)

### install nebula operator

See [install/uninstall nebula operator](doc/user/install_guide.md) .

### Create and destroy a nebula cluster

```bash
$ kubectl create -f config/samples/apps_v1alpha1_nebulacluster.yaml
```

A none ha-mode nebula cluster will be created.

```bash
$ kubectl get pods -l app.kubernetes.io/cluster=nebula
NAME READY STATUS RESTARTS AGE
Expand All @@ -29,7 +37,8 @@ nebula-storaged-2 1/1 Running 0 1m
```

See [client service](doc/user/client_service.md) for how to access nebula clusters created by the operator.
If you are working with [kubeadm locally](https://kubernetes.io/docs/reference/setup-tools/kubeadm/), create a nodePort service and test that nebula is responding:
If you are working with [kubeadm locally](https://kubernetes.io/docs/reference/setup-tools/kubeadm/), create a nodePort
service and test that nebula is responding:

```bash
$ kubectl create -f config/samples/graphd-nodeport-service.yaml
Expand All @@ -48,6 +57,7 @@ $ kubectl delete -f config/samples/apps_v1alpha1_nebulacluster.yaml
```

### Resize a nebula cluster

Create a nebula cluster:

```bash
Expand All @@ -68,7 +78,7 @@ Modify the file and change `replicas` from 3 to 5.
memory: "1Gi"
replicas: 5
image: vesoft/nebula-storaged
version: v3.3.0
version: v3.4.0
storageClaim:
resources:
requests:
Expand Down Expand Up @@ -96,7 +106,8 @@ nebula-storaged-3 1/1 Running 0 5m
nebula-storaged-4 1/1 Running 0 5m
```

Similarly we can decrease the size of the cluster from 5 back to 3 by changing the replicas field again and reapplying the change.
Similarly, we can decrease the size of the cluster from 5 back to 3 by changing the replicas field again and reapplying
the change.

```yaml
storaged:
Expand All @@ -109,7 +120,7 @@ Similarly we can decrease the size of the cluster from 5 back to 3 by changing t
memory: "1Gi"
replicas: 3
image: vesoft/nebula-storaged
version: v3.3.0
version: v3.4.0
storageClaim:
resources:
requests:
Expand All @@ -132,6 +143,7 @@ nebula-storaged-2 1/1 Running 0 10m
In addition, you can [Install Nebula Cluster with helm](doc/user/nebula_cluster_helm_guide.md).

### Upgrade a nebula cluster

Create a nebula cluster with the version specified (v3.0.0):

```bash
Expand All @@ -154,25 +166,35 @@ $ kubectl get pods -l app.kubernetes.io/cluster=nebula -o jsonpath="{.items[*].
3 vesoft/nebula-storaged:v3.0.0
```

Now modify the file `apps_v1alpha1_nebulacluster.yaml` and change the `version` from v3.0.0 to v3.2.0:
Now modify the file `apps_v1alpha1_nebulacluster.yaml` and change the `version` from v3.0.0 to v3.4.0:

Apply the version change to the cluster CR:

```bash
$ kubectl apply -f config/samples/apps_v1alpha1_nebulacluster.yaml
```

Wait 2 minutes. The container image version should be updated to v3.2.0:
Wait few minutes. The container image version should be updated to v3.4.0:

```bash
$ kubectl get pods -l app.kubernetes.io/cluster=nebula -o jsonpath="{.items[*].spec.containers[*].image}" |tr -s '[[:space:]]' '\n' |sort |uniq -c
1 vesoft/nebula-graphd:v3.3.0
1 vesoft/nebula-metad:v3.3.0
3 vesoft/nebula-storaged:v3.3.0
1 vesoft/nebula-graphd:v3.4.0
1 vesoft/nebula-metad:v3.4.0
3 vesoft/nebula-storaged:v3.4.0
```

**Warning:**

Enterprise version doesn't support upgrade from v3.1.x or v3.2.x to v3.4.0

### Backup and Restore a nebula cluster

See [backup/restore nebula cluster](doc/user/br_guide.md) .

### Failover
If the minority of nebula components crash, the nebula operator will automatically recover the failure. Let's walk through this in the following steps.

If the minority of nebula components crash, the nebula operator will automatically recover the failure. Let's walk
through this in the following steps.

Create a nebula cluster:

Expand Down Expand Up @@ -202,20 +224,22 @@ nebula-storaged-2 1/1 Running 0 19s

Nebula Operator <-> NebulaGraph

| | NebulaGraph v2.5 | NebulaGraph v2.6 | NebulaGraph v3.0 | NebulaGraph v3.1 | NebulaGraph v3.2 | NebulaGraph v3.3 |
|-----------|------------------|------------------|------------------|------------------|------------------|------------------|
| `v0.8.0` | ✓ | - | - | - | - | - |
| `v0.9.0`* | ✓ | ✓ | - | - | - | - |
| `v1.0.0`* | - | - | ✓ | ✓ | ✓ | ✓ |
| `v1.1.0` | - | - | ✓ | ✓ | ✓ | ✓ |
| `v1.2.0` | - | - | ✓ | ✓ | ✓ | ✓ |
| `v1.3.0` | - | - | ✓ | ✓ | ✓ | ✓ |
| | NebulaGraph v2.5 | NebulaGraph v2.6 | NebulaGraph v3.0 | NebulaGraph v3.1 | NebulaGraph v3.2 | NebulaGraph v3.3 | NebulaGraph v3.4 |
|:----------|:-----------------|:-----------------|:-----------------|:-----------------|:-----------------|:-----------------|:-----------------|
| `v0.8.0` | ✓ | - | - | - | - | - | - |
| `v0.9.0`* | ✓ | ✓ | - | - | - | - | - |
| `v1.0.0`* | - | - | ✓ | ✓ | ✓ | ✓ | ✓ |
| `v1.1.0` | - | - | ✓ | ✓ | ✓ | ✓ | ✓ |
| `v1.2.0` | - | - | ✓ | ✓ | ✓ | ✓ | ✓ |
| `v1.3.0` | - | - | ✓ | ✓ | ✓ | ✓ | ✓ |
| `1.4.0` | - | - | ✓ | ✓ | ✓ | ✓ | ✓ |

Key:
**Note:**

* `✓` Compatible.
* `-` Not Compatible.
* `*` Please notice that the StorageClaim is split into LogVolumeClaim and DataVolumeClaim in crd. v0.9.0 can't forward compatible.
* `*` Please notice that the StorageClaim is split into LogVolumeClaim and DataVolumeClaim in crd. v0.9.0 can't forward
compatible.
* v1.0.0 does not support storage auto scaling.
* v1.x does not support upgrading from v2.x to v3.x.

Expand All @@ -224,19 +248,24 @@ Key:
Please refer to [FAQ.md](FAQ.md)

## Community

Feel free to reach out if you have any questions. The maintainers of this project are reachable via:

- [Filing an issue](https://github.com/vesoft-inc/nebula-operator/issues) against this repo

## Contributing

Contributions are welcome and greatly appreciated.
Contributions are welcome and greatly appreciated.

- Start by some issues
- Submit Pull Requests to us. Please refer to [how-to-contribute](https://docs.nebula-graph.io/manual-EN/4.contributions/how-to-contribute/).
- Submit Pull Requests to us. Please refer
to [how-to-contribute](https://docs.nebula-graph.io/manual-EN/4.contributions/how-to-contribute/).

## Acknowledgements

nebula-operator refers to [tidb-operator](https://github.com/pingcap/tidb-operator). They have made a very good product. We have a similar architecture, although the product pattern is different from the application scenario, we would like to express our gratitude here.
nebula-operator refers to [tidb-operator](https://github.com/pingcap/tidb-operator). They have made a very good product.
We have a similar architecture, although the product pattern is different from the application scenario, we would like
to express our gratitude here.

## License

Expand Down
33 changes: 0 additions & 33 deletions ROADMAP.md

This file was deleted.

20 changes: 20 additions & 0 deletions apis/apps/v1alpha1/nebulacluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ func (nc *NebulaCluster) GetMetadEndpoints() []string {
return nc.MetadComponent().GetHeadlessConnAddresses(MetadPortNameThrift)
}

func (nc *NebulaCluster) GetStoragedEndpoints() []string {
return nc.StoragedComponent().GetHeadlessConnAddresses(StoragedPortNameThrift)
}

func (nc *NebulaCluster) GetClusterName() string {
return nc.Name
}
Expand Down Expand Up @@ -88,3 +92,19 @@ func (nc *NebulaCluster) IsAutoBalanceEnabled() bool {
}
return *enabled
}

func (nc *NebulaCluster) IsForceUpdateEnabled() bool {
enabled := nc.Spec.Storaged.EnableForceUpdate
if enabled == nil {
return false
}
return *enabled
}

func (nc *NebulaCluster) IsBREnabled() bool {
enabled := nc.Spec.EnableBR
if enabled == nil {
return false
}
return *enabled
}
Loading