| title | Configure a SQL Server Always On availability group in Kubernetes for high availability | Microsoft Docs |
|---|---|
| description | This tutorial shows how to deploy a SQL Server always on availability group with Kubernetes on Azure Container Service. |
| author | MikeRayMSFT |
| ms.author | mikeray |
| manager | craigg |
| ms.date | 07/16/2018 |
| ms.topic | tutorial |
| ms.prod | sql |
| ms.component | |
| ms.suite | sql |
| ms.custom | sql-linux,mvc |
| ms.technology | linux |
Learn how to configure a SQL Server Always On availability group on Kubernetes in Azure Kubernetes Service (AKS). This solution provides the high availability (HA) and read-scale benefits of a SQL Server Always On availability group with the container orchestration benefits of Kubernetes.
This tutorial demonstrates how to configure a highly available SQL Server instance in containers that use AKS.
[!div class="checklist"]
- Create an SA password
- Create storage
- Create the deployment
- Connect with SQL Server Management Studio (SSMS)
- Verify failure and recovery
-
Configure storage for SQL Server files
-
Deploy the operator, and agents
Create a manifest file to define the storage class and the persistent volume claim for each of the 3 SQL Server instances that will be part of the AG. The Kubernetes cluster uses this manifest to create the persistent storage.
The following yaml file example, defines a storage class and persistent volume claims. The storage class provisioner is azure-disk because this Kubernetes cluster is in Azure. The persistent volume claims are mssql-data-1, mssql-data-2, mssql-data-3. The persistent volume claim metadata includes an annotation connecting it back to the storage class.
kind: StorageClass
apiVersion: storage.k8s.io/v1beta1
metadata:
name: azure-disk
provisioner: kubernetes.io/azure-disk
parameters:
storageaccounttype: Standard_LRS
kind: Managed
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: mssql-data-1
annotations:
volume.beta.kubernetes.io/storage-class: azure-disk
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 8Gi
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: mssql-data-2
annotations:
volume.beta.kubernetes.io/storage-class: azure-disk
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 8Gi
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: mssql-data-3
annotations:
volume.beta.kubernetes.io/storage-class: azure-disk
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 8GiSave the file pvc.yaml.
kubectl apply -f <Path to pvc.yaml file>
Kubernetes creates the persistent volumes automatically as Azure managed storage accounts, and binds them to the persistent volume claims.
kubectl describe pvc <PersistentVolumeClaim>
In the preceding step, the persistent volume claim is named mssql-data-<x> where <x> is a number. For example, mssql-data-1. To see
metadata about the persistent volume claim, run the following command:
kubectl describe pvc mssql-data-<x>
kubectl describe pv
kubectl returns metadata about the persistent volumes that were automatically created and bound to the persistent volume claims.
In these steps you will:
- Create an
[!div class="nextstepaction"] Introduction to Kubernetes