All Projects → kubejam → database-controller

kubejam / database-controller

Licence: other
Controller to manage databases on Kubernetes

Programming Languages

go
31211 projects - #10 most used programming language
shell
77523 projects
Dockerfile
14818 projects
Makefile
30231 projects

Projects that are alternatives of or similar to database-controller

Metac
It is metacontroller and more
Stars: ✭ 50 (+21.95%)
Mutual labels:  ci, controller
rasa-train-test-gha
A GitHub action to run easily rasa train and rasa test in the CIs.
Stars: ✭ 26 (-36.59%)
Mutual labels:  ci
plasmolysis
[WIP] 探索同构开发新范式的可能性
Stars: ✭ 12 (-70.73%)
Mutual labels:  controller
npm-audit-ci
www.npmjs.com/package/npm-audit-ci
Stars: ✭ 18 (-56.1%)
Mutual labels:  ci
netlify-plugin-cache
⚡ Generic plugin for caching any files and/or folders between Netlify builds
Stars: ✭ 19 (-53.66%)
Mutual labels:  ci
swarmci
Swarm CI - Docker Swarm-based CI system or enhancement to existing systems.
Stars: ✭ 48 (+17.07%)
Mutual labels:  ci
github-create-release-action
Create a GitHub release from a Tag
Stars: ✭ 33 (-19.51%)
Mutual labels:  ci
flagsmith-js-client
Javascript Client for Flagsmith. Ship features with confidence using feature flags and remote config. Host yourself or use our hosted version at https://www.flagsmith.com/
Stars: ✭ 42 (+2.44%)
Mutual labels:  ci
ci-publish
Poor man's semantic release utility. Let the CI do the `npm publish` step after the build passes
Stars: ✭ 30 (-26.83%)
Mutual labels:  ci
pcb-ws2812-wifi-controller
WiFi Controller for WS2812 LED Stripes
Stars: ✭ 48 (+17.07%)
Mutual labels:  controller
Alfred ShadowsocksController
ShadowsocksX controller for Alfred
Stars: ✭ 70 (+70.73%)
Mutual labels:  controller
docker-coala-base
coala base docker image
Stars: ✭ 20 (-51.22%)
Mutual labels:  ci
arduino-lint
Tool to check for problems with Arduino projects
Stars: ✭ 63 (+53.66%)
Mutual labels:  ci
release-helper
🤖 A GitHub Action that help you publish release.
Stars: ✭ 27 (-34.15%)
Mutual labels:  ci
react-native-ci-tools
Change application bundle name and ID on the fly (build time) for both Android and IOS
Stars: ✭ 30 (-26.83%)
Mutual labels:  ci
sdram-controller
Generic FPGA SDRAM controller, originally made for AS4C4M16SA
Stars: ✭ 45 (+9.76%)
Mutual labels:  controller
duci
The simple ci server
Stars: ✭ 73 (+78.05%)
Mutual labels:  ci
prettier-check
Check that all files match prettier code style.
Stars: ✭ 54 (+31.71%)
Mutual labels:  ci
dockerized-drupal-starter
End-to-end (CI + CD) dockerized Drupal 8 starting point.
Stars: ✭ 27 (-34.15%)
Mutual labels:  ci
phpstan-symfony
*DEPRECATED* Symfony extension for PHPStan
Stars: ✭ 42 (+2.44%)
Mutual labels:  controller

Kubernetes database controller

Go Report Card

This is a database controller for Kubernetes. It allows users to provision on-demand databases for their applications by creating "Database" resources in Kubernetes, without requiring access to the database server. This is useful for staging sites, CI builds, review apps and other situations where new databases need to be provisioned frequently.

The controller works by watching for creation of a new custom resouce type called Database, and running CREATE USER / CREATE DATABASE statements on the configured database server(s). Both MySQL and PostgreSQL databases are supported, and multiple database classes can be configured for each type (e.g. "staging" and "review"). When the Database resource is deleted in Kubernetes, the corresponding database and user are dropped.

WARNING: This is experimental software and drops databases by design. We strongly recommend keeping regular backups, and not running it on production databases.

Cluster setup

For the provisioner to work, you must create the Database custom resource type on your Kubernetes cluster:

$ kubectl apply -f https://raw.githubusercontent.com/kubejam/database-controller/master/crd.yaml

(For Kubernetes 1.6 or earlier, use tpr.yaml instead; this creates a ThirdPartyResource which you will need to migrate when upgrading to 1.8 or later.)

In addition, if your cluster uses authorization (e.g. RBAC) you should give users permission to create and delete Database resources in the kubejam/v1 API group.

Installation

The easiest way to run the provisioner is as a pod inside Kubernetes. See the example deployment.yaml for an example. A configuration file is required; an example is provided in config.yaml.example.

Create the configuration in config.yaml and apply it to the cluster:

$ kubectl create namespace database-controller
$ kubectl -n database-controller create secret generic config --from-file=config.yaml=config.yaml

Then deploy the controller:

$ kubectl apply -f https://raw.githubusercontent.com/kubejam/database-controller/master/deployment.yaml

Usage

To provision a database, create a Database resource that looks like this:

apiVersion: kubejam/v1
kind: Database
metadata:
  namespace: default
  name: mydb
spec:
  type: postgresql
  class: default
  secretName: mydb-secret

type is the type of database to create; currently, postgresql and mysql are the supported types. class is the class of database to create. If not specified, the default is default. The specified class must be configured in config.yaml, or provisioning will fail.

secretName is the name of a secret that will be created to store the database URL. The created secret will look like this:

apiVersion: v1
kind: Secret
metadata:
  namespace: default
  name: mydb-secret
type: Opaque
data:
  database-url: cG9zdGdyZXNxbDovL2RlZmF1bHRfbXlkYjplOFFFTGZUWkpkdW0wVHJVQHBvc3RncmVzLmRhdGFiYXNlLnN2Yy9kZWZhdWx0X215ZGI=
$ echo 'cG9zdGdyZXNxbDovL2RlZmF1bHRfbXlkYjplOFFFTGZUWkpkdW0wVHJVQHBvc3RncmVzLmRhdGFiYXNlLnN2Yy9kZWZhdWx0X215ZGI=' | base64 -d
postgresql://default_mydb:[email protected]/default_mydb

To delete a provisioned database, delete the Database resource:

$ kubectl delete database mydb

Notes / bugs

Compared to the persistent volume provisioner, this controller is very primitive.

It does not use finalizers to ensure consistent database deletion, so it's possible for a Database record to be deleted while the corresponding database isn't dropped, if an error occurs or the controller misses the deletion event.

It does not use a lease to serialize operations, so only one copy can be running at once.

There is no permission checking on the created Secret, so a user with access to create Database resources in a namespace can overwrite existing Secrets in that namespace. (This is not considered a serious problem since Kubernetes access control is usually done on the namespace level anyway.)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].