{"id":15157977,"url":"https://github.com/marctc/database-controller","last_synced_at":"2025-09-30T07:31:14.610Z","repository":{"id":47288984,"uuid":"95666971","full_name":"marctc/database-controller","owner":"marctc","description":" Controller to manage databases on Kubernetes ","archived":true,"fork":false,"pushed_at":"2021-05-05T09:27:30.000Z","size":17329,"stargazers_count":41,"open_issues_count":1,"forks_count":13,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-09-27T20:21:15.708Z","etag":null,"topics":["ci","controller","database-controller","kubernetes","mysql","postgresql","provisioner"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/marctc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-06-28T12:31:09.000Z","updated_at":"2023-11-01T15:40:19.000Z","dependencies_parsed_at":"2022-09-12T15:53:31.664Z","dependency_job_id":null,"html_url":"https://github.com/marctc/database-controller","commit_stats":null,"previous_names":["kubejam/database-controller","kubehippie/database-controller"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marctc%2Fdatabase-controller","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marctc%2Fdatabase-controller/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marctc%2Fdatabase-controller/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marctc%2Fdatabase-controller/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marctc","download_url":"https://codeload.github.com/marctc/database-controller/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234712879,"owners_count":18875526,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ci","controller","database-controller","kubernetes","mysql","postgresql","provisioner"],"created_at":"2024-09-26T20:21:27.086Z","updated_at":"2025-09-30T07:31:10.714Z","avatar_url":"https://github.com/marctc.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"Kubernetes database controller\n==============================\n[![Go Report Card](https://goreportcard.com/badge/github.com/kubejam/database-controller)](https://goreportcard.com/report/github.com/kubejam/database-controller)\n\nThis is a database controller for Kubernetes.  It allows users to provision\non-demand databases for their applications by creating \"Database\" resources in\nKubernetes, without requiring access to the database server.  This is useful\nfor staging sites, CI builds, review apps and other situations where new\ndatabases need to be provisioned frequently.\n\nThe controller works by watching for creation of a new custom resouce type\ncalled `Database`, and running `CREATE USER` / `CREATE DATABASE` statements on\nthe configured database server(s).  Both MySQL and PostgreSQL databases are\nsupported, and multiple database classes can be configured for each type (e.g.\n\"staging\" and \"review\").  When the Database resource is deleted in Kubernetes,\nthe corresponding database and user are dropped.\n\n**WARNING**: This is **experimental** software and **drops databases by\ndesign**.  We strongly recommend keeping regular backups, and not running it on\nproduction databases.\n\nCluster setup\n-------------\n\nFor the provisioner to work, you must create the Database custom resource type\non your Kubernetes cluster:\n\n```\n$ kubectl apply -f https://raw.githubusercontent.com/kubejam/database-controller/master/crd.yaml\n```\n\n(For Kubernetes 1.6 or earlier, use `tpr.yaml` instead; this creates a\nThirdPartyResource which you will need to\n[migrate](https://kubernetes.io/docs/tasks/access-kubernetes-api/migrate-third-party-resource/)\nwhen upgrading to 1.8 or later.)\n\nIn addition, if your cluster uses authorization (e.g. RBAC) you should give\nusers permission to create and delete Database resources in the kubejam/v1\nAPI group.\n\nInstallation\n------------\n\nThe easiest way to run the provisioner is as a pod inside Kubernetes.  See the\nexample `deployment.yaml` for an example.  A configuration file is required; an\nexample is provided in `config.yaml.example`.\n\nCreate the configuration in `config.yaml` and apply it to the cluster:\n\n```\n$ kubectl create namespace database-controller\n$ kubectl -n database-controller create secret generic config --from-file=config.yaml=config.yaml\n```\n\nThen deploy the controller:\n\n```\n$ kubectl apply -f https://raw.githubusercontent.com/kubejam/database-controller/master/deployment.yaml\n```\n\nUsage\n-----\n\nTo provision a database, create a Database resource that looks like this:\n\n```\napiVersion: kubejam/v1\nkind: Database\nmetadata:\n  namespace: default\n  name: mydb\nspec:\n  type: postgresql\n  class: default\n  secretName: mydb-secret\n```\n\n`type` is the type of database to create; currently, `postgresql` and `mysql`\nare the supported types.  `class` is the class of database to create.  If not\nspecified, the default is `default`.  The specified class must be configured in\n`config.yaml`, or provisioning will fail.\n\n`secretName` is the name of a secret that will be created to store the database\nURL.  The created secret will look like this:\n\n```\napiVersion: v1\nkind: Secret\nmetadata:\n  namespace: default\n  name: mydb-secret\ntype: Opaque\ndata:\n  database-url: cG9zdGdyZXNxbDovL2RlZmF1bHRfbXlkYjplOFFFTGZUWkpkdW0wVHJVQHBvc3RncmVzLmRhdGFiYXNlLnN2Yy9kZWZhdWx0X215ZGI=\n```\n\n```\n$ echo 'cG9zdGdyZXNxbDovL2RlZmF1bHRfbXlkYjplOFFFTGZUWkpkdW0wVHJVQHBvc3RncmVzLmRhdGFiYXNlLnN2Yy9kZWZhdWx0X215ZGI=' | base64 -d\npostgresql://default_mydb:e8QELfTZJdum0TrU@postgres.database.svc/default_mydb\n```\n\nTo delete a provisioned database, delete the Database resource:\n\n```\n$ kubectl delete database mydb\n```\n\nNotes / bugs\n------------\n\nCompared to the persistent volume provisioner, this controller is very\nprimitive.\n\nIt does not use finalizers to ensure consistent database deletion, so it's\npossible for a Database record to be deleted while the corresponding database\nisn't dropped, if an error occurs or the controller misses the deletion event.\n\nIt does not use a lease to serialize operations, so only one copy can be\nrunning at once.\n\nThere is no permission checking on the created Secret, so a user with access to\ncreate Database resources in a namespace can overwrite existing Secrets in that\nnamespace.  (This is not considered a serious problem since Kubernetes access\ncontrol is usually done on the namespace level anyway.)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarctc%2Fdatabase-controller","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarctc%2Fdatabase-controller","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarctc%2Fdatabase-controller/lists"}