{"id":13742479,"url":"https://github.com/grtl/mysql-operator","last_synced_at":"2025-05-09T00:31:34.769Z","repository":{"id":40533529,"uuid":"108867500","full_name":"grtl/mysql-operator","owner":"grtl","description":"Kubernetes Custom Resource for MySQL","archived":false,"fork":false,"pushed_at":"2018-12-12T11:08:51.000Z","size":29538,"stargazers_count":54,"open_issues_count":14,"forks_count":8,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-03-04T21:38:11.119Z","etag":null,"topics":["kubernetes","kubernetes-cluster","kubernetes-operator","mysql","mysql-operator"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/grtl.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-10-30T15:07:46.000Z","updated_at":"2024-11-08T12:03:47.000Z","dependencies_parsed_at":"2022-06-30T01:04:15.149Z","dependency_job_id":null,"html_url":"https://github.com/grtl/mysql-operator","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grtl%2Fmysql-operator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grtl%2Fmysql-operator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grtl%2Fmysql-operator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grtl%2Fmysql-operator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/grtl","download_url":"https://codeload.github.com/grtl/mysql-operator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253170944,"owners_count":21865273,"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":["kubernetes","kubernetes-cluster","kubernetes-operator","mysql","mysql-operator"],"created_at":"2024-08-03T05:00:32.735Z","updated_at":"2025-05-09T00:31:29.756Z","avatar_url":"https://github.com/grtl.png","language":"Go","funding_links":[],"categories":["Repository is obsolete"],"sub_categories":["Awesome Operators in the Wild"],"readme":"# MySQL Operator\nKubernetes Custom Resource for MySQL.\n\n[![Build Status](https://travis-ci.org/grtl/mysql-operator.svg?branch=master)](https://travis-ci.org/grtl/mysql-operator)\n[![Coverage Status](https://coveralls.io/repos/github/grtl/mysql-operator/badge.svg?branch=master)](https://coveralls.io/github/grtl/mysql-operator?branch=master)\n[![Go Report Card](https://goreportcard.com/badge/github.com/grtl/mysql-operator)](https://goreportcard.com/report/github.com/grtl/mysql-operator)\n[![GoDoc](https://godoc.org/github.com/grtl/mysql-operator?status.svg)](https://godoc.org/github.com/grtl/mysql-operator)\n\n# Running MySQL Operator\nIn order for the custom resources to be properly processed and an actual MySQL cluster\ndeployed, a running instance of the MySQL Operator is required inside your Kubernetes\ninfrastructure. The operator listens for changes on `MySQLCluster` and `MySQLBackupSchedule`\ncustom resources and creates the appropriate objects.\n\n## As a Kubernetes pod\nThis is the __recommended__ option. MySQL Operator will run as a pod inside your\nKubernetes cluster.\n```bash\nkubectl run mysql-operator --image=grtl/mysql-operator:latest\n```\n\n## As an out-of-cluster binary\nAnother option (suitable for development rather than a production-ready solution)\nis to run the MySQL Operator binary outside of the Kubernetes cluster.\n\n```bash\ngo get -u github.com/grtl/mysql-operator\nmysql-operator -kubeconfig ~/.kube/config\n```\n\nRun code directly (ex. after making changes)\n```bash\ngit clone https://github.com/grtl/mysql-operator \u0026\u0026 cd $_\ngo run -kubeconfig ~/.kube/config\n```\n\n# MySQL Operator Docker image\n## Download from DockerHub\nDownload MySQL Operator image from DockerHub to easily deploy it in your\nKubernetes cluster.\n```bash\ndocker pull grtl/mysql-operator\n```\n## Build yourself\nOr build it yourself\n```bash\nGOOS=linux GOARCH=amd64 go build -o mysql-operator \u0026\u0026 docker build .\n```\n\n# Usage\nMake sure the __operator is up and running__ before creating any custom resources.\nAll resources may be created with standard Kubernetes yaml files.\n\n## Clusters\n### Creating a cluster\nFirst, a Kubernetes _Secret_ containing the database password needs to be created.\n```bash\nkubectl create secret generic my-secret --from-literal=password=\"P4sSw0rD\"\n```\n\nThen you can create a cluster from a yaml file.\n```bash\nkubectl create -f cluster-config.yaml\n```\n\n#### Example `cluster-config.yaml` _(minimal)_\n```yaml\napiVersion: cr.mysqloperator.grtl.github.com/v1\nkind: MySQLCluster\nmetadata:\n  name: \"my-cluster\"\nspec:\n  secret: \"my-secret\"\n```\n\n#### Example `cluster-config.yaml` _(fully customized)_\n```yaml\napiVersion: cr.mysqloperator.grtl.github.com/v1\nkind: MySQLCluster\nmetadata:\n  name: \"my-cluster\"\nspec:\n  secret: \"my-secret\"   # Name of the secret containing the password\n  port: 3306            # Port on which the service will expose the MySQL\n  replicas: 2           # Number of replicas\n  storage: \"1Gi\"        # Persistance Volume Claim size for each replica\n  image: \"mysql:latest\" # MySQL image\n```\n\n### Restoring a cluster from the backup\nWhile creating a cluster its data may be restored from an existing\n[backup instance](#backup-instances). The only difference between the\nconfiguration files for [creating a cluster](#creating-a-cluster) and\nthe one to restore a cluster from backup is an additional field\n`fromBackup` field pointing to the [backup instance](#backup-instances).\n```bash\nkubectl create -f cluster-restore-config.yaml\n```\n\n#### Example `cluster-restore-config.yaml` (minimal)\n```yaml\napiVersion: cr.mysqloperator.grtl.github.com/v1\nkind: MySQLCluster\nmetadata:\n  name: \"my-cluster\"\nspec:\n  secret: \"my-secret\"\n  fromBackup: \"my-backup-2017-12-14-01-22\"\n```\n\n#### Example `cluster-restore-config.yaml` (fully customized)\n```yaml\napiVersion: cr.mysqloperator.grtl.github.com/v1\nkind: MySQLCluster\nmetadata:\n  name: \"my-cluster\"\nspec:\n  secret: \"my-secret\"\n  fromBackup: \"my-backup-2017-12-14-01-22\"\n  port: 3306\n  replicas: 2\n  storage: \"1Gi\"\n  image: \"mysql:latest\"\n```\n\n### Deleting a cluster\nSimply delete the cluster custom resource\n```bash\nkubectl delete mc \"my-cluster\"\n```\n\n## Backup Schedules\n### Creating a backup schedule\nYou can create a backup schedule, which will automatically create backups\naccording to the schedule (cron job style).\n\n```bash\nkubectl create -f backup-config.yaml\n```\n\nExample `backup-config.yaml`\n```yaml\napiVersion: cr.mysqlbackup.grtl.github.com/v1\nkind: MySQLBackup\nmetadata:\n  name: \"my-backup\"\nspec:\n  cluster: \"my-cluster\"\n  time: \"*/5 * * * *\"    # Create a backup every 5 minutes\n```\n\n### Deleting a backup schedule\nSimply delete the backup schedule custom resource\n```bash\nkubectl delete mbs \"my-backup\"\n```\n\n## Backup Instances\nA backup schedule will create backup instances according to the schedule.\n\n### Getting backup instances\nGet all backup instances \n```bash\nkubectl get mbi\n```\nGet all backup instances created within a given backup schedule\n```bash\nkubectl get mbi -l schedule=\"my-backup\"\n```\n\nGet all backup instances created for a given cluster\n```bash\nkubectl get mbi -l cluster=\"my-cluster\"\n```\n\nStandard `kubectl` output for backup instances lacks important fields, for\na valuable output we recommend using output flag with the following configuration.\n```bash\nkubectl get mbi -o custom-columns=\"NAME:metadata.name,STATUS:status.phase,\\\n    SCHEDULE:spec.schedule,CLUSTER:spec.cluster,CREATED:metadata.creationTimestamp\"\n```\nExample output:\n```\nNAME                 STATUS      SCHEDULE       CLUSTER      CREATED\nmy-backup-instance   Completed   my-backup      my-cluster   2018-04-27T14:42:33Z\n```\n\n### Deleting a backup instance\nSimply delete the backup instance custom resource\n```bash\nkubectl delete mbi \"my-backup-instance\"\n```\nBe aware that removing a backup instance will delete its contents from\nthe Persistent Volume.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrtl%2Fmysql-operator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgrtl%2Fmysql-operator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrtl%2Fmysql-operator/lists"}