You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/linux/tutorial-sql-server-containers-kubernetes-DH2i.md
+61-44Lines changed: 61 additions & 44 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,37 +5,38 @@ ms.custom:
5
5
author: amvin87
6
6
ms.author: amitkh
7
7
ms.reviewer: amitkh, vanto
8
-
ms.date: 07/09/2021
8
+
ms.date: 07/20/2021
9
9
ms.topic: tutorial
10
10
ms.prod: sql
11
11
ms.technology: linux
12
12
---
13
13
14
14
# Deploy availability group with DH2i for SQL Server containers on AKS
15
15
16
-
This tutorial explains how to configure SQL Server Always On availability group for SQL Server Linux based containers deployed in Kubernetes cluster. In this case, Azure Kubernetes Service (AKS) is used as the kubernetes cluster and the tutorial consists of the following tasks:
16
+
This tutorial explains how to configure SQL Server Always On availability group for SQL Server Linux based containers deployed in a Kubernetes cluster. In this tutorial, Azure Kubernetes Service (AKS) is used as the kubernetes cluster and the tutorial consists of the following tasks:
17
17
18
18
For more information about DxEnterprise, see [DH2i DxEnterprise](https://dh2i.com/dxenterprise-availability-groups/).
19
19
20
20
> [!NOTE]
21
21
> Microsoft supports data movement, availability group, and SQL Server components. DH2i is responsible for support of the DxEnterprise product, which includes cluster and quorum management.
22
22
23
-
1. Deploy Azure Kubernetes Service.
24
-
2. Prepare the SQL Server & DH2i custom container image.
25
-
3. Deploy containers on Azure Kubernetes Service.
26
-
4. Configure the DxEnterprise cluster.
27
-
5. Configure Read_Write_Routing_URL for listener functionality - Optional.
23
+
> [!div class="checklist"]
24
+
> - Deploy Azure Kubernetes Service
25
+
> - Prepare the SQL Server & DH2i custom container image
26
+
> - Deploy containers on Azure Kubernetes Service
27
+
> - Configure the DxEnterprise cluster
28
+
> - Configure Read_Write_Routing_URL for listener functionality - Optional
28
29
29
30
## Prerequisites
30
31
31
-
1. To deploy Azure Kubernetes Service, you must have an Azure account. A two-node cluster is a good starting point for this tutorial.
32
-
2. Create Azure Container Registry. This will be used in our deployment scripts to retrieve the custom image and deploy the containers to Azure Kubernetes. Instead of Azure Container Registry (ACR), you could use your preferred container registry to push the custom container images.
32
+
- To deploy Azure Kubernetes Service, you must have an [Azure account](https://azure.microsoft.com/free/). A two-node cluster is a good starting point for this tutorial.
33
+
- Create [Azure Container Registry](/azure/container-registry/container-registry-get-started-portal). This will be used in our deployment scripts to retrieve the custom image and deploy the containers to Azure Kubernetes. Instead of Azure Container Registry (ACR), you could use your preferred container registry to push the custom container images.
33
34
34
35
## Deploy Azure Kubernetes Service
35
36
36
-
Follow this [quickstart tutorial](/azure/aks/kubernetes-walkthrough-portal#create-an-aks-cluster) to set up a two-node Kubernetes cluster using the Azure Kubernetes Service. After you've created the cluster, you can connect to it by following the steps outlined in the article's ["connect to the cluster"](/azure/aks/kubernetes-walkthrough-portal#connect-to-the-cluster) section.
37
+
Follow this [quickstart tutorial](/azure/aks/kubernetes-walkthrough-portal#create-an-aks-cluster) to set up a two-node Kubernetes cluster using the Azure Kubernetes Service. After you've created the cluster, you can connect to it by following the steps outlined in the [Connect to the cluster](/azure/aks/kubernetes-walkthrough-portal#connect-to-the-cluster) section.
37
38
38
-
You should now have a two-node kubernetes cluster, and running **kubectl get nodes** from your client machine should yield results similar to this:
39
+
You should now have a two-node kubernetes cluster. Running `kubectl get nodes` from your client machine using a console app should yield results similar to the following:
## Prepare the SQL Server & DH2i DxEnterprise custom container image
48
49
49
-
Next, we'll create the custom container image that will be used in our deployment manifests. This custom container image will deploy SQL Server, .Net, and DxEnterprise in a container. The deployment sample dockerfile is provided below; you can modify it to meet your needs, such as changing the SQL Server version.
50
+
Create the custom container image that will be used in our deployment manifests. The custom container image will deploy SQL Server, .NET, and DxEnterprise in a container. The deployment sample dockerfile is provided below. You can modify it to meet your needs, such as changing the SQL Server version.
51
+
52
+
For more information on Docker and using dockerfiles, see the [docker documentation](https://docs.docker.com/get-started/).
50
53
51
54
```bash
52
55
FROM mcr.microsoft.com/mssql/server:2019-latest
@@ -88,48 +91,58 @@ $nano Dockerfile
88
91
# paste the sample dockerfile content shared above
89
92
# now build the image using the command:
90
93
$docker build -t <tagname>.
91
-
# you should now be able to see the new image sqlimage when you run the docker images command
94
+
# you should now be able to see the new image, sqlimage when you run the docker images command
92
95
```
93
96
94
-
Now, tag the image and push it to Azure Container Registry (ACR) using the commands below. Make sure you've already logged in to Azure Container Registry (ACR) using the docker login command; for more information, see [login to ACR](/azure/container-registry/container-registry-get-started-portal#log-in-to-registry).
97
+
Tag the image and push it to Azure Container Registry (ACR) using the commands below. Make sure you've already logged into Azure Container Registry (ACR) using the docker login command. For more information, see [login to ACR](/azure/container-registry/container-registry-get-started-portal#log-in-to-registry).
95
98
96
99
```bash
97
-
$docker tag sqlimage/latest amvinacr.azurecr.io/sqlimage:latest
100
+
$docker tag sqlimage/latest <registry-name>.azurecr.io/sqlimage:latest
#you can browse your ACR through the portal and should see the repo and the tag listed in the ACR.
101
104
```
102
-
This ensures that the custom image has been pushed to Azure Container Registry (ACR) and that you can now integrate your Azure Kubernetes Service with Azure Container Registry by running the following command; for more information, see this [article](/azure/aks/cluster-container-registry-integration).
105
+
106
+
This ensures that the custom image has been pushed to Azure Container Registry (ACR) and that you can now integrate your Azure Kubernetes Service (AKS) with ACR by running the following command. For more information, see this [Integrate ACR with an AKS cluster](/azure/aks/cluster-container-registry-integration).
103
107
104
108
```bash
105
-
az aks update -n myAKSCluster -g amvindomain --attach-acr amvinacr
109
+
az aks update -n myAKSCluster -g <myResourceGroup> --attach-acr <registry-name>
106
110
```
107
111
108
112
## Deploy containers on Azure Kubernetes Service
109
113
110
-
We will deploy SQL Server containers as statefulset deployments; a sample deployment file that deploys the containers on the Azure Kubernetes Service is provided below for reference. Take note of the following points:
114
+
We'll deploy SQL Server containers as StatefulSet deployments; a sample deployment file that deploys the containers on the Azure Kubernetes Service is provided below for reference.
115
+
116
+
1. We'll set up three SQL Server instances. One as a primary replica and two as secondary replicas. You can optionally add labels to the node to ensure that the primary replica always runs on one node and the secondary replicas run on another. The following are the steps for labeling the nodes:
111
117
112
-
1. We will set up three SQL Server instances, one as a primary replica and two as secondary replicas. You can optionally add labels to the node to ensure that the primary replica always runs on one node and the secondary replicas run on another. The following are the steps for labelling the nodes:
118
+
1. Get the node names of the cluster using the command:
113
119
114
-
1. Get the node names of the cluster using the command:
Replace MyC0m9l&xP@ssw0rd with your own complex password
131
139
132
-
3. Create a manifest (a YAML file) to describe the deployment. The example below depicts our current deployment, which makes use of the custom container image created in the preceding steps.
140
+
Replace `MyC0m9l&xP@ssw0rd` with your own complex password.
141
+
142
+
1. Create a manifest (a YAML file) to describe the deployment. The example below shows our current deployment, which makes use of the custom container image created in the preceding steps.
143
+
144
+
> [!NOTE]
145
+
> The below is an example and will need to be modified to fit your environment, such as replacing port, image, and storage details.
133
146
134
147
```bash
135
148
kind: StorageClass
@@ -162,7 +175,7 @@ spec:
162
175
fsGroup: 10001
163
176
containers:
164
177
- name: mssql
165
-
image: amvinacr.azurecr.io/sqldh2i:latest
178
+
image: <registry-name>.azurecr.io/sqldh2i:latest
166
179
env:
167
180
- name: ACCEPT_EULA
168
181
value: "Y"
@@ -221,7 +234,7 @@ spec:
221
234
fsGroup: 10001
222
235
containers:
223
236
- name: mssql
224
-
image: amvinacr.azurecr.io/sqldh2i:latest
237
+
image: <registry-name>.azurecr.io/sqldh2i:latest
225
238
env:
226
239
- name: ACCEPT_EULA
227
240
value: "Y"
@@ -314,14 +327,17 @@ spec:
314
327
targetPort: 7979
315
328
```
316
329
317
-
Copy the preceding code into a new file called sqldeployment.yaml, update the values like port, image, and storage details to suit your needs. Create the deployment using the command below:
330
+
Copy the preceding code into a new file called **sqldeployment.yaml**.
331
+
332
+
Create the deployment using the command below:
318
333
319
334
```bash
320
335
kubectl apply -f <Path to sqldeployment.yaml file>
321
336
```
322
-
Once the deployment completes when you run the **kubectl get all**command you should see result as shown below:
323
337
324
-
```bash
338
+
Once the deployment completes, run the **kubectl get all** command. You should see result as shown below:
339
+
340
+
```output
325
341
C:\>kubectl get all
326
342
NAME READY STATUS RESTARTS AGE
327
343
pod/mssql-pri-0 1/1 Running 0 33h
@@ -338,17 +354,18 @@ NAME READY AGE
338
354
statefulset.apps/mssql-pri 1/1 33h
339
355
statefulset.apps/mssql-sec 2/2 33h
340
356
```
341
-
As you can see, we have three SQL Server instances, each with its own storage and services exposing ports 1433 (SQL) and 7979 (DxEnterprise Cluster). You can connect to each SQL Server instance using the External-IP address, and the SA PASSWORD is the same password you provided when creating the mssql secret in the preceding steps.
342
357
343
-
## Configure the DxEnterprise Cluster on the Containers deployed
358
+
As you can see, we have three SQL Server instances, each with its own storage and services exposing ports 1433 (SQL) and 7979 (DxEnterprise Cluster). You can connect to each SQL Server instance using the External-IP address. The SA PASSWORD is the same password you provided when creating the mssql secret in the preceding steps.
359
+
360
+
## Configure the DxEnterprise cluster on the containers deployed
344
361
345
-
DxEnterprise is high availability clustering software from DH2i that supports SQL Server availability groups, including in containers. A fully featured [developer](https://dh2i.com/dxenterprise-dxodyssey-developer-edition) edition is available fornon-production use. To configure the DxEnterprise clusterin containers, follow the steps in this [DH2i guide](https://dh2i.com/wp-content/uploads/DxEnterprise-v21.0-Supplemental-Guide-for-Availability-Groups-in-Kubernetes.pdf).
362
+
DxEnterprise is high availability clustering software from DH2i that supports SQL Server availability groups, including in containers. A fully featured [developer](https://dh2i.com/dxenterprise-dxodyssey-developer-edition) edition is available fornon-production use. To configure the DxEnterprise clusterin containers, follow the steps in this [DH2i guide](https://dh2i.com/wp-content/uploads/DxEnterprise-v21.0-Supplemental-Guide-for-Availability-Groups-in-Kubernetes.pdf).
346
363
347
364
With this, you should have an Always On availability group created and database(s) added to the group supporting high availability.
348
365
349
-
## Steps to configure Read/write connection redirection: (Optional)
366
+
## Steps to configure read/write connection redirection: (Optional)
350
367
351
-
After you've created the availability group, you can enable read/write connection redirection from secondary to primary by following the steps below. For more information, see [Read write routing URL](/sql/database-engine/availability-groups/windows/secondary-replica-connection-redirection-always-on-availability-groups).
368
+
After you've created the availability group, you can enable read/write connection redirection from the secondary to primary by following the steps below. For more information, see [Secondary to primary replica read/write connection redirection](../database-engine/availability-groups/windows/secondary-replica-connection-redirection-always-on-availability-groups.md).
352
369
353
370
```bash
354
371
USE [master]
@@ -385,5 +402,5 @@ GO
385
402
386
403
## Next Steps
387
404
388
-
1. [Deploy SQL Server containers on Azure Kubernetes Service](tutorial-sql-server-containers-kubernetes.md)
389
-
2. [Deploy SQL Server Read Scale AG on SQL Server Linux based containers deployed on kubernetes](https://techcommunity.microsoft.com/t5/sql-server/configure-sql-server-ag-read-scale-for-sql-containers-deployed/ba-p/2224742)
405
+
- [Deploy SQL Server containers on Azure Kubernetes Service](tutorial-sql-server-containers-kubernetes.md)
406
+
- [Deploy SQL Server Read Scale AG on SQL Server Linux based containers deployed on kubernetes](https://techcommunity.microsoft.com/t5/sql-server/configure-sql-server-ag-read-scale-for-sql-containers-deployed/ba-p/2224742)
0 commit comments