Skip to content

Commit

Permalink
feat: introduce maxscale
Browse files Browse the repository at this point in the history
With the release of the mariadb operator v0.25.0 maxscale was introduced
to resolve issues with multi-master deployments, enhance scale, and make
better use of nodes in the environment. This change creates the maxscale
resources and converts our standard deployment systems to use maxscale
as the point of ingress.

Specific feature we're interested in

> point to an existing MaxScale instance. Doing this will delegate tasks
  such as primary failover to MaxScale.

Docs: https://github.com/mariadb-operator/mariadb-operator/blob/main/docs/MAXSCALE.md
Related: https://github.com/mariadb-operator/mariadb-operator/releases/tag/v0.0.26
Signed-off-by: Kevin Carter <[email protected]>
  • Loading branch information
cloudnull committed Mar 21, 2024
1 parent d49012c commit f0f4157
Show file tree
Hide file tree
Showing 19 changed files with 179 additions and 38 deletions.
6 changes: 3 additions & 3 deletions docs/infrastructure-mariadb-connect.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
Sometimes an operator may need to connect to the database to troubleshoot things or otherwise make modifications to the databases in place. The following command can be used to connect to the database from a node within the cluster.

``` shell
mysql -h $(kubectl -n openstack get service mariadb-galera-primary -o jsonpath='{.spec.clusterIP}') \
-p$(kubectl --namespace openstack get secret mariadb -o jsonpath='{.data.root-password}' | base64 -d) \
-u root
mysql -h $(kubectl -n openstack get service maxscale-galera -o jsonpath='{.spec.clusterIP}') \
-p$(kubectl --namespace openstack get secret maxscale -o jsonpath='{.data.password}' | base64 -d) \
-u maxscale-galera-client
```

!!! info
Expand Down
16 changes: 16 additions & 0 deletions docs/infrastructure-mariadb.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,19 @@ kubectl --namespace openstack apply -k /opt/genestack/kustomize/mariadb-cluster/
``` shell
kubectl --namespace openstack get mariadbs -w
```

## MaxScale

