{"id":17324937,"url":"https://github.com/cuppett/mysql-dba-operator","last_synced_at":"2025-03-22T19:33:11.983Z","repository":{"id":39899018,"uuid":"334976409","full_name":"cuppett/mysql-dba-operator","owner":"cuppett","description":"Help manage users and databases (CRUD + permissions) in a database from Kubernetes","archived":false,"fork":false,"pushed_at":"2024-10-01T08:06:18.000Z","size":558,"stargazers_count":2,"open_issues_count":9,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-16T14:11:57.508Z","etag":null,"topics":["database","dba","kubernetes","mysql","sql"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cuppett.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-02-01T14:30:07.000Z","updated_at":"2024-10-01T08:05:09.000Z","dependencies_parsed_at":"2023-10-28T14:37:51.354Z","dependency_job_id":"7ba2644b-91c1-4ede-b640-2f3fa6aacedd","html_url":"https://github.com/cuppett/mysql-dba-operator","commit_stats":{"total_commits":251,"total_committers":4,"mean_commits":62.75,"dds":"0.43426294820717126","last_synced_commit":"bf388090730c770cf0cd36fcd329413d1d7e38fe"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cuppett%2Fmysql-dba-operator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cuppett%2Fmysql-dba-operator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cuppett%2Fmysql-dba-operator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cuppett%2Fmysql-dba-operator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cuppett","download_url":"https://codeload.github.com/cuppett/mysql-dba-operator/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221832478,"owners_count":16888257,"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":["database","dba","kubernetes","mysql","sql"],"created_at":"2024-10-15T14:12:01.063Z","updated_at":"2024-10-28T13:35:03.271Z","avatar_url":"https://github.com/cuppett.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MySQL DBA Operator\n\nThis operator does **not** provision MySQL database servers.\nIt works against and within existing database servers.\nIt helps user applications by allowing provisioning of individual\ndatabases and database users inside an existing MySQL database server.\n\n## Types\n\n### AdminConnection\n\nDatabase servers can be provisioned separately and then made available\nfor use with this operator by defining an \u003ccode\u003eAdminConnection\u003c/code\u003e.\n\u003ccode\u003eAdminConnection\u003c/code\u003e resources can be created in any namespace \nseparate from user applications.\n\nSample:\n\n\u003cpre\u003e\napiVersion: mysql.apps.cuppett.dev/v1alpha1\nkind: AdminConnection\nmetadata:\n  name: db1\n  namespace: cuppett\nspec:\n  host: 172.25.234.155.nip.io\n  adminPassword:\n    secretKeyRef:\n      name: mysql\n      key: database-root-password\n  allowedNamespaces:\n    - tenant1\n    - openshift-*\n    - blog-*\n\u003c/pre\u003e\n\n\u003ccode\u003eadminUser\u003c/code\u003e can be defined similarly to \u003ccode\u003eadminPassword\u003c/code\u003e.\nThe default username is 'root' and the default password is an empty string.\n\u003ccode\u003ehost\u003c/code\u003e is required to be a valid hostname.\n\n\u003ccode\u003eallowedNamespaces\u003c/code\u003e is there to enable usage of the admin connection for provisioning only where desired.\nBy default, only the namespace containing the \u003ccode\u003eAdminConnection\u003c/code\u003e is permitted (and does not need specified).\nAllows specifying prefix by adding a trailing '*' character (e.g. blog-*).\n\nWith each \u003ccode\u003eAdminConnection\u003c/code\u003e an administrative database is created and updated to track the objects\nprovisioned with this operator.\nThis database helps ensure that unique UID, name and namespace databases are created and that those previously\nexisting or provisioned in other namespaces are not overridden, commandeered or inadvertently removed.\n\nThe following tables are created and updated as objects are created/destroyed:\n\n\u003cpre\u003e\nmysql\u003e describe zz_dba_operator.managed_databases;\n+---------------+-------------+------+-----+---------+-------+\n| Field         | Type        | Null | Key | Default | Extra |\n+---------------+-------------+------+-----+---------+-------+\n| uuid          | varchar(36) | NO   | PRI | NULL    |       |\n| namespace     | varchar(64) | YES  |     | NULL    |       |\n| name          | varchar(64) | YES  |     | NULL    |       |\n| database_name | varchar(64) | YES  |     | NULL    |       |\n| created_at    | datetime(3) | YES  |     | NULL    |       |\n| updated_at    | datetime(3) | YES  |     | NULL    |       |\n+---------------+-------------+------+-----+---------+-------+\n6 rows in set (0.00 sec)\n\nmysql\u003e describe zz_dba_operator.managed_users;\n+------------+-------------+------+-----+---------+-------+\n| Field      | Type        | Null | Key | Default | Extra |\n+------------+-------------+------+-----+---------+-------+\n| uuid       | varchar(36) | NO   | PRI | NULL    |       |\n| namespace  | varchar(64) | YES  |     | NULL    |       |\n| name       | varchar(64) | YES  |     | NULL    |       |\n| username   | varchar(32) | YES  |     | NULL    |       |\n| created_at | datetime(3) | YES  |     | NULL    |       |\n| updated_at | datetime(3) | YES  |     | NULL    |       |\n+------------+-------------+------+-----+---------+-------+\n6 rows in set (0.00 sec)\n\u003c/pre\u003e\n\n### Database\n\nOnce you have an \u003ccode\u003eAdminConnection\u003c/code\u003e resource, you can create a \u003ccode\u003eDatabase\u003c/code\u003e\nresource. Creating a new \u003ccode\u003eDatabase\u003c/code\u003e resource effectively triggers a \u003csql\u003eCREATE DATABASE\u003c/sql\u003e \nagainst the server to match the specification in your custom resource.\n\nSample:\n\n\u003cpre\u003e\napiVersion: mysql.apps.cuppett.dev/v1alpha1\nkind: Database\nmetadata:\n  name: mydb\n  namespace: customer-ns\nspec:\n  adminConnection:\n    namespace: cuppett /* Optional */\n    name: db1\n  name: mydb\n  characterSet: utf8\n  collate: utf8_general_ci\n\u003c/pre\u003e\n\nModifications to either \u003ccode\u003echaracterSet\u003c/code\u003e or \u003ccode\u003ecollate\u003c/code\u003e trigger\nchanges to the database defaults. \nUpdates to \u003ccode\u003ename\u003c/code\u003e are rejected by a\nvalidating webhook. \n\n### DatabaseUser\n\nFinally, you can create a \u003ccode\u003eDatabaseUser\u003c/code\u003e resource to programmatically create\nusers and control a few attributes and permissions for the user. \nThis object used to drive \u003csql\u003eCREATE USER\u003c/sql\u003e and \u003csql\u003eALTER USER\u003c/sql\u003e operations within\nthe database.\n\nSample:\n\u003cpre\u003e\napiVersion: mysql.apps.cuppett.dev/v1alpha1\nkind: DatabaseUser\nmetadata:\n  name: cuppett\n  namespace: customer-ns\nspec:\n  adminConnection:\n    namespace: cuppett /* Optional */\n    name: db1\n  username: cuppett\n  identification:\n    authPlugin: ''\n    clearText: true\n    authString:\n      secretKeyRef:\n        name: db-password\n        key: password\n  databasePermissions:\n  - databaseName: mydb\n    grants: /* Optional */\n    - SELECT\n    - INSERT\n    - UPDATE\n    - DELETE\n\u003c/pre\u003e\n\n\u003ccode\u003edatabasePermissions\u003c/code\u003e is a list of \u003ccode\u003eDatabase\u003c/code\u003e object names in the cluster (not names in the database server).\nThis allows for maintaining correct constraints and permission controls via both systems (Kubernetes and MySQL).\n\n\u003e NOTE: Optional \u003ccode\u003eauthString\u003c/code\u003e references a \u003ccode\u003ev1.Secret\u003c/code\u003e created by the user.\nThe \u003ccode\u003ev1.Secret\u003c/code\u003e will have \u003ccode\u003eownerReferences\u003c/code\u003e updated to belong to the operator once consumed.\nThis is to facilitate one-use passwords and automatically clean them up or scrub them when the user is\nremoved/dropped.\n\n## Development \u0026 Testing\n\n### Prerequisites\n\n* [Operator SDK](https://sdk.operatorframework.io/docs/installation/)\n* [Kustomize](https://kubectl.docs.kubernetes.io/installation/kustomize/)\n* [Testcontainers for Go](https://golang.testcontainers.org/)\n* [Docker](https://docs.docker.com/get-docker/) -or- [Podman](https://podman.io/getting-started/installation)\n\n### Testing\n\nEnsure you've installed the prerequisites above.\n\n```bash\nmake test\n```\n\n### Lineage\n\nOperator originally built using [Operator SDK 1.3.0](https://v1-3-x.sdk.operatorframework.io/)\u003cbr /\u003e\nOperator currently built using [Operator SDK 1.32.0](https://v1-29-x.sdk.operatorframework.io/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcuppett%2Fmysql-dba-operator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcuppett%2Fmysql-dba-operator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcuppett%2Fmysql-dba-operator/lists"}