Skip to content
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
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
git diff --cached --exit-code || (echo 'Please run "go mod tidy" to sync Go modules' && exit 1);
- name: Check auto-generated assets
run: |
make generate && git add pkg config &&
make generate && git add pkg manifests &&
git diff --cached --exit-code || (echo 'Please run "make generate" to generate assets' && exit 1);
- name: Verify gofmt
run: |
Expand Down
49 changes: 2 additions & 47 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -90,62 +90,17 @@ build: manifests generate fmt vet ## Build manager binary.
run: fmt vet ## Run a controller from your host.
go run ./cmd/main.go

# If you wish to build the manager image targeting other platforms you can use the --platform flag.
# (i.e. docker build --platform linux/arm64). However, you must enable docker buildKit for it.
# More info: https://docs.docker.com/develop/develop-images/build_enhancements/
.PHONY: docker-build
docker-build: ## Build docker image with the manager.
$(CONTAINER_TOOL) build -t ${IMG} .

.PHONY: docker-push
docker-push: ## Push docker image with the manager.
$(CONTAINER_TOOL) push ${IMG}

# PLATFORMS defines the target platforms for the manager image be built to provide support to multiple
# architectures. (i.e. make docker-buildx IMG=myregistry/mypoperator:0.0.1). To use this option you need to:
# - be able to use docker buildx. More info: https://docs.docker.com/build/buildx/
# - have enabled BuildKit. More info: https://docs.docker.com/develop/develop-images/build_enhancements/
# - be able to push the image to your registry (i.e. if you do not set a valid value via IMG=<myregistry/image:<tag>> then the export will fail)
# To adequately provide solutions that are compatible with multiple platforms, you should consider using this option.
PLATFORMS ?= linux/arm64,linux/amd64,linux/s390x,linux/ppc64le
.PHONY: docker-buildx
docker-buildx: ## Build and push docker image for the manager for cross-platform support
# copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile
sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' Dockerfile > Dockerfile.cross
- $(CONTAINER_TOOL) buildx create --name databend-operator-builder
$(CONTAINER_TOOL) buildx use databend-operator-builder
- $(CONTAINER_TOOL) buildx build --push --platform=$(PLATFORMS) --tag ${IMG} -f Dockerfile.cross .
- $(CONTAINER_TOOL) buildx rm databend-operator-builder
rm Dockerfile.cross

.PHONY: build-installer
build-installer: manifests generate kustomize ## Generate a consolidated YAML with CRDs and deployment.
mkdir -p dist
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
$(KUSTOMIZE) build config/default > dist/install.yaml

##@ Deployment

ifndef ignore-not-found
ignore-not-found = false
endif

