Skip to content

db-operator/db-operator

 
 

Repository files navigation

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.

Status of the project

Until we find more maintainers for the project, I (@allanger) only plan to implement features that I personally need and keep the codebase up-to-date. For a couple of years, I’ve been receiving requests for new features related to DbUsers or cloud provider compatibility, but I don’t use either of these.

I don’t want to discourage anyone from creating issues or asking questions. I try to stay active, and I’m always ready to help. If there are bugs or vulnerabilities, they will be fixed as soon as I have time.

However, I want to make it clear that, as of now, I consider the project complete. Even though I have many ideas for improvements, my focus has shifted away from Go and Kubernetes development into a different field.

With that said, if you need a new feature — especially related to DbUsers or cloud providers — feel free to create an issue, but be prepared to implement it yourself. I am always ready to review pull requests.

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

Helm Chart is migrated!

The repository contains helm charts for db-operator is moved to https://github.com/db-operator/charts New chart after db-operator > 1.2.7, db-instances > 1.3.0 will be only available in new repository.

CRD Versions are upgraded!

Now both DbInstance and Database resources are upgraded to v1beta1. In case you were using connectionStringTemplate, make sure I've migrated to secretsTempaltes before upgrading, because connectionStringTemplate is removed in this version. Everything else should go seamless. We've added Webhooks that will take care of resources with an old API version and convert them to the newer one.

Downloading old charts

Installing older version of charts is still possible. Check available versions by following command.

$ helm repo add kloeckneri-old https://kloeckner-i.github.io/db-operator/
$ helm search repo kloeckneri-old/ --versions

Quickstart

To install DB Operator with helm:

$ helm repo add db-operator https://db-operator.github.io/charts/
$ helm install --name my-release db-operator/db-operator

To see more options of helm values, see chart repo

To see which version is working together check out our version matrix.

Development

Prerequisites

  • go 1.15+
  • docker
  • make
  • kubectl v1.14+ (< v1.21)
  • helm v3.0.2+
  • k3d

To have kubernetes environment locally, you need to install k3d.

makefile help

addexamples           add examples via kubectl create -f examples/
build                 build db-operator docker image
controller-gen        Download controller-gen locally if necessary.
generate              generate supporting code for custom resource types
help                  show this help
k3d_image             rebuild the docker images and upload into your k3d cluster
k3d_install           install k3d cluster locally
k3d_setup             install k3d and import image to your k3d cluster
k3s_mac_deploy        build image and import image to local lima k8s
k3s_mac_image         import built image to local lima k8s
k3s_mac_lima_create   create local k8s using lima
k3s_mac_lima_start    start local lima k8s
lint                  lint go code
manifests             generate custom resource definitions
test                  run go unit test
vet                   go vet to find issues

Developing locally

After code changes

rebuild CRD manifests

$ make manifests

rebuild local docker image

$ make build

Run local kubernetes

$ make k3d_setup

or

$ make k3s_mac_lima_create

Import local docker image

$ make k3d_build

or

$ make k3s_mac_image

Deploy

helm repo add db-operator https://db-operator.github.io/charts
helm repo update
helm upgrade my-release db-operator/db-operator --set image.repository=my-db-operator --set image.tag=1.0.0-dev --set image.pullPolicy=IfNotPresent --install

Run unit test locally

$ make test

Packages

 
 
 

Languages

  • Go 96.8%
  • Makefile 1.8%
  • Shell 1.2%
  • Dockerfile 0.2%