Skip to content

Commit 3acd180

Browse files
authored
Merge pull request #7046 from MikeRayMSFT/20180830-Kubernetes
Update kubernetes AG instructions
2 parents 874f48e + 8b83304 commit 3acd180

11 files changed

Lines changed: 226 additions & 598 deletions

docs/linux/sql-server-ag-kubernetes.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ To deploy an availability group in Kubernetes:
4242

4343
1. Create the Kubernetes cluster
4444

45-
For an availability group, create at least three nodes for SQL Server plus a node for the operator.
45+
For an availability group, create at least three nodes for SQL Server plus a node for the master.
4646

4747
1. Deploy the operator
4848

@@ -64,26 +64,32 @@ The StatfulSet contains:
6464

6565
* mssql-server container
6666

67-
* AG Agent container
67+
* mssql-ha-supervisor container
6868

69-
The code for the operator, AG agent, and SQL Server is packaged in a Docker image called `mssql-server-k8s-agents`. This image contains following binaries:
69+
The code for the operator, HA supervisor, and SQL Server is packaged in a Docker image called `mcr.microsoft.com/mssql/ha`. This image contains following binaries:
7070

71-
* `mssql-server-k8s-operator`
71+
* `mssql-operator`
7272

7373
This process is deployed as a separate Kubernetes deployment. It registers the custom Kubernetes [custom resource](http://kubernetes.io/docs/concepts/extend-kubernetes/api-extension/custom-resources/) called `SqlServer` (sqlservers.mssql.microsoft.com). Then it listens for such resources being created or updated in the Kubernetes cluster. For every such event, it creates or updates the Kubernetes resources for the corresponding instance (for example the StatefulSet, or `mssql-server-k8s-init-sql` job).
7474

7575
* `mssql-server-k8s-sqlhealth-agent`
7676

7777
This web server serves Kubernetes [liveness probes](http://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/) to determine the health of a SQL Server instance. Monitors the health of the local SQL Server instance by calling `sp_server_diagnostics` and comparing the results with your monitor policy.
7878

79-
* `mssql-server-k8s-ag-agent-supervisor`
80-
81-
This process spawns `mssql-server-k8s-ag-agent` processes as child processes and terminates them as necessary, based on which AGs the local SQL Server instance is meant to be part of.
79+
* `mssql-ha-supervisor`
80+
81+
Contains `mssql-health-monitor`
82+
83+
This process spawns `mssql-server-k8s-ag-agent` and `mssql-server-k8s-sqlhealth-agent` processes as child processes and terminates them as necessary, based on which AGs the local SQL Server instance is meant to be part of.
84+
85+
It also maintains the ag certificate and endpoint.
8286

8387
* `mssql-server-k8s-ag-agent`
8488

8589
This process monitors the health of an AG replica on a single SQL Server instance and performs failovers.
8690

91+
It also maintains the leader election.
92+
8793
* `mssql-server-k8s-init-sql`
8894

8995
This Kubernetes [job](http://kubernetes.io/docs/concepts/workloads/controllers/jobs-run-to-completion/) applies a desired state configuration to a SQL Server instance. The job is created by the operator every time a SqlServer resource is created or updated. It ensures that the target SQL Server instance corresponding to the custom resource has the desired configuration described in the resource.
@@ -103,7 +109,7 @@ The code for the operator, AG agent, and SQL Server is packaged in a Docker imag
103109

104110
### Notes
105111

106-
Regardless of the AG configuration, The operator will always deploy the AG agent. If the SqlServer resource does not list any AG, the operator will still deploy this container.
112+
Regardless of the AG configuration, The operator will always deploy the HA supervisor. If the SqlServer resource does not list any AG, the operator will still deploy this container.
107113

108114
The version for the operator image is identical to the version for the SQL Server image.
109115

docs/linux/sql-server-linux-container-ha-overview.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,20 @@ ms.component: ""
1111
ms.suite: "sql"
1212
ms.custom: "sql-linux"
1313
ms.technology: linux
14-
monikerRange: ">=sql-server-ver15||>=sql-server-linux-ver15||=sqlallproducts-allversions"
14+
monikerRange: ">=sql-server-2017||>=sql-server-linux-2017||=sqlallproducts-allversions"
1515
---
1616
# High availability for SQL Server containers
1717

1818
Create and manage your SQL Server instances natively in Kubernetes.
1919

2020
Deploy SQL Server to docker containers managed by [Kubernetes](https://kubernetes.io/). In Kubernetes, a container with a SQL Server instance can automatically recover in case a cluster node fails. For more robust availability, configure SQL Server Always On availability group with SQL Server instances in containers on a Kubernetes cluster. This article compares the two solutions.
2121

22+
## Compare SQL Server versions on Kubernetes
23+
24+
SQL Server 2017 provides a Docker image that can deploy on Kubernetes. You can configure the image with a Kubernetes persistent volume claim (PVC). Kubernetes monitors the SQL Server process in the container. If the process, pod, container, or node fail, Kubernetes automatically bootstraps another instance and reconnects to the storage.
25+
26+
SQL Server 2019 introduces a more robust archicture with a Kubernetes StatefulSet. This allows Kubernetes to orchestrate instances of SQL Server in container images that can participate in a SQL Server Always On Availability Group. This can provide improved health monitoring, faster recovery, offload backup, and read scale out.
27+
2228
## Container with SQL Server instance on Kubernetes
2329

2430
Kubernetes 1.6 and later has support for [*storage classes*](http://kubernetes.io/docs/concepts/storage/storage-classes/), [*persistent volume claims*](http://kubernetes.io/docs/concepts/storage/storage-classes/#persistentvolumeclaims), and the [*Azure disk volume type*](https://github.com/kubernetes/examples/tree/master/staging/volumes/azure_disk).
@@ -33,9 +39,11 @@ Kubernetes orchestrates the resources in the cluster. When a pod or node hosting
3339

3440
SQL Server 2017 and later support containers on Kubernetes.
3541

42+
To create a container in Kubernetes, see [Deploy a SQL Server container in Kubernetes](tutorial-sql-server-containers-kubernetes.md)
43+
3644
## A SQL Server Always On availability group on SQL Server containers in Kubernetes
3745

38-
SQL Server 2019 supports availability groups on containers in a Kubernetes. For availability groups, deploy the SQL Server [Kubernetes operator](http://coreos.com/blog/introducing-operators.html) to your Kubernetes cluster. The operator helps package, deploy, and manage the availability group in a cluster.
46+
SQL Server 2019 supports availability groups on containers in a Kubernetes. For availability groups, deploy the SQL Server [Kubernetes operator](http://coreos.com/blog/introducing-operators.html) to your Kubernetes cluster. The operator helps package, deploy, and manage SQL Server instances and the availability group in a cluster.
3947

4048
![AG in Kubernetes Container](media/tutorial-sql-server-ag-containers-kubernetes/KubernetesCluster.png)
4149

@@ -45,7 +53,7 @@ In the image above, a four-node kubernetes cluster hosts an availability group w
4553

4654
* Three nodes, each hosting a [*StatefulSet*](http://kubernetes.io/docs/concepts/workloads/controllers/statefulset/). The StatefulSet contains a pod. Each pod contains:
4755
* A SQL Server container running one instance of SQL Server.
48-
* An availability group agent.
56+
* A supervisor `mcr.microsoft.com/mssql/ha` to manage the availability group.
4957

5058
* Two [*ConfigMaps*](http://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/) related to the availability group. The ConfigMaps provide information about:
5159
* The deployment for the operator.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
title: Connect to SQL Server Always On Availability Group on Kubernetes cluster
3+
description: This article explains the environment variables for the SQL Server Kubernetes Always On availability group failover job
4+
author: MikeRayMSFT
5+
ms.author: mikeray
6+
manager: craigg
7+
ms.date: 08/09/2018
8+
ms.topic: article
9+
ms.prod: sql
10+
ms.component: ""
11+
ms.suite: "sql"
12+
ms.custom: "sql-linux"
13+
ms.technology: linux
14+
monikerRange: ">=sql-server-ver15||>=sql-server-linux-ver15||=sqlallproducts-allversions"
15+
---
16+
17+
# Connect to SQL Server Availability Group on Kubernetes
18+
19+
## Connect to primary replica
20+
21+
## Connect to secondary replica
22+
23+
## Next steps
24+
25+
[Manage SQL Server availability group on Kubernetes cluster](sql-server-linux-kubernetes-manage.md)
26+
27+
[SQL Server availability group on Kubernetes cluster](sql-server-ag-kubernetes.md)
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
---
2+
title: Deploy SQL Server Always On Availability Group on Kubernetes Cluster
3+
description: This article explains the parameters for the SQL Server Kubernetes Always On availability group operator global requirements
4+
author: MikeRayMSFT
5+
ms.author: mikeray
6+
manager: craigg
7+
ms.date: 08/09/2018
8+
ms.topic: article
9+
ms.prod: sql
10+
ms.component: ""
11+
ms.suite: "sql"
12+
ms.custom: "sql-linux"
13+
ms.technology: linux
14+
monikerRange: ">=sql-server-ver15||>=sql-server-linux-ver15||=sqlallproducts-allversions"
15+
---
16+
# Deploy a SQL Server Always On Availability Group on Kubernetes Cluster
17+
18+
To deploy a SQL Server Always On Availability Group on a Kubernetes Cluster:
19+
20+
1. Configure the cluster
21+
22+
Use a cluster with at least four nodes. One node is the master. The other nodes host SQL Server containers with the replicas. At least three replicas are required for high-availability.
23+
24+
1. Configure storage
25+
26+
In cloud environments like Azure, configure persistent volumes.
27+
28+
1. Create Kubernetes secrets
29+
30+
1. Configure and deploy the SQL Server operator manifest
31+
32+
Copy the SQL Server operator `operator.yaml` file from [sql-server-samples](https://github.com/Microsoft/sql-server-samples/tree/master/samples/features/high%20availability/Linux)
33+
34+
The `operator.yaml` file is the deployment manifiest for the Kubernetes.
35+
36+
To configure the manifest, update the `operator.yaml` file for your environment.
37+
38+
Apply the manifest to the Kubernetes cluster.
39+
40+
```azurecli
41+
kubectl apply -f operator.yaml
42+
```
43+
44+
## Next steps
45+
46+
[Connect to SQL Server availability group on Kubernetes cluster](sql-server-linux-kubernetes-connect.md)
47+
48+
[Manage SQL Server availability group on Kubernetes cluster](sql-server-linux-kubernetes-manage.md)
49+
50+
[SQL Server availability group on Kubernetes cluster](sql-server-ag-kubernetes.md)

docs/linux/sql-server-linux-kubernetes-failover-job.md

Lines changed: 0 additions & 118 deletions
This file was deleted.
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
---
2+
title: SQL Server Always On availability group Kubernetes specification
3+
description: This article explains the parameters for the SQL Server Kubernetes Always On availability group specification
4+
author: MikeRayMSFT
5+
ms.author: mikeray
6+
manager: craigg
7+
ms.date: 08/09/2018
8+
ms.topic: article
9+
ms.prod: sql
10+
ms.component: ""
11+
ms.suite: "sql"
12+
ms.custom: "sql-linux"
13+
ms.technology: linux
14+
monikerRange: ">=sql-server-ver15||>=sql-server-linux-ver15||=sqlallproducts-allversions"
15+
---
16+
# SQL Server Always On Availability Group - Kubernetes specification
17+
18+
To configure an Always On Availability Group on Kubernetes, create a specification. The specification is a `.yaml` file.
19+
20+
Shows basic management tasks for Kubernetes. The examples in this article apply to all Kubernetes cluster. The scenarios in these examples are applied against a cluster on Azure Kubernetes Service.
21+
22+
See an example of the of the end-to-end deployment in [this tutorial](tutorial-sql-server-ag-kubernetes.md).
23+
24+
## Create a manifest file for the specification
25+
26+
The following example of a manifest file describes a Kubernetes specification for SQL Server. Copy the contents of the example into a new file named `sqlserver.yaml` to create the SQL Server availability group StatefulSet in Kubernetes.
27+
28+
[sqlserver.yaml](https://github.com/Microsoft/sql-server-samples/tree/master/samples/features/high%20availability/Linux)
29+
30+
To deploy the SQL Server instances and create the availability group, run the following command.
31+
32+
```azurecli
33+
kubectl apply -f sqlserver.yaml
34+
```
35+
36+
## Fail over - SQL Server availability group on Kubernetes
37+
38+
To fail over an Always On availability group primary replica to a different node in Kubernetes, use a job. This article identifies the environment variables for this job.
39+
40+
The following example of a manifest file describes a job to manually fail over job for an availability group on a Kubernetes replica. Copy the contents of the example into a new file called `ag-failover.yaml`.
41+
42+
[ag-failover.yaml](https://github.com/Microsoft/sql-server-samples/tree/master/samples/features/high%20availability/Linux)
43+
44+
```azurecli
45+
kubectl apply -f ag-failover.yaml
46+
```
47+
48+
When you apply manifest file, Kubernetes runs the job. When the job runs, the supervisor elects a new leader and moves the primary replica to the SQL Server instance of the leader.
49+
50+
After you run the job, delete it. The job object in Kubernetes remains after completion so you can view its status. You have to manually delete old jobs after noting their status. Deleting the job also deletes the Kubernetes logs. If you do not delete the job, future failover jobs will fail unless you change the job name and the pod selector. For more information, see [Jobs - Run to Completion](https://kubernetes.io/docs/concepts/workloads/controllers/jobs-run-to-completion/).
51+
52+
## Rotate credentials
53+
54+
[rotate-creds.yaml](https://github.com/Microsoft/sql-server-samples/tree/master/samples/features/high%20availability/Linux)
55+
56+
```azurecli
57+
kubectl apply -f ag-failover.yaml
58+
```
59+
60+
## Next steps
61+
62+
[SQL Server availability group on Kubernetes cluster](sql-server-ag-kubernetes.md)

0 commit comments

Comments
 (0)