.PHONY: install
install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
$(KUSTOMIZE) build config/crd | $(KUBECTL) apply -f -
$(KUSTOMIZE) build manifests/crds | $(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.
$(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.
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
$(KUSTOMIZE) build config/default | $(KUBECTL) apply -f -

.PHONY: undeploy
undeploy: kustomize ## 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 -
$(KUSTOMIZE) build manifests/crds | $(KUBECTL) delete --ignore-not-found=$(ignore-not-found) -f -

##@ Dependencies

Expand Down
107 changes: 37 additions & 70 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,100 +1,67 @@
# databend-operator
// TODO(user): Add simple overview of use/purpose
# Databend Operator

## Description
// TODO(user): An in-depth paragraph about your project and overview of use
<img src="https://github.com/databendlabs/databend/assets/172204/9997d8bc-6462-4dbd-90e3-527cf50a709c" alt="databend" />

## Getting Started
<div align="center">

### Prerequisites
- go version v1.22.0+
- docker version 17.03+.
- kubectl version v1.11.3+.
- Access to a Kubernetes v1.11.3+ cluster.
<div>
<a href="https://link.databend.com/join-slack">
<img src="https://img.shields.io/badge/slack-databend-0abd59?logo=slack" alt="slack" />
</a>

### To Deploy on the cluster
**Build and push your image to the location specified by `IMG`:**
<a href="https://link.databend.com/join-feishu">
<img src="https://img.shields.io/badge/feishu-databend-0abd59" alt="feishu" />
</a>

```sh
make docker-build docker-push IMG=<some-registry>/databend-operator:tag
```

**NOTE:** This image ought to be published in the personal registry you specified.
And it is required to have access to pull the image from the working environment.
Make sure you have the proper permission to the registry if the above commands don’t work.
<br>

**Install the CRDs into the cluster:**
</div>
</div>

```sh
make install
```
[Kubernetes](https://kubernetes.io/docs/home/) is an open source container orchestration engine for automating deployment, scaling, and management of containerized applications. [Operators](https://kubernetes.io/docs/concepts/extend-kubernetes/operator/) are software extensions to Kubernetes that make use of custom resources to manage applications and their components. Operators follow Kubernetes principles, notably the control loop.

**Deploy the Manager to the cluster with the image specified by `IMG`:**
Use this operator to manage [Databend](https://github.com/databendlabs/databend) clusters which are deployed as custom resources. In short, the task of configuring, creating, managing, automatically scaling up and scaling-in of Databend cluster(s) in a Kubernetes environment has been made simple, easy and quick.

```sh
make deploy IMG=<some-registry>/databend-operator:tag
```
## Deploying Operator

> **NOTE**: If you encounter RBAC errors, you may need to grant yourself cluster-admin
privileges or be logged in as admin.
Run the following command to install the latest changes of the Databend Operator:

**Create instances of your solution**
You can apply the samples (examples) from the config/sample:

```sh
kubectl apply -k config/samples/
```shell
kubectl apply -k "github.com/databendcloud/databend-operator/manifests"
```

>**NOTE**: Ensure that the samples has default values to test it out.

### To Uninstall
**Delete the instances (CRs) from the cluster:**

```sh
kubectl delete -k config/samples/
```
## Get Started

**Delete the APIs(CRDs) from the cluster:**
You can get started by deploying [this example](./examples/get-started/) from `examples/get-started`!

```sh
make uninstall
```
Learn more about Databend deployments from [this guide](https://docs.databend.com/guides/deploy/deploy/understanding-deployment-modes).

**UnDeploy the controller from the cluster:**
Step1: Deploy Databend Meta Cluster

```sh
make undeploy
```shell
helm repo add databend https://charts.databend.com
helm install meta databend/databend-meta --namespace databend-system
```

## Project Distribution
Step2: Prepare Object Storage

Following are the steps to build the installer and distribute this project to users.
We'll use [Minio](https://github.com/minio/minio) as the object storage for our example.

1. Build the installer for the image built and published in the registry:

```sh
make build-installer IMG=<some-registry>/databend-operator:tag
```shell
kubectl apply -f "github.com/databendcloud/databend-operator/examples/get-started/minio.yaml"
```

NOTE: The makefile target mentioned above generates an 'install.yaml'
file in the dist directory. This file contains all the resources built
with Kustomize, which are necessary to install this project without
its dependencies.

2. Using the installer
Step3: Define Tenant

Users can just run kubectl apply -f <URL for YAML BUNDLE> to install the project, i.e.:

```sh
kubectl apply -f https://raw.githubusercontent.com/<org>/databend-operator/<tag or branch>/dist/install.yaml
```shell
kubectl apply -f "github.com/databendcloud/databend-operator/examples/get-started/tenant.yaml"
```

## Contributing
// TODO(user): Add detailed information on how you would like others to contribute to this project

**NOTE:** Run `make help` for more information on all potential `make` targets
Step4: Deploy Dataebend Query Cluster(Warehouse)

More information can be found via the [Kubebuilder Documentation](https://book.kubebuilder.io/introduction.html)
```shell
kubectl apply -f "github.com/databendcloud/databend-operator/examples/get-started/warehouse.yaml"
```

## License

Expand Down
66 changes: 0 additions & 66 deletions config/rbac/role.yaml

This file was deleted.

Loading