diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 0197740..16ad4fa 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -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: | diff --git a/Makefile b/Makefile index 00e28c8..b9f52b9 100644 --- a/Makefile +++ b/Makefile @@ -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=> 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 diff --git a/README.md b/README.md index 6194478..c2a3efa 100644 --- a/README.md +++ b/README.md @@ -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 +databend -## Getting Started +
-### Prerequisites -- go version v1.22.0+ -- docker version 17.03+. -- kubectl version v1.11.3+. -- Access to a Kubernetes v1.11.3+ cluster. +
+ +slack + -### To Deploy on the cluster -**Build and push your image to the location specified by `IMG`:** + +feishu + -```sh -make docker-build docker-push IMG=/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. +
-**Install the CRDs into the cluster:** +
+
-```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=/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=/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 to install the project, i.e.: - -```sh -kubectl apply -f https://raw.githubusercontent.com//databend-operator//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 diff --git a/config/rbac/role.yaml b/config/rbac/role.yaml deleted file mode 100644 index d9485f9..0000000 --- a/config/rbac/role.yaml +++ /dev/null @@ -1,66 +0,0 @@ ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - name: manager-role -rules: -- apiGroups: - - "" - resources: - - configmaps - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - "" - resources: - - secrets - verbs: - - get - - list -- apiGroups: - - apps - resources: - - statefulsets - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - databendlabs.io - resources: - - tenants - - warehouses - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - databendlabs.io - resources: - - tenants/finalizers - - warehouses/finalizers - verbs: - - update -- apiGroups: - - databendlabs.io - resources: - - tenants/status - - warehouses/status - verbs: - - get - - patch - - update