mssqlserver-2019

by prom3theu5

Helm chartv1.2.3App 2019-CU16-ubuntu-20.04

SQL Server 2019 Linux Helm Chart

About this chart

HELM Chart for Microsoft SQL Server 2019 on Linux

Prerequisites

  • This chart requires Docker Engine 1.8+ in any of their supported platforms. Please see vendor requirements here for more information.
  • At least 2GB of RAM (3.25 GB prior to 2017-CU2). Make sure to assign enough memory to the Docker VM if you're running on Docker for Mac or Windows.
  • Requires the following variables
    • You must change the acceptEula.value in the values.yaml file to Y or include --set acceptEula.value=Y in the command line of helm install to override the default value of N.

    • You must change the editions variable in the values.yaml file to include the edition of SQL Server or include --set edition.value=<your_product_id | edition_name> in the command line of helm install.

    • You must change the acceptEula.value in the values.yaml file to Y or include --set acceptEula.value=Y in the command line of helm install to override the default value of N.

Chart Components

  • Creates a SQL Server 2019 deployment (default edition: Express)
  • Creates a Kubernetes Service on specified port (default: 1433)
  • Creates a Secert to hold SA_PASSWORD

Installing the Chart

You can install the chart with the release name mymssql as below.

$ helm install --name mymssql <helm-repo>/mssql-linux --set acceptEula.value=Y --set edition.value=Developer
...

$ helm install --name mymssql stable/mssql-linux --set acceptEula.value=Y --set edition.value=Developer

Note - If you do not specify a name, helm will select a name for you.

Installed Components

You can use kubectl get to view all of the installed components.

$ kubectl get all -l app=mssql-linux
NAME                                DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
deploy/mymssql-mssql-linux          1         1         1            1           9m

NAME                                DESIRED   CURRENT   READY     AGE
rs/mymssql-mssql-linux-8688756468   1         1         1         9m

NAME                                DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
deploy/mymssql-mssql-linux          1         1         1            1           9m

NAME                                DESIRED   CURRENT   READY     AGE
rs/mymssql-mssql-linux-8688756468   1         1         1         9m

NAME                                      READY     STATUS    RESTARTS   AGE
po/mymssql-mssql-linux-8688756468-x758g   1/1       Running   0          9m

NAME                      TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)    AGE
svc/mymssql-mssql-linux   ClusterIP   10.104.152.61   <none>        1433/TCP   9m

SA Password Retrieval

The sa password is a randomized in the secret.yaml file. To retrieve the password, perform the following steps once you install the helm chart.

$ printf $(kubectl get secret --namespace default mymssql-mssql-linux-secret -o jsonpath="{.data.sapassword}" | base64 --decode);echo
...

Connecting to SQL Server Instance

  1. Run the following command

This command will create a pod called mssqlcli that will include the SQL Server Commandline sqlcmd and start at a bash prompt.

$ kubectl run mssqlcli --image=mcr.microsoft.com/mssql-tools -ti --restart=Never --rm=true -- /bin/bash
$ sqlcmd -S mymssql-mssql-linux -U sa
Password: <Enter SA Password>
$ 1> select @@VERSION;
$ 2> go
------------------------------------------------------------------------------------
Microsoft SQL Server 2019
Dec 22 2017 16:13:22
Copyright (C) 2017 Microsoft Corporation
Express Edition (64-bit) on Linux (Ubuntu 16.04.3 LTS)
(1 rows affected)

Values

The configuration parameters in this section control the resources requested and utilized by the SQL Server instance.

ParameterDescriptionDefault
acceptEula.valueEULA that needs to be accepted. It will need to be changed via commandline or values.yaml.n
edition.valueThe edition of SQL Server to install. See section Editions.Developer
sapasswordPassword for sa loginRandom (20-AlphNum)1
image.repositoryThe docker hub repo for SQL Servermcr.microsoft.com/mssql/server
image.tagThe tag for the image2017-CU5
image.pullPolicyThe pull policy for the deploymentIfNotPresent
image.pullSecretsSpecify an image pull secret if neededCommented Out
nodeSelectorNode labels for pod assignment{}
service.headlessAllows you to setup a headless servicefalse
service.typeService TypeClusterIP
service.portService Port1433
service.nodePortService NodePortRandom Port
service.annotationsKubernetes service annotations{}
service.labelsKubernetes service labels{}
deployment.annotationsKubernetes deployment annotations{}
deployment.labelsKubernetes deployment labels{}
pod.annotationsKubernetes pod annotations{}
pod.labelsKubernetes pod labels{}
collationDefault collation for SQL ServerSQL_Latin1_General_CP1_CI_AS
dataDirSpecify the default SQL data directory/var/opt/mssql
lcidDefault languages for SQL Server1033
hadrEnable Availability Group0
replicaCountSet the number of replica1
persistence.enabledPersist the Data and Log files for SQL Serverfalse
persistence.existingDataClaimIdentify an existing Claim to be used for the Data DirectoryCommented Out
persistence.storageClassStorage Class to be usedCommented Out
persistence.dataAccessModeData Access Mode to be used for the Data DirectoryReadWriteOnce
persistence.dataSizePVC Size for Data Directory1Gi

