• Stars
    star
    767
  • Rank 59,242 (Top 2 %)
  • Language
    Python
  • License
    Other
  • Created over 3 years ago
  • Updated about 1 month ago

Reviews

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

Repository Details

MySQL Operator for Kubernetes

MySQL Operator for Kubernetes

Introduction

The MySQL Operator for Kubernetes is an operator for managing MySQL InnoDB Cluster setups inside a Kubernetes Cluster. It manages the full lifecycle with set up and maintenance that includes automating upgrades and backup.

MySQL Operator for Kubernetes is brought to you by the MySQL team at Oracle.

Issues and Pull Requests

As with all MySQL projects, issues (including bugs and feature requests) are tracked here:

Pull requests submitted via github are also tracked at bugs.mysql.com; see CONTRIBUTING for related information.

License

Copyright (c) 2020, 2023, Oracle and/or its affiliates.

License information can be found in the LICENSE file. This distribution may include materials developed by third parties. For license and attribution notices for these materials, please refer to the LICENSE file.

MySQL Operator for Kubernetes Installation

Using Manifest Files with kubectl

First deploy the Custom Resource Definition (CRDs):

$> kubectl apply -f https://raw.githubusercontent.com/mysql/mysql-operator/trunk/deploy/deploy-crds.yaml

Then deploy MySQL Operator for Kubernetes:

$> kubectl apply -f https://raw.githubusercontent.com/mysql/mysql-operator/trunk/deploy/deploy-operator.yaml

Verify the operator is running by checking the deployment inside the mysql-operator namespace:

$> kubectl get deployment -n mysql-operator mysql-operator

NAME             READY   UP-TO-DATE   AVAILABLE   AGE
mysql-operator   1/1     1            1           1h

Using Helm

Alternatively, you may use Helm; which is a package manager for Kubernetes.

Install the Helm repository:

$> helm repo add mysql-operator https://mysql.github.io/mysql-operator/
$> helm repo update

Then deploy the operator:

$> helm install mysql-operator mysql-operator/mysql-operator --namespace mysql-operator --create-namespace

This deploys the latest MySQL Operator for Kubernetes from DockerHub using all defaults; although the deployment can be customized through a variety of options to override built-in defaults. See the documentation for details.

MySQL InnoDB Cluster Installation

Using kubectl

For creating a MySQL InnoDB Cluster, first create a secret with credentials for a MySQL root user used to perform administrative tasks in the cluster. For example:

$> kubectl create secret generic mypwds \
        --from-literal=rootUser=root \
        --from-literal=rootHost=% \
        --from-literal=rootPassword="sakila"

Define your MySQL InnoDB Cluster, which references the secret. For example:

apiVersion: mysql.oracle.com/v2
kind: InnoDBCluster
metadata:
  name: mycluster
spec:
  secretName: mypwds
  tlsUseSelfSigned: true
  instances: 3
  router:
    instances: 1

Assuming it's saved as mycluster.yaml, deploy it:

$> kubectl apply -f mycluster.yaml

This sample creates an InnoDB Cluster with three MySQL Server instances and one MySQL Router instance. The process can be observed using:

$> kubectl get innodbcluster --watch

NAME          STATUS    ONLINE   INSTANCES   ROUTERS   AGE
mycluster     PENDING   0        3           1         2m6s
...
mycluster     ONLINE    3        3           1         10s

Using Helm

Create MySQL InnoDB Cluster installations using defaults or with customization. Here's an example using all defaults for a cluster named mycluster:

$> helm install mycluster mysql-operator/mysql-innodbcluster

Or customize, this example sets options from the command line:

$> helm install mycluster mysql-operator/mysql-innodbcluster \
        --namespace mynamespace \
        --create-namespace \
        --set credentials.root.user='root' \
        --set credentials.root.password='supersecret' \
        --set credentials.root.host='%' \
        --set serverInstances=3 \
        --set routerInstances=1

Connecting to MySQL InnoDB Cluster

A MySQL InnoDB Cluster Service is created inside the Kubernetes cluster:

$> kubectl get service mycluster

NAME        TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)                                                  AGE
mycluster   ClusterIP   10.110.228.51   <none>        3306/TCP,33060/TCP,6446/TCP,6448/TCP,6447/TCP,6449/TCP   26h

The ports represent read-write and read-only ports for the MySQL Protocol and the X Protocol. Use describe or see the documentation for additional information.

Using MySQL Shell

This example creates a new container named myshell using the container-registry.oracle.com/mysql/community-operator image, and immediately executes MySQL Shell:

$> kubectl run --rm -it myshell --image=container-registry.oracle.com/mysql/community-operator -- mysqlsh
If you don't see a command prompt, try pressing enter.

MySQL JS>  \connect root@mycluster

Creating a session to 'root@mycluster'
Please provide the password for 'root@mycluster': ******

MySQL mycluster JS>

Using root@mycluster connection assumes the default namespace is used; the long form is {innodbclustername}.{namespace}.svc.cluster.local. Each MySQL instance has MySQL Shell installed that can be used when troubleshooting.

Using Port Forwarding

Kubernetes port forwarding creates a redirection from your local machine to use a MySQL client, such as mysql or MySQL Workbench. For example, for read-write connection to the primary using the MySQL protocol:

$> kubectl port-forward service/mycluster mysql

Forwarding from 127.0.0.1:3306 -> 6446
Forwarding from [::1]:3306 -> 6446

And in a second terminal:

$> mysql -h127.0.0.1 -P3306 -uroot -p

Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
...

When prompted, enter the password used when creating the Secret.

More Information

Refer to the official documentation at:

For additional downloads and the source code, visit:

Contributing to MySQL Operator for Kubernetes, see:

More Repositories

1

mysql-server

MySQL Server, the world's most popular open source database, and MySQL Cluster, a real-time, open source transactional database.
C++
10,830
star
2

mysql-connector-j

MySQL Connector/J
Java
908
star
3

mysql-workbench

MySQL Workbench is a unified visual tool for database architects, developers, and DBAs. MySQL Workbench provides data modeling, SQL development, and comprehensive administration tools for server configuration, user administration, backup, and much more.
C++
898
star
4

mysql-connector-python

MySQL Connector/Python is implementing the MySQL Client/Server protocol completely in Python. No MySQL libraries are needed, and no compilation is necessary to run this Python DB API v2.0 compliant driver. Documentation & Download: http://dev.mysql.com/doc/connector-python/en
Python
876
star
5

mysql-sys

The MySQL sys schema
PLpgSQL
828
star
6

mysql-connector-cpp

MySQL Connector/C++ is a MySQL database connector for C++. It lets you develop C++ and C applications that connect to MySQL Server.
C++
634
star
7

mysql-proxy

MySQL Proxy is a simple program that sits between your client and MySQL server(s) and that can monitor, analyze or transform their communication. Its flexibility allows for a wide variety of uses, including load balancing, failover, query analysis, query filtering and modification, and many more.
C
420
star
8

mysql-connector-net

Connector/NET is a fully-managed ADO.NET driver for MySQL.
C#
291
star
9

mysql-utilities

MySQL Utilities is a set of easy-to-use scripts intended to make working with MySQL servers easier.
Python
267
star
10

mysql-shell

MySQL Shell is a new command line scriptable shell for MySQL. It supports JavaScript and Python.
C++
193
star
11

mysql-js

NoSQL node.js connector for MySQL Cluster
JavaScript
170
star
12

mysql-connector-nodejs

MySQL Connector Node.JS is a MySQL Connector using the X Protocol, which was introduced with MySQL 5.7.12.
JavaScript
154
star
13

mysql-router

MySQL Router is lightweight middleware that provides transparent routing between your application and any backend MySQL Servers.
C++
150
star
14

mysql-connector-odbc

This is the source for MySQL Connector/ODBC (myodbc), an ODBC (3.51) driver for connecting an ODBC-aware application to the MySQL Server.
C++
92
star
15

mysql-shell-plugins

Plugins for the MySQL Shell
TypeScript
73
star
16

mysql-for-excel

MySQL for Excel is an Excel Add-In that is installed and accessed from within the MS Excel Data tab offering a wizard-like interface arranged in an elegant,yet simple way to help users browse MySQL Schemas, Tables, Views, and Procedures and perform data operations against them using MS Excel as the vehicle to drive the data in and out MySQL Databases.
C#
65
star
17

mysql-for-vs

MySQL for Visual Studio provides access to MySQL objects and data without forcing your developers to leave Visual Studio. Designed and developed as a Visual Studio package, MySQL for Visual Studio integrates directly into Server Explorer providing a seamless experience for setting up new connections and working with database objects.
C#
36
star
18

mysql-ndb-operator

Kubernetes Operator for MySQL NDB Cluster.
Go
35
star
19

mysql-notifier

MySQL Notifier is a small utility that can keep watch over your Windows and MySQL services, notifying you of changes in their operation. Notifier is intended to run when Windows starts up and sits in the tray notification area watching the MySQL and Windows services you have configured.
C#
19
star
20

mysql-snap

Source files for building Ubuntu Snap images
Shell
13
star
21

mysql-configurator

MySQL Configurator
C#
5
star