Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,33 @@ namespace/demo created

## Storage Autoscaling of Distributed Cluster Database

At first verify that your clusters have a storage class that supports volume expansion. Let's check,
At first verify that your clusters have a storage class that supports volume expansion. First let's check the storagclass of `Controler` cluster,
```bash
$ kubectl get storageclass --context demo-controller
NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE
local-path (default) rancher.io/local-path Delete WaitForFirstConsumer false 4d
longhorn (default) driver.longhorn.io Delete Immediate true 24h
longhorn-static driver.longhorn.io Delete Immediate true 24h
```
Then check the storageclass of `Worker` cluster,

```bash
$ kubectl get storageclass --context demo-worker
NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE
standard (default) rancher.io/local-path Delete WaitForFirstConsumer false 79m
topolvm-provisioner topolvm.cybozu.com Delete WaitForFirstConsumer true 78m
NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE
local-path (default) rancher.io/local-path Delete WaitForFirstConsumer false 4d
longhorn (default) driver.longhorn.io Delete Immediate true 23h
longhorn-static driver.longhorn.io Delete Immediate true 23h
```

We can see from the output the `topolvm-provisioner` storage class has `ALLOWVOLUMEEXPANSION` field as true. So, this storage class supports volume expansion. We can use it. You can install topolvm from [here](https://github.com/topolvm/topolvm)
We can see from the output the `longhorn (default)` and `longhorn-static` storage class has `ALLOWVOLUMEEXPANSION` field as true. So, this storage class supports volume expansion. We can use it. You can install `longhorn` from [here](https://longhorn.io/docs/1.11.2/deploy/install/)

### Deploy PlacementPolicy

For distributed MariaDB autoscaling, the `PlacementPolicy` must include a `monitoring.prometheus.url` for each spoke cluster. The autoscaler uses these endpoints to monitor storage usage across all clusters where MariaDB pods are running.
For distributed `MariaDB` autoscaling, the PlacementPolicy must define a valid `monitoring.prometheus.url` for each spoke cluster. These endpoints are required by the autoscaler to collect metrics and monitor storage usage across all clusters where MariaDB pods are deployed.

Additionally, it is essential to explicitly specify the storage class for each cluster using `spec.clusterSpreadConstraint.distributionRules.storageClassName`. If this field is not provided, the system will fall back to the default storage class, which may lead to unintended behavior or potential data management risks in a distributed environment.

Below is the YAML of the `PlacementPolicy` that we are going to create. It distributes 4 replicas across two clusters and provides the Prometheus endpoint for each:
Below is the YAML of the `PlacementPolicy` that we are going to create. It distributes 3 replicas across two clusters and provides the Prometheus endpoint for each:

```yaml
apiVersion: apps.k8s.appscode.com/v1
Expand All @@ -74,13 +85,15 @@ spec:
clusterSpreadConstraint:
distributionRules:
- clusterName: demo-controller
storageClassName: local-path
monitoring:
prometheus:
url: http://prometheus-operated.monitoring.svc.cluster.local:9090
replicaIndices:
- 0
- 2
- clusterName: demo-worker
storageClassName: local-path
monitoring:
prometheus:
url: http://prometheus-operated.monitoring.svc.cluster.local:9090
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ This guide will give an overview on how KubeDB Autoscaler operator autoscales th
The following diagram shows how KubeDB Autoscaler operator autoscales the resources of `MariaDB` database components. Open the image in a new tab to see the enlarged version.

<figure align="center">
<img alt="Storage Autoscaling process of MariaDB" src="/docs/guides/mariadb/autoscaler/storage/overview/images/mdas-storage.jpeg">
<img alt="Storage Autoscaling process of MariaDB" src="/docs/guides/mariadb/distributed/autoscaler/storage/overview/images/mdas-storage.jpeg">
<figcaption align="center">Fig: Storage Autoscaling process of MariaDB</figcaption>
</figure>

Expand Down
10 changes: 10 additions & 0 deletions docs/guides/mariadb/distributed/opsrequest/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
title: Horizontal Scaling
menu:
docs_{{ .version }}:
identifier: guides-mariadb-distributed-horizontalscaling
name: Horizontal Scaling
parent: guides-mariadb-distributed
weight: 50
menu_name: docs_{{ .version }}
---
31 changes: 31 additions & 0 deletions docs/guides/mariadb/distributed/opsrequest/examples/mariadb.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
apiVersion: kubedb.com/v1
kind: MariaDB
metadata:
name: mariadb
namespace: demo
spec:
version: "11.5.2"
distributed: true
replicas: 3
storageType: Durable
storage:
storageClassName: "longhorn"
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
podTemplate:
spec:
podPlacementPolicy:
name: distributed-mariadb
containers:
- name: mariadb
resources:
requests:
cpu: "200m"
memory: "300Mi"
limits:
cpu: "200m"
memory: "300Mi"
deletionPolicy: WipeOut
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: ops.kubedb.com/v1alpha1
kind: MariaDBOpsRequest
metadata:
name: mdops-scale-horizontal-down
namespace: demo
spec:
type: HorizontalScaling
databaseRef:
name: mariadb
horizontalScaling:
member: 3
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: ops.kubedb.com/v1alpha1
kind: MariaDBOpsRequest
metadata:
name: mdops-scale-horizontal-up
namespace: demo
spec:
type: HorizontalScaling
databaseRef:
name: mariadb
horizontalScaling:
member: 5
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
apiVersion: apps.k8s.appscode.com/v1
kind: PlacementPolicy
metadata:
labels:
app.kubernetes.io/managed-by: Helm
name: distributed-mariadb
spec:
clusterSpreadConstraint:
distributionRules:
- clusterName: demo-controller
replicaIndices:
- 0
- 2
- 4
- clusterName: demo-worker
replicaIndices:
- 1
- 3
slice:
projectNamespace: kubeslice-demo-distributed-mariadb
sliceName: demo-slice
nodeSpreadConstraint:
maxSkew: 1
whenUnsatisfiable: ScheduleAnyway
zoneSpreadConstraint:
maxSkew: 1
whenUnsatisfiable: ScheduleAnyway
Loading
Loading