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/sql-server-ag-kubernetes.md
+14-8Lines changed: 14 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -42,7 +42,7 @@ To deploy an availability group in Kubernetes:
42
42
43
43
1. Create the Kubernetes cluster
44
44
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.
46
46
47
47
1. Deploy the operator
48
48
@@ -64,26 +64,32 @@ The StatfulSet contains:
64
64
65
65
* mssql-server container
66
66
67
-
*AG Agent container
67
+
*mssql-ha-supervisor container
68
68
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:
70
70
71
-
*`mssql-server-k8s-operator`
71
+
*`mssql-operator`
72
72
73
73
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).
74
74
75
75
*`mssql-server-k8s-sqlhealth-agent`
76
76
77
77
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.
78
78
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.
82
86
83
87
*`mssql-server-k8s-ag-agent`
84
88
85
89
This process monitors the health of an AG replica on a single SQL Server instance and performs failovers.
86
90
91
+
It also maintains the leader election.
92
+
87
93
*`mssql-server-k8s-init-sql`
88
94
89
95
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
103
109
104
110
### Notes
105
111
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.
107
113
108
114
The version for the operator image is identical to the version for the SQL Server image.
Create and manage your SQL Server instances natively in Kubernetes.
19
19
20
20
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.
21
21
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
+
22
28
## Container with SQL Server instance on Kubernetes
23
29
24
30
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
33
39
34
40
SQL Server 2017 and later support containers on Kubernetes.
35
41
42
+
To create a container in Kubernetes, see [Deploy a SQL Server container in Kubernetes](tutorial-sql-server-containers-kubernetes.md)
43
+
36
44
## A SQL Server Always On availability group on SQL Server containers in Kubernetes
37
45
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.
39
47
40
48

41
49
@@ -45,7 +53,7 @@ In the image above, a four-node kubernetes cluster hosts an availability group w
45
53
46
54
* Three nodes, each hosting a [*StatefulSet*](http://kubernetes.io/docs/concepts/workloads/controllers/statefulset/). The StatefulSet contains a pod. Each pod contains:
47
55
* 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.
49
57
50
58
* Two [*ConfigMaps*](http://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/) related to the availability group. The ConfigMaps provide information about:
# 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)
# 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.
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`.
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/).
0 commit comments