1 - Please read password requirements

Liveness and Readiness

The SQL Server instance has liveness and readiness checks specified. These parameters can be used to tune the sensitivity of the liveness and readiness checks.

Liveness Probes

ParameterDescriptionDefault
livenessprobe.initialDelaySecondsTells the kubelet that it should wait XX second(s) before performing the first probe15
livenessprobe.periodSecondsField specifies that the kubelet should perform a liveness probe every XX seconds(s)20

Readiness Probes

ParameterDescriptionDefault
readinessprobe.initialDelaySecondsTells the kubelet that it should wait XX second(s) before performing the first probe5
readinessprobe.periodSecondsField specifies that the kubelet should perform a liveness probe every XX second(s)10

Resources

You can specify the resource limits for this chart in the values.yaml file. Make sure you comment out or remove the curly brackets from the values.yaml file before specifying resource limits. Example:

resources:
  limits:
    cpu: 1
    memory: 2Gi
  requests:
    cpu: 0.5
    memory: 2Gi

Persistence Examples

Persistence in this chart can be enabled by specifying persistence.enabled=true. The path to the database's data and log files can be customized to fit different requirements.

  • Example 1 - Enable persistence in values.yaml without specifying claim

Note - This is useful for local development in a minikube environment

persistence:
  enabled: true
  # existingDataClaim:
  # existingTransactionLogClaim:
  # storageClass: "-"
  dataAccessMode: ReadWriteOnce
  dataSize: 1Gi
  logAccessMode: ReadWriteOnce
  logSize: 1Gi
  • Example 2 - Enable persistence in values.yaml with existing claim

Note - This is useful for production based environments for persistence volumes and claims already exist.

persistence:
  enabled: true
  existingDataClaim: pvc-mssql-data
  existingTransactionLogClaim: pvc-mssql-log
  # storageClass: "-"
  # dataAccessMode: ReadWriteOnce
  # dataSize: 1Gi
  # logAccessMode: ReadWriteOnce
  # logSize: 1Gi

SQL Server for Linux Editions

Below are the supported versions of SQL Server on Linux. You can find out more information here.

  • Developer : This will run the container using the Developer Edition (this is the default if no MSSQL_PID environment variable is supplied)
  • Express : This will run the container using the Express Edition
  • Standard : This will run the container using the Standard Edition
  • Enterprise : This will run the container using the Enterprise Edition
  • EnterpriseCore : This will run the container using the Enterprise Edition Core
  • Product ID: This will run the container with the edition that is associated with the PID

Collation and Language Support

You can change the collation of the MSSQL installation by changing the collation key in the values.yaml file. More information about Collation and Unicode Support can be found on the Microsoft Docs Page.

To change the language of the MSSQL installation, change the lcid key in the values.yaml. More informationa about languages can be found using the system view sys.syslanguages. A list of available languages can be found here.

  • Example 1 - Retrieve Collation and Language
1>select substring(convert(varchar(30),serverproperty('Collation')),1,30), substring(convert(varchar(20),serverproperty('lcid')),1,20);
2>go

Master database files

As part of this chart the master database is configured to be installed based in the /mssql-data/master.

HADR

As part of this chart you can enable your SQL Server container for Availability Groups. As an administrator, you will need to configure additional settings once this options is enabled. For more information on Availability Group(s) click here for more information.

Query to determine if HADR is enabled

1>SELECT SERVERPROPERTY ('IsHadrEnabled');
2>go

Deploy mssqlserver-2019 with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has mssqlserver-2019 on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartmssqlserver-2019 is pinned at v1.2.3 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply