Skip to content

Commit f786850

Browse files
committed
Editorial review
1 parent d5bf1ad commit f786850

1 file changed

Lines changed: 61 additions & 44 deletions

File tree

docs/linux/tutorial-sql-server-containers-kubernetes-DH2i.md

Lines changed: 61 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -5,37 +5,38 @@ ms.custom:
55
author: amvin87
66
ms.author: amitkh
77
ms.reviewer: amitkh, vanto
8-
ms.date: 07/09/2021
8+
ms.date: 07/20/2021
99
ms.topic: tutorial
1010
ms.prod: sql
1111
ms.technology: linux
1212
---
1313

1414
# Deploy availability group with DH2i for SQL Server containers on AKS
1515

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:
1717

1818
For more information about DxEnterprise, see [DH2i DxEnterprise](https://dh2i.com/dxenterprise-availability-groups/).
1919

2020
> [!NOTE]
2121
> 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.
2222
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
2829
2930
## Prerequisites
3031

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.
3334

3435
## Deploy Azure Kubernetes Service
3536

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.
3738

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:
3940

4041
```bash
4142
C:\>kubectl get nodes
@@ -46,7 +47,9 @@ aks-nodepool1-75119571-vmss000001 Ready agent 61d v1.19.9
4647

4748
## Prepare the SQL Server & DH2i DxEnterprise custom container image
4849

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/).
5053

5154
```bash
5255
FROM mcr.microsoft.com/mssql/server:2019-latest
@@ -88,48 +91,58 @@ $nano Dockerfile
8891
# paste the sample dockerfile content shared above
8992
# now build the image using the command:
9093
$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
9295
```
9396

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).
9598

9699
```bash
97-
$docker tag sqlimage/latest amvinacr.azurecr.io/sqlimage:latest
100+
$docker tag sqlimage/latest <registry-name>.azurecr.io/sqlimage:latest
98101
#now push to the ACR repo:
99-
$docker push amvinacr.azurecr.io/sqlimage:latest
102+
$docker push <registry-name>.azurecr.io/sqlimage:latest
100103
#you can browse your ACR through the portal and should see the repo and the tag listed in the ACR.
101104
```
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).
103107

104108
```bash
105-
az aks update -n myAKSCluster -g amvindomain --attach-acr amvinacr
109+
az aks update -n myAKSCluster -g <myResourceGroup> --attach-acr <registry-name>
106110
```
107111

108112
## Deploy containers on Azure Kubernetes Service
109113

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:
111117

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:
113119

114-
1. Get the node names of the cluster using the command:
115-
```bash
116-
kubectl get nodes
117-
```
120+
```bash
121+
kubectl get nodes
122+
```
118123

119-
2. Now label the nodes using the commands:
120-
```bash
121-
kubectl label node aks-nodepool1-75119571-vmss000000 <role=ags-primary>
122-
kubectl label node aks-nodepool1-75119571-vmss000001 <role=ags-secondary>
123-
```
124+
1. Label the nodes using the following commands:
124125

125-
2. Create the SA password secret on kubernetes before deploying the SQL Server containers using the command:
126+
```bash
127+
kubectl label node aks-nodepool1-75119571-vmss000000 <role=ags-primary>
128+
```
129+
130+
```bash
131+
kubectl label node aks-nodepool1-75119571-vmss000001 <role=ags-secondary>
132+
```
133+
134+
1. Create the SA password secret on kubernetes before deploying the SQL Server containers using the following command:
126135

127136
```bash
128137
kubectl create secret generic mssql --from-literal=SA_PASSWORD="MyC0m9l&xP@ssw0rd"
129138
```
130-
Replace MyC0m9l&xP@ssw0rd with your own complex password
131139

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.
133146

134147
```bash
135148
kind: StorageClass
@@ -162,7 +175,7 @@ spec:
162175
fsGroup: 10001
163176
containers:
164177
- name: mssql
165-
image: amvinacr.azurecr.io/sqldh2i:latest
178+
image: <registry-name>.azurecr.io/sqldh2i:latest
166179
env:
167180
- name: ACCEPT_EULA
168181
value: "Y"
@@ -221,7 +234,7 @@ spec:
221234
fsGroup: 10001
222235
containers:
223236
- name: mssql
224-
image: amvinacr.azurecr.io/sqldh2i:latest
237+
image: <registry-name>.azurecr.io/sqldh2i:latest
225238
env:
226239
- name: ACCEPT_EULA
227240
value: "Y"
@@ -314,14 +327,17 @@ spec:
314327
targetPort: 7979
315328
```
316329

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:
318333

319334
```bash
320335
kubectl apply -f <Path to sqldeployment.yaml file>
321336
```
322-
Once the deployment completes when you run the **kubectl get all** command you should see result as shown below:
323337

324-
```bash
338+
Once the deployment completes, run the **kubectl get all** command. You should see result as shown below:
339+
340+
```output
325341
C:\>kubectl get all
326342
NAME READY STATUS RESTARTS AGE
327343
pod/mssql-pri-0 1/1 Running 0 33h
@@ -338,17 +354,18 @@ NAME READY AGE
338354
statefulset.apps/mssql-pri 1/1 33h
339355
statefulset.apps/mssql-sec 2/2 33h
340356
```
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.
342357

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
344361

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 for non-production use. To configure the DxEnterprise cluster in 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 for non-production use. To configure the DxEnterprise cluster in 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).
346363

347364
With this, you should have an Always On availability group created and database(s) added to the group supporting high availability.
348365

349-
## Steps to configure Read/write connection redirection: (Optional)
366+
## Steps to configure read/write connection redirection: (Optional)
350367

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).
352369
353370
```bash
354371
USE [master]
@@ -385,5 +402,5 @@ GO
385402
386403
## Next Steps
387404
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

Comments
 (0)