DB Operator
The DB Operator eases the pain of managing PostgreSQL and MySQL instances for applications running in Kubernetes. The Operator creates databases and make them available in the cluster via Custom Resource. It is designed to support the on demand creation of test environments in CI/CD pipelines.
Features
DB Operator provides following features:
- Create/Delete databases on the database server running outside/inside Kubernetes by creating
Database
custom resource;
- Create Google Cloud SQL instances by creating
DbInstance
custom resource;
- Automatically create backup
CronJob
with defined schedule (limited feature);
Documentations
Quickstart
To install DB Operator with helm:
$ helm repo add db-operator https://kloeckner-i.github.io/db-operator/helm/
$ helm install --name my-release db-operator/db-operator
To see more options of helm values here
Development
Prerequisites
- go 1.15+
- docker
- make
- kubectl v1.14+ (< v1.21)
- helm v3.0.2+
- minikube or k3d
To have kubernetes environment locally, you need to install minikube or microk8s.
makefile help
make miniup: start minikube
make minidown: stop minikube
make minidelete: delete minikube
make minidashboard: open minikube dashboard
make build: build db-operator docker image
make helm: install helm if not exist and install local chart using helm upgrade --install command
make setup: build db-operator image, install helm
make update: build db-operator image again and delete running pod
make addexamples: kubectl create -f examples/
make test: spin up mysql, postgres containers and run go unit test
make microsetup: install microk8s locally and deploy db-operator (only for linux)
make k3d_setup: install k3d locally and deploy db-operator
make manifests: generate custom resource definitions
make generate: generate supporting code for custom resource types
Developing with Minikube
How to run db-operator
$ make miniup
$ make setup
After code changes
rebuild local docker image
$ make build
delete running db-operator and apply new image
$ make deploy
or both at once
$ make update
After helm template changes
$ make helm
helm upgrade --install -f {LOCAL CHART DIR}/values-local.yaml {LOCAL CHART DIR}
Developing with k3d
How to run db-operator
$ make k3d_setup
After code changes
rebuild local docker image
$ make k3d_build
delete running db-operator and apply new image
$ make deploy
After helm template changes
$ make helm
Developing with microk8s
- Microk8s supports only linux environment. Non linux user can use microk8s using vm for example multipass. Please find details here
How to run db-operator
$ make microsetup
microsetup is used for our integration test in pipeline.
Run unit test locally
$ make test