Within the deployment the OpenStack services use MaxScale for loadlancing and greater reliability. While the MaxScale ecosystem is a good one, there are some limitations that you should be aware of. It is recommended that you review the [MaxScale reference documentation](https://mariadb.com/kb/en/mariadb-maxscale-2302-limitations-and-known-issues-within-mariadb-maxscale) for more about all of the known limitations and potential workarounds available.

``` mermaid
flowchart TD
A[Connection] ---B{MaxScale}
B ---|ro| C[ES-0]
B ---|rw| D[ES-1] ---|sync| E & C
B ---|ro| E[ES-2]
```

### MaxScale GUI

The MaxScale deployment has access to a built in GUI that can be exposed for further debuging and visibility into the performance of the MariDB backend. For more information on accessing the GUI please refer to the MaxScale documentation that can be found [here](https://mariadb.com/resources/blog/getting-started-with-the-mariadb-maxscale-gui).
2 changes: 1 addition & 1 deletion docs/openstack-skyline.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ kubectl --namespace openstack \
--from-literal=service-domain="service" \
--from-literal=service-project="service" \
--from-literal=service-project-domain="service" \
--from-literal=db-endpoint="mariadb-galera-primary.openstack.svc.cluster.local" \
--from-literal=db-endpoint="maxscale-galera.openstack.svc.cluster.local" \
--from-literal=db-name="skyline" \
--from-literal=db-username="skyline" \
--from-literal=db-password="$(< /dev/urandom tr -dc _A-Za-z0-9 | head -c${1:-32};echo;)" \
Expand Down
2 changes: 1 addition & 1 deletion helm-configs/cinder/cinder-helm-overrides.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1320,7 +1320,7 @@ endpoints:
username: cinder
password: password
hosts:
default: mariadb-galera-primary
default: maxscale-galera
host_fqdn_override:
default: null
path: /cinder
Expand Down
2 changes: 1 addition & 1 deletion helm-configs/glance/glance-helm-overrides.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ endpoints:
username: glance
password: password
hosts:
default: mariadb-galera-primary
default: maxscale-galera
host_fqdn_override:
default: null
path: /glance
Expand Down
2 changes: 1 addition & 1 deletion helm-configs/gnocchi/gnocchi-helm-overrides.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ endpoints:
username: gnocchi
password: password
hosts:
default: mariadb-galera-primary
default: maxscale-galera
host_fqdn_override:
default: null
path: /gnocchi
Expand Down
2 changes: 1 addition & 1 deletion helm-configs/heat/heat-helm-overrides.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,7 @@ endpoints:
username: heat
password: password
hosts:
default: mariadb-galera-primary
default: maxscale-galera
host_fqdn_override:
default: null
path: /heat
Expand Down
2 changes: 1 addition & 1 deletion helm-configs/horizon/horizon-helm-overrides.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7242,7 +7242,7 @@ endpoints:
username: horizon
password: password
hosts:
default: mariadb-galera-primary
default: maxscale-galera
host_fqdn_override:
default: null
path: /horizon
Expand Down
2 changes: 1 addition & 1 deletion helm-configs/keystone/keystone-helm-overrides.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -972,7 +972,7 @@ endpoints:
username: keystone
password: password
hosts:
default: mariadb-galera-primary
default: maxscale-galera
host_fqdn_override:
default: null
path: /keystone
Expand Down
2 changes: 1 addition & 1 deletion helm-configs/neutron/neutron-helm-overrides.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2199,7 +2199,7 @@ endpoints:
username: neutron
password: password
hosts:
default: mariadb-galera-primary
default: maxscale-galera
host_fqdn_override:
default: null
path: /neutron
Expand Down
6 changes: 3 additions & 3 deletions helm-configs/nova/nova-helm-overrides.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1640,7 +1640,7 @@ endpoints:
username: nova
password: password
hosts:
default: mariadb-galera-primary
default: maxscale-galera
host_fqdn_override:
default: null
path: /nova
Expand All @@ -1657,7 +1657,7 @@ endpoints:
username: nova
password: password
hosts:
default: mariadb-galera-primary
default: maxscale-galera
host_fqdn_override:
default: null
path: /nova_api
Expand All @@ -1674,7 +1674,7 @@ endpoints:
username: nova
password: password
hosts:
default: mariadb-galera-primary
default: maxscale-galera
host_fqdn_override:
default: null
path: /nova_cell0
Expand Down
2 changes: 1 addition & 1 deletion helm-configs/octavia/octavia-helm-overrides.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ endpoints:
username: octavia
password: password
hosts:
default: mariadb-galera-primary
default: maxscale-galera
host_fqdn_override:
default: null
path: /octavia
Expand Down
2 changes: 1 addition & 1 deletion helm-configs/placement/placement-helm-overrides.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ endpoints:
username: nova
password: password
hosts:
default: mariadb-galera-primary
default: maxscale-galera
host_fqdn_override:
default: null
path: /placement
Expand Down
6 changes: 3 additions & 3 deletions kustomize/grafana/base/grafana-database.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: mariadb.mmontes.io/v1alpha1
apiVersion: k8s.mariadb.com/v1alpha1
kind: Database
metadata:
name: grafana
Expand All @@ -13,7 +13,7 @@ spec:
requeueInterval: 30s
retryInterval: 5s
---
apiVersion: mariadb.mmontes.io/v1alpha1
apiVersion: k8s.mariadb.com/v1alpha1
kind: User
metadata:
name: grafana
Expand All @@ -32,7 +32,7 @@ spec:
requeueInterval: 30s
retryInterval: 5s
---
apiVersion: mariadb.mmontes.io/v1alpha1
apiVersion: k8s.mariadb.com/v1alpha1
kind: Grant
metadata:
name: grant
Expand Down
7 changes: 7 additions & 0 deletions kustomize/mariadb-cluster/aio/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,10 @@ patches:
- op: replace
path: /spec/galera/enabled
value: false
- target:
kind: MaxScale
name: maxscale-galera
patch: |-
- op: replace
path: /spec/replicas
value: 1
1 change: 1 addition & 0 deletions kustomize/mariadb-cluster/base/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
resources:
- mariadb-configmap.yaml
- mariadb-maxscale.yaml
- mariadb-galera.yaml
- mariadb-backup.yaml
19 changes: 2 additions & 17 deletions kustomize/mariadb-cluster/base/mariadb-galera.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,8 @@ spec:
runAsUser: 0

# point to an existing MaxScale instance. Doing this will delegate tasks such as primary failover to MaxScale.
# maxScaleRef:
# name: maxscale

# provision a MaxScale instance and set 'spec.maxScaleRef' automatically.
maxScale:
enabled: false

kubernetesService:
type: LoadBalancer
annotations:
metallb.universe.tf/address-pool: primary

connection:
secretName: mxs-galera-conn
port: 3306
maxScaleRef:
name: maxscale-galera

galera:
enabled: true
Expand Down Expand Up @@ -132,8 +119,6 @@ spec:
resources:
requests:
memory: 256Mi
limits:
memory: 16Gi

metrics:
enabled: true
132 changes: 132 additions & 0 deletions kustomize/mariadb-cluster/base/mariadb-maxscale.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
apiVersion: k8s.mariadb.com/v1alpha1
kind: MaxScale
metadata:
name: maxscale-galera
spec:
replicas: 3

mariaDbRef:
name: mariadb-galera
namespace: openstack

services:
- name: rw-router
router: readwritesplit
params:
transaction_replay: "true"
transaction_replay_attempts: "10"
transaction_replay_timeout: "5s"
max_slave_connections: "255"
max_replication_lag: "3s"
master_accept_reads: "true"
listener:
name: rw-listener
port: 3306
protocol: MariaDBProtocol
params:
connection_metadata: "tx_isolation=auto"
suspend: false
suspend: false
- name: rconn-master-router
router: readconnroute
params:
router_options: "master"
max_replication_lag: "3s"
master_accept_reads: "true"
listener:
port: 3307
- name: rconn-slave-router
router: readconnroute
params:
router_options: "slave"
max_replication_lag: "3s"
listener:
port: 3308

monitor:
name: mariadb-monitor
module: galeramon
interval: 2s
cooperativeMonitoring: majority_of_all
params:
disable_master_failback: "false"
available_when_donor: "false"
disable_master_role_setting: "false"
suspend: false

admin:
port: 8989
guiEnabled: true

config:
params:
log_info: "true"
volumeClaimTemplate:
resources:
requests:
storage: 100Mi
accessModes:
- ReadWriteOnce
storageClassName: general
sync:
database: mysql
interval: 5s
timeout: 10s

auth:
generate: true
adminUsername: mariadb-operator
adminPasswordSecretKeyRef:
name: maxscale
key: password
deleteDefaultAdmin: true
clientUsername: maxscale-galera-client
clientPasswordSecretKeyRef:
name: maxscale
key: password
clientMaxConnections: 1024
serverUsername: maxscale-galera-server
serverPasswordSecretKeyRef:
name: maxscale
key: password
serverMaxConnections: 1024
monitorUsername: maxscale-galera-monitor
monitorPasswordSecretKeyRef:
name: maxscale
key: password
monitorMaxConnections: 128
syncUsername: maxscale-galera-sync
syncPasswordSecretKeyRef:
name: maxscale
key: password
syncMaxConnections: 128

securityContext:
allowPrivilegeEscalation: false

updateStrategy:
type: RollingUpdate

kubernetesService:
type: LoadBalancer
annotations:
metallb.universe.tf/address-pool: primary

connection:
secretName: mxs-galera-conn
port: 3306

resources:
requests:
memory: 128Mi

affinity:
enableAntiAffinity: true

tolerations:
- key: "k8s.mariadb.com/ha"
operator: "Exists"
effect: "NoSchedule"

podDisruptionBudget:
maxUnavailable: 33%
4 changes: 2 additions & 2 deletions kustomize/octavia/base/octavia-agent.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ spec:
- name: PATH
value: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/
- name: DEPENDENCY_SERVICE
value: "openstack:mariadb-galera-primary,openstack:keystone-api,openstack:rabbitmq-nodes,openstack:memcached,openstack:neutron-server"
value: "openstack:maxscale-galera,openstack:keystone-api,openstack:rabbitmq-nodes,openstack:memcached,openstack:neutron-server"
- name: DEPENDENCY_JOBS
value: "octavia-db-sync,octavia-ks-user,octavia-ks-endpoints"
- name: DEPENDENCY_DAEMONSET
Expand Down Expand Up @@ -187,4 +187,4 @@ spec:
secretName: octavia-etc
defaultMode: 0444
- emptyDir: {}
name: pod-run-octavia
name: pod-run-octavia

0 comments on commit f0f4157

Please sign in to comment.