• Stars
    star
    246
  • Rank 164,726 (Top 4 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created over 4 years ago
  • Updated 9 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

MySQL operator on Kubernetes using GTID-based semi-synchronous replication.

GitHub release CI PkgGoDev Go Report Card

MOCO

moco logo

MOCO is a MySQL operator on Kubernetes. Its primary function is to manage MySQL clusters using GTID-based semi-synchronous replication. It does not manage group replication clusters.

MOCO is designed to have the following properties.

  • Compatibility with the standard MySQL
  • 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.
  • Availability
    • MOCO can quickly switch the primary in case of the primary failure or restart.
    • MOCO allows up to 5 instances in a cluster.

Blog article: Introducing MOCO, a modern MySQL operator on Kubernetes

Supported software

  • MySQL: 8.0.18, 8.0.25, 8.0.26, 8.0.27, 8.0.28, 8.0.30, 8.0.31, 8.0.32
  • Kubernetes: 1.25, 1.26, 1.27

Other MySQL 8 releases would probably work. They are simply not tested in our CI.

Features

  • Cluster with odd number of MySQL instances
  • kubectl plugin
  • Replication from an external MySQL instance
  • Manual and automatic switchover of the primary instance
  • Automatic failover of the primary instance
  • Backup and Point-in-Time Recovery
  • Errant transaction detection
  • Different MySQL versions for each cluster
  • Upgrading MySQL version of a cluster
  • Monitor for replication delays
  • Built-in mysqld_exporter for mysqld metrics
  • Services for the primary and replicas, respectively
  • Custom my.cnf configurations
  • Custom Pod, Service, and PersistentVolumeClaim templates
  • Redirect slow query logs to a sidecar container
  • Auto-generate PodDisruptionBudget

Quick start

You can quickly run MOCO using kind.

  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:

$ 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/mysql:8.0.30
  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:

$ ../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.

$ ../bin/kubectl moco mysql -it test

To destroy the Kubernetes cluster, run:

$ make stop

Documentation

See https://cybozu-go.github.io/moco/

examples directory contains example MySQLCluster manifests.

Docker images

Docker images are available on ghcr.io/cybozu-go/moco.

More Repositories

1

transocks

Transparent SOCKS5 / HTTP proxy in Go
Go
465
star
2

neco

Project Neco
Go
241
star
3

cke

Cybozu Kubernetes Engine
Go
193
star
4

coil

CNI plugin for Kubernetes designed for scalability and extensibility
Go
164
star
5

usocksd

SOCKS4/5 server library and command in Go
Go
142
star
6

well

Go framework for well-behaving commands
Go
125
star
7

goma

An extensible monitoring agent in Go.
Go
124
star
8

aptutil

Go utilities for Debian APT repositories
Go
123
star
9

sabakan

A versatile network boot server for large data centers
Go
122
star
10

placemat

Virtual data center construction tool
Go
82
star
11

etcdpasswd

Distributed Linux user management using etcd
Go
46
star
12

accurate

Kubernetes controller for multi-tenancy. It propagates resources between namespaces accurately and allows tenant users to create/delete sub-namespaces.
Go
28
star
13

log

Logging framework for Cybozu Go products
Go
28
star
14

contour-plus

Enhance contour for external-dns and cert-manager
Go
25
star
15

meows

Kubernetes controller for GitHub actions self-hosted runners
Go
19
star
16

netutil

Add-ons for Go networking
Go
17
star
17

kkok

Alert routing and filtering service
Go
10
star
18

scim

generic SCIM server/client library in Go
Go
7
star
19

options

A small library that provides Option[T], which represents an optional value of type T
Go
5
star
20

cat-gate

A Kubernetes controller to delay pod deployment using scheduling gates
Go
5
star
21

setup-hw

Build container image to configure BMC and BIOS
Go
5
star
22

nginx-i2c

ip2country.conf generation tool for nginx
Go
4
star
23

scim-server

Go
4
star
24

pod-security-admission

A Kubernetes admission webhook to ensure pod security standards
Go
4
star
25

nyamber

Custom controllers to create Neco environment
Go
1
star
26

neco-template

Template repository for Neco
Makefile
1
star
27

neco-gcp

GCP management tools for project Neco
Go
1
star
28

necotiator

ResourceQuota Controller for soft multi-tenancy
Go
1
star
29

etcdutil

Add-ons for etcd
Go
1
star
30

cattage

Kubernetes controller that enhances the multi-tenancy of Argo CD with Accurate.
Go
1
star
31

tenet

Tenet is a Kubernetes controller that aims to facilitate setting-up Network Policies on tenant namespaces.
Go
1
star
32

necoperf

necoperf provides the ability to easily retrieve profiles of containers running on Kubernetes.
Go
1
star
33

zombie-detector

Go
1
star