DxOperator Quick Start Guide
DxOperator is a software extension to Kubernetes that uses custom resource definitions to automate the deployment of DxEnterprise clusters. DxEnterprise then provides all of the instrumentation to create, configure, manage and provide automatic failover for Microsoft SQL Server availability group workloads in Kubernetes.
Prerequisites
-
A Kubernetes cluster installed with at least 4GB of RAM.
-
An internet connection.
Install DxOperator
-
Download the DxOperator YAML.
wget https://dxoperator.dh2i.com/dxesqlag/files/v1.yaml
-
Apply the DxOperator YAML.
kubectl apply -f v1.yaml
Create a DxEnterpriseSqlAg
-
Create secrets for the DxEnterprise passkey, license key and the SQL Server SA account.
kubectl create secret generic dxe --from-literal=DX_PASSKEY=<pass> --from-literal=DX_LICENSE=<license_key>
kubectl create secret generic mssql --from-literal=MSSQL_SA_PASSWORD=<pass>
-
(OPTIONAL) Apply a ConfigMap YAML for the
mssql.conf
file.infoSee the Microsoft documentation for all supported variables for MSSQL.
kind: ConfigMap
apiVersion: v1
metadata:
name: mssql-config
data:
mssql.conf: |
[EULA]
accepteula = Y
[network]
tcpport = 1433
[sqlagent]
enabled = truekubectl apply -f configmap.yaml
-
Copy the example
DxEnterpriseSqlAg.yaml
file below or download the file.infoThere are many configuration options for the DxEnterpriseSqlAg custom resource beyond those that are shown in this example. View the DxEnterpriseSqlAg API Reference for more information.
DxEnterpriseSqlAg.yamlapiVersion: dh2i.com/v1
kind: DxEnterpriseSqlAg
metadata:
name: dxesqlag
spec:
synchronousReplicas: 3
asynchronousReplicas: 0
# ConfigurationOnlyReplicas are only allowed with availabilityGroupClusterType set to EXTERNAL
configurationOnlyReplicas: 0
availabilityGroupName: AG1
# Listener port for the availability group (uncomment to apply)
#availabilityGroupListenerPort: 14033
# For a contained availability group, add the option CONTAINED
availabilityGroupOptions: null
# Valid options are EXTERNAL (automatic failover) and NONE (no automatic failover)
availabilityGroupClusterType: EXTERNAL
createLoadBalancers: true
template:
metadata:
labels:
label: example
annotations:
annotation: example
spec:
dxEnterpriseContainer:
image: "docker.io/dh2i/dxe:latest"
imagePullPolicy: Always
acceptEula: true
clusterSecret: dxe
vhostName: VHOST1
joinExistingCluster: false
# QoS – guaranteed (uncomment to apply)
#resources:
#limits:
#memory: 1Gi
#cpu: '1'
# Configuration options for the required persistent volume claim for DxEnterprise
volumeClaimConfiguration:
storageClassName: null
resources:
requests:
storage: 1Gi
mssqlServerContainer:
image: "mcr.microsoft.com/mssql/server:latest"
imagePullPolicy: Always
mssqlSecret: mssql
acceptEula: true
mssqlPID: Developer
mssqlConfigMap: null
# QoS – guaranteed (uncomment to apply)
#resources:
#limits:
#memory: 2Gi
#cpu: '2'
# Configuration options for the required persistent volume claim for SQL Server
volumeClaimConfiguration:
storageClassName: null
resources:
requests:
storage: 2Gi
# Additional side-car containers, such as mssql-tools (uncomment to apply)
#containers:
#- name: mssql-tools
#image: "mcr.microsoft.com/mssql-tools"
#command: [ "/bin/sh" ]
#args: [ "-c", "tail -f /dev/null" ]cautionIf you applied a ConfigMap in the previous optional step, you need to modify the
spec.mssqlServerContainer.mssqlConfigMap
value, otherwise the ConfigMap will not be applied:mssqlConfigMap: mssql-config
-
Apply the DxEnterpriseSqlAg custom resource YAML.
kubectl apply -f DxEnterpriseSqlAg.yaml
-
Verify the deployment.
kubectl get pods
-
Verify load balancer assignments.
kubectl get services
Creating an Availability Group Listener
-
In the DxEnterpriseSqlAg
spec
, add a new entry for the AG Listener.spec:
availabilityGroupListenerPort: 14033 -
Apply the below service YAML to add a load balancer for the listener.
infoMake sure to set the selector to
dh2i.com/entity: <DxEnterpriseSqlAg_name>
, using the name that was applied in theDxEnterpriseSqlAg.yaml
above.Example Load Balancer ServiceapiVersion: v1
kind: Service
metadata:
name: dxemssql-cluster-lb
spec:
type: LoadBalancer
selector:
dh2i.com/entity: beta2
ports:
- name: sql
protocol: TCP
port: 1433
targetPort: 1433
- name: listener
protocol: TCP
port: 14033
targetPort: 14033
- name: dxe
protocol: TCP
port: 7979
targetPort: 7979 -
Verify the load balancer assignments.
kubectl get services
Removing Custom Resources and DxOperator
The below steps will allow you to delete the custom resources and PVCs to redeploy with the same operator (steps 1 & 2). Or you can optionally also delete DxOperator completely (step 3).
-
Delete the DxEnterpriseSqlAg custom resource YAML.
kubectl delete -f DxEnterpriseSqlAg.yaml
-
Delete the persistent volume claims (PVC).
kubectl delete pvc --all
-
Delete the DxOperator YAML.
dangerRunning this command will delete the DxEnterpriseSqlAg CRD. If any DxEnterpriseSqlAg custom resources remain in the Kubernetes cluster, Kubernetes will destroy them as part of the deletion process. Only run this command if you intend on removing every DxEnterpiseSqlAg too!
To list all DxEnterpriseSqlAgs, run 'kubectl get dxesqlag'.
kubectl delete -f v1.yaml