• Stars
    star
    147
  • Rank 251,277 (Top 5 %)
  • Language
  • License
    Apache License 2.0
  • Created about 8 years ago
  • Updated about 1 year ago

Reviews

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

Repository Details

The simplest SQL cluster that could possibly work

MySQL with automatic failover on Kubernetes

This is a galera cluster setup, with plain manifests. We actually use it in production, though with modest loads.

Get started

First create a storage class mysql-data. See exampels in ./configure/. You might also want to edit the volume size request, at the bottom of ./50mariadb.yml.

Then: kubectl apply -f ..

Cluster Health

Readiness and liveness probes will only assert client-level health of individual pods. Watch logs for "sst" or "Quorum results", or run this quick check:

for i in 0 1 2; do kubectl -n mysql exec mariadb-$i -- mysql -e "SHOW STATUS LIKE 'wsrep_cluster_size';" -N; done

Port 9104 exposes plaintext metris in Prometheus scrape format.

# with kubectl -n mysql port-forward mariadb-0 9104:9104
$ curl -s http://localhost:9104/metrics | grep ^mysql_global_status_wsrep_cluster_size
mysql_global_status_wsrep_cluster_size 3

A reasonable alert is on mysql_global_status_wsrep_cluster_size staying below the desired number of replicas.

Cluster un-health

We need to assume a couple of things here. First and foremost: Production clusters are configured so that the statefulset pods do not go down together.

  • Pods are properly spread across nodes.
  • Nodes are spread across multiple availability zones.

Let's also assume that there is monitoring. Any wsrep_cluster_size issue (see above), or absence of wsrep_cluster_size should lead to a human being paged.

Rarity combined with manual attention means that this statefulset can/should avoid attempts at automatic recovery. The reason for that being: we can't test for failure modes properly, as they depend on the Kubernetes setup. Automation may appoint the wrong leader - losing writes - or cause split-brain situations.

We can however support detection in the init script.

It's normal operations to scale down to two instances

  • actually one instance, but nodes should be considered ephemeral so don't do that - and up to any number of replicas.

phpMyAdmin

Carefully consider the security implications before you create this. Note that it uses a non-official image.

kubectl apply -f myadmin/

PhpMyAdmin has a login page where you need a mysql user. To allow login (with full access) create a user with your choice of password:

kubectl -n mysql exec mariadb-0 -- mysql -e "CREATE USER 'phpmyadmin'@'%' IDENTIFIED BY 'my-admin-pw'; GRANT ALL ON *.* TO 'phpmyadmin'@'%' WITH GRANT OPTION;"

More Repositories

1

kubernetes-kafka

Kafka cluster as Kubernetes StatefulSet, plain manifests and config
Shell
1,804
star
2

youkube

Kubernetes locally using kubeadm and https://github.com/coreos/coreos-vagrant
Shell
11
star
3

kubeadm-vagrant

Multi-node unopinionated Kubernetes setup locally
Shell
9
star
4

kubernetes-assert

JavaScript
8
star
5

kubernetes-registry

Tries to track what's going on with https://github.com/kubernetes/kubernetes/tree/master/cluster/addons/registry, and avoid dependency on gcr.io
Makefile
8
star
6

ystack

Kubernetes platform-as-a-platform
Shell
7
star
7

kafka-cache

Explorations for the log-backed in-memory cache we need in almost every service
JavaScript
6
star
8

confluent-quickstart-kubernetes

Abandoned in favor of https://github.com/Yolean/kubernetes-kafka/pull/45
6
star
9

kubernetes-minio

Minio on Kubernetes using Kustomize
5
star
10

kafka-keyvalue

The sequel to https://github.com/Yolean/kafka-cache - over HTTP this time
Java
3
star
11

docker-base

Because pull time matters with ephemeral nodes
Dockerfile
3
star
12

kafka-hook

HTTP to Kafka, a webhook endpoint that tries to represent every event with context
Java
3
star
13

keycloak-stats

A /varz REST endpoint that returns session count for the realms in keycloak
JavaScript
3
star
14

kafka-topic-client

Create Kafka topics remotely
Java
3
star
15

quarkus-javet

Quarkus Javet extension, see https://github.com/caoccao/Javet/issues/107
Java
2
star
16

kubernetes-keycloakx

Transition to Keycloak.X from Keycloak.big-footprint on Kubernetes
Shell
2
star
17

kube-test

2
star
18

kafka-topics-copy

Copy Kafka topics within your existing Kafka Cluster.
Shell
2
star
19

kubernetes-requestbin

2
star
20

kubernetes-job-to-cronjob

Because CronJob is one yaml "spec:" level too far
2
star
21

kafka-keyvalue-nodejs

TypeScript
2
star
22

kafka-test-failover

A test utility for https://github.com/Yolean/kubernetes-kafka/pull/78
Java
1
star
23

kafka-keyvalue-demo

JavaScript
1
star
24

kubernetes-git-cluster

Bare git hosting with sufficiently high availability for use as gitRepo volumes in other pods
Shell
1
star
25

promparse

A crappy lib, but it explores Deno && Node compatibility
TypeScript
1
star
26

grafana-dashboards

Ops dashboards in addition to those from kubernetes-mixin
JavaScript
1
star
27

yolean.github.io

HTML
1
star
28

kube-backup

Experiments with kubectl get --export to pull relevant parts of Etcd state to version control
Shell
1
star
29

knative-test

Knative was just irresistible
Shell
1
star
30

javet-quarkus

Experiments with Javet and Quarkus native builds
HTML
1
star
31

build-contract

CI-neutral build+test definitions using docker-compose
JavaScript
1
star