-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Neaj Morshad <[email protected]>
- Loading branch information
1 parent
c8e8288
commit 134157a
Showing
13 changed files
with
158 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
--- | ||
title: Arbiter Node for MS SQL Server Cluster with Even Nodes | ||
menu: | ||
docs_{{ .version }}: | ||
identifier: arbiter-guides | ||
name: Arbiter Node for AG Cluster | ||
parent: ms-arbiter | ||
weight: 15 | ||
menu_name: docs_{{ .version }} | ||
section_menu_id: guides | ||
--- | ||
|
||
> New to KubeDB? Please start [here](/docs/README.md). | ||
# Arbiter Node for Microsoft SQL Server Cluster with Even Nodes | ||
|
||
Here we will show how to use KubeDB to provision a SQL Server even-sized Availability Group Cluster with Arbiter Node. | ||
|
||
## Before You Begin | ||
|
||
- You need to have a Kubernetes cluster, and the kubectl command-line tool must be configured to communicate with your cluster. If you do not already have a cluster, you can create one by using [kind](https://kind.sigs.k8s.io/docs/user/quick-start/). | ||
|
||
- Now, install KubeDB cli on your workstation and KubeDB operator in your cluster following the steps [here](/docs/setup/README.md). Make sure install with helm command including `--set global.featureGates.MSSQLServer=true` to ensure MSSQLServer CRD installation. | ||
|
||
- To configure TLS/SSL in `MSSQLServer`, `KubeDB` uses `cert-manager` to issue certificates. So first you have to make sure that the cluster has `cert-manager` installed. To install `cert-manager` in your cluster following steps [here](https://cert-manager.io/docs/installation/kubernetes/). | ||
|
||
|
||
## Concepts | ||
We use [Raft Consensus Algorithm](https://raft.github.io/) to determine the leader of SQL Server Availability Group cluster. With each `mssql` container, | ||
we run a sidecar container named `mssql-coordinator` which determines the leader of the cluster both on bootstrap and in fail over scenarios. | ||
This works very well with the clusters having odd number of nodes. Clusters with even number of nodes still have a chance of split brain problem(Two primary node in the cluster at the same time). To avoid this split brain issue, | ||
we introduced an extra node named `{{db}}-arbiter`. The job of the | ||
arbiter node is to participate solely in leader election. | ||
It doesn't store any data related to mssqlserver database. However, it needs | ||
a bare minimum of 1Gi~2Gi Storage for storing WAL and Snapshots that | ||
are generated by RAFT. But the generation of WAL are not very frequent. | ||
So storage space of 2Gi is more than enough for most of the clusters. | ||
|
||
## Demo | ||
|
||
To keep things isolated, this tutorial uses a separate namespace called `demo` throughout this tutorial. | ||
|
||
```bash | ||
$ kubectl create ns demo | ||
namespace/demo created | ||
``` | ||
|
||
Let's apply the following yaml. | ||
|
||
```yaml | ||
apiVersion: kubedb.com/v1alpha2 | ||
kind: MSSQLServer | ||
metadata: | ||
name: ms-even-cluster | ||
namespace: demo | ||
spec: | ||
version: "2022-cu16" | ||
replicas: 2 | ||
topology: | ||
mode: AvailabilityGroup | ||
availabilityGroup: | ||
databases: | ||
- agdb1 | ||
- agdb2 | ||
tls: | ||
issuerRef: | ||
name: mssqlserver-ca-issuer | ||
kind: Issuer | ||
apiGroup: "cert-manager.io" | ||
clientTLS: false | ||
podTemplate: | ||
spec: | ||
containers: | ||
- name: mssql | ||
env: | ||
- name: ACCEPT_EULA | ||
value: "Y" | ||
- name: MSSQL_PID | ||
value: Evaluation | ||
storageType: Durable | ||
storage: | ||
accessModes: | ||
- ReadWriteOnce | ||
resources: | ||
requests: | ||
storage: 1Gi | ||
deletionPolicy: WipeOut | ||
``` | ||
A petset with the name `{{ dbName }}-arbiter` should be created once you apply this yaml. | ||
|
||
```bash | ||
kubectl get petset -n demo | ||
NAME AGE | ||
ms-even-cluster 72s | ||
ms-even-cluster-arbiter 55s | ||
``` | ||
|
||
Following a pod having name `{{ dbName }}-arbiter-0` will be created. | ||
|
||
```bash | ||
kubectl get pods -n demo | ||
NAME READY STATUS RESTARTS AGE | ||
ms-even-cluster-0 2/2 Running 0 84s | ||
ms-even-cluster-1 2/2 Running 0 78s | ||
ms-even-cluster-arbiter-0 1/1 Running 0 68s | ||
``` | ||
Get the pvc, | ||
|
||
```bash | ||
kubectl get pvc -n demo | ||
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE | ||
data-ms-even-cluster-0 Bound pvc-8653958e-091c-4c15-8151-4d207c976ad1 1Gi RWO standard 2m50s | ||
data-ms-even-cluster-1 Bound pvc-afd698cf-22d5-4a66-996e-a8d53198a95f 1Gi RWO standard 2m44s | ||
data-ms-even-cluster-arbiter-0 Bound pvc-25c413c9-4cb0-4a5c-89f6-9d2208841b07 2Gi RWO standard 2m34s | ||
``` | ||
> Note: Your pvc size for data nodes might be 1000Gi, but for most of the cases you will never need more than 2Gi storage for arbiter node. | ||
|
||
|
||
You can check arbiter pod has only one container by getting the pod yaml. | ||
```bash | ||
kubectl get pods -n demo ms-even-cluster-arbiter-0 -oyaml | ||
``` | ||
|
||
## Why do we need arbiter node? | ||
|
||
Few of our users don't want to run 3 node cluster as this was quite | ||
expensive for them, instead they wanted to use 2 node cluster, | ||
1 primary and 1 replica. But due to raft implementation, there was chance of split brain. So we introduced this arbiter node so that they can still have | ||
1 primary and 1 replica cluster and not have faced split brain problem. | ||
|
||
|
||
## Cleaning up | ||
|
||
```bash | ||
kubectl delete pg -n demo ms-even-cluster | ||
kubectl delete ns demo | ||
``` | ||
|
||
## Next Steps | ||
- Learn more about [Raft implementation](https://github.com/etcd-io/etcd/blob/main/contrib/raftexample/README.md) | ||
- Learn about [backup and restore](/docs/guides/mssqlserver/backup/overview/index.md) Microsoft SQL Server database using Stash. | ||
- Want to set up Microsoft SQL Server cluster? Check how to [configure Highly Available Microsoft SQL Server Cluster](/docs/guides/mssqlserver/clustering/ag_cluster.md) | ||
- Monitor your Microsoft SQL Server database with KubeDB using [Prometheus operator](/docs/guides/mssqlserver/monitoring/using-prometheus-operator.md). | ||
- Detail concepts of [Postgres object](/docs/guides/mssqlserver/concepts/mssqlserver.md). | ||
- Want to hack on KubeDB? Check our [contribution guidelines](/docs/CONTRIBUTING.md). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters