generated from cybozu-go/neco-template
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update documents and prepare for a new release
- Loading branch information
Showing
30 changed files
with
697 additions
and
380 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# How to develop MOCO | ||
|
||
## Running tests | ||
|
||
MOCO has the following 4 kinds of tests: | ||
|
||
1. Tests that do not depend on MySQL or Kubernetes | ||
2. `pkg/dbop` tests that depend on MySQL version | ||
3. Tests that depend on Kubernetes and therefore run by controller-runtime's envtest | ||
4. End-to-end tests | ||
|
||
To run these tests, use the following make targets respectively: | ||
|
||
1. `make test` | ||
2. `make test-dbop` | ||
3. `make envtest` | ||
4. Read [`e2e/README.md`](e2e/README.md) | ||
|
||
## Generated files | ||
|
||
Some files in the repository are auto-generated. | ||
|
||
- [`docs/crd_mysqlcluster.md`](docs/crd_mysqlcluster.md) is generated by `make apidoc`. | ||
- Some files under `config` are generated by `make manifests`. | ||
- `api/**/*.deepcopy.go` are generated by `make generate`. | ||
|
||
CI checks and fails if they need to be rebuilt. | ||
|
||
## Testing with unreleased moco-agent | ||
|
||
MOCO depends on [moco-agent][] that is released from a different repository. | ||
The dependency is therefore managed in `go.mod` file. | ||
|
||
To run e2e tests with an unreleased moco-agent, follow the instructions in | ||
[`e2e/README.md`](e2e/README.md). | ||
|
||
## Updating moco-agent | ||
|
||
Run `go get github.com/cybozu-go/moco-agent@latest`. | ||
|
||
## Updating fluent-bit | ||
|
||
Edit `FluentBitImage` in [`version.go`](versoin.go). | ||
|
||
[moco-agent]: https://github.com/cybozu-go/moco-agent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,117 @@ | ||
[![GitHub release](https://img.shields.io/github/release/cybozu-go/moco.svg?maxAge=60)][releases] | ||
[![CircleCI](https://circleci.com/gh/cybozu-go/moco.svg?style=svg)](https://circleci.com/gh/cybozu-go/moco) | ||
[![CI](https://github.com/cybozu-go/moco/actions/workflows/ci.yaml/badge.svg)](https://github.com/cybozu-go/moco/actions/workflows/ci.yaml) | ||
[![PkgGoDev](https://pkg.go.dev/badge/github.com/cybozu-go/moco)](https://pkg.go.dev/github.com/cybozu-go/moco) | ||
[![Go Report Card](https://goreportcard.com/badge/github.com/cybozu-go/moco)](https://goreportcard.com/report/github.com/cybozu-go/moco) | ||
|
||
# MOCO | ||
|
||
MOCO is a Kubernetes operator for MySQL. | ||
Its primary function is to manage a cluster of MySQL using binlog-based, semi-synchronous replication. | ||
MOCO is a Kubernetes operator for [MySQL][]. | ||
Its primary function is to manage MySQL clusters using [GTID-based](https://dev.mysql.com/doc/refman/8.0/en/replication-gtids.html) [semi-synchronous](https://dev.mysql.com/doc/refman/8.0/en/replication-semisync.html) replication. It does _not_ manage [group replication](https://dev.mysql.com/doc/refman/8.0/en/group-replication.html) clusters. | ||
|
||
MOCO is designed for the following properties: | ||
MOCO is designed to have the following properties. | ||
|
||
- Durability | ||
- Do not lose any data under a given degree of faults. | ||
- Compatibility with the standard MySQL | ||
- This is the reason that MOCO does not adopt group replication that has [a number of limitations](https://dev.mysql.com/doc/refman/8.0/en/group-replication-limitations.html). | ||
- Safety | ||
- MOCO only allows writes to a single instance called the primary at a time. | ||
- MOCO configures loss-less semi-synchronous replication with sufficient replicas. | ||
- MOCO detects and excludes instances having [errant transactions](https://www.percona.com/blog/2014/05/19/errant-transactions-major-hurdle-for-gtid-based-failover-in-mysql-5-6/). | ||
- Availability | ||
- Keep the MySQL cluster available under a given degree of faults. | ||
- Business Continuity | ||
- Perform a quick recovery if some failure is occurred. | ||
- MOCO can quickly switch the primary in case of the primary failure or restart. | ||
- MOCO allows up to 5 instances in a cluster. | ||
|
||
## Features | ||
|
||
TBD | ||
## Supported software | ||
|
||
## Supported MySQL versions | ||
- MySQL: 8.0.18, 8.0.20, and 8.0.24 | ||
- Kubernetes: 1.19 and 1.20 | ||
|
||
8.0.18 and 8.0.20 | ||
Other versions may work, though not tested. | ||
|
||
## Supported Kubernetes version | ||
## Features | ||
|
||
1.20 and 1.19 | ||
- Cluster of 1, 3, or 5 MySQL instances | ||
- Replication from an external MySQL instance | ||
- Manual and automatic switchover of the primary instance | ||
- Automatic failover of the primary instance | ||
- Errant transaction detection | ||
- Different MySQL versions for each cluster | ||
- Upgrading MySQL version of a cluster | ||
- Monitor for replication delays | ||
- Service for the primary and replicas, respectively | ||
- Custom `my.cnf` configurations | ||
- Custom Pod, Service, and PersistentVolumeClaim templates | ||
- Redirect slow query logs to a sidecar container | ||
- (planning) Backup and [Point-in-Time Recovery](https://dev.mysql.com/doc/refman/8.0/en/point-in-time-recovery-positions.html) | ||
|
||
## Quick start | ||
|
||
You can quickly run MOCO using [kind](https://kind.sigs.k8s.io/). | ||
|
||
1. Prepare a Linux machine and install Docker. | ||
2. Checkout MOCO and go to `e2e` directory. | ||
3. Run `make start` | ||
|
||
You can then create a three-instance MySQL cluster as follows: | ||
|
||
```console | ||
$ cat > mycluster.yaml <<'EOF' | ||
apiVersion: moco.cybozu.com/v1beta1 | ||
kind: MySQLCluster | ||
metadata: | ||
namespace: default | ||
name: test | ||
spec: | ||
replicas: 3 | ||
podTemplate: | ||
spec: | ||
containers: | ||
- name: mysqld | ||
image: quay.io/cybozu/moco-mysql:8.0.24 | ||
volumeClaimTemplates: | ||
- metadata: | ||
name: mysql-data | ||
spec: | ||
accessModes: [ "ReadWriteOnce" ] | ||
resources: | ||
requests: | ||
storage: 1Gi | ||
EOF | ||
|
||
$ export KUBECONFIG=$(pwd)/.kubeconfig | ||
$ ../bin/kubectl apply -f mycluster.yaml | ||
``` | ||
|
||
Check the status of MySQLCluster until it becomes healthy as follows: | ||
|
||
```console | ||
$ ../bin/kubectl get mysqlcluster test | ||
NAME AVAILABLE HEALTHY PRIMARY SYNCED REPLICAS ERRANT REPLICAS | ||
test True True 0 3 | ||
``` | ||
|
||
Once it becomes healthy, you can use `kubectl-moco` to play with `mysql` client. | ||
|
||
```console | ||
$ ../bin/kubectl moco mysql -it test | ||
``` | ||
|
||
To destroy the Kubernetes cluster, run: | ||
|
||
```console | ||
$ make stop | ||
``` | ||
|
||
## Documentation | ||
|
||
[docs](docs/) directory contains documents about designs and specifications. | ||
- [`docs/setup.md`](docs/setup.md) for installing MOCO. | ||
- [`docs/usage.md`](docs/usage.md) is the user manual of MOCO. | ||
- [`examples`](examples/) directory contains example MySQLCluster manifests. | ||
|
||
## Docker images | ||
|
||
Docker images are available on [Quay.io](https://quay.io/repository/cybozu/moco) | ||
[`docs`](docs/) directory also contains other design or specification documents. | ||
|
||
## License | ||
## Docker images | ||
|
||
MOCO is licensed under MIT license. | ||
Docker images are available on [ghcr.io/cybozu-go/moco](https://github.com/orgs/cybozu-go/packages/container/package/moco). | ||
|
||
[releases]: https://github.com/cybozu-go/moco/releases | ||
[godoc]: https://godoc.org/github.com/cybozu-go/moco | ||
[MySQL]: https://www.mysql.com/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.