Skip to content

Commit 0e12922

Browse files
authored
Merge pull request #744 from jamesongithub/jy/rancher
A chart that can be used readuly for deploying SQL Server using Rancher. Add questions.yml and app-readme.md for rancher chart
2 parents 92247bf + 136a48f commit 0e12922

File tree

16 files changed

+486
-3
lines changed

16 files changed

+486
-3
lines changed

linux/rancher/Chart.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
apiVersion: v2
2+
name: sql-server-rancher
3+
description: A Helm chart for SQL Server on Rancher
4+
5+
# A chart can be either an 'application' or a 'library' chart.
6+
#
7+
# Application charts are a collection of templates that can be packaged into versioned archives
8+
# to be deployed.
9+
#
10+
# Library charts provide useful utilities or functions for the chart developer. They're included as
11+
# a dependency of application charts to inject those utilities and functions into the rendering
12+
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
13+
type: application
14+
15+
# This is the chart version. This version number should be incremented each time you make changes
16+
# to the chart and its templates, including the app version.
17+
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18+
version: 0.0.1
19+
20+
# This is the version number of the application being deployed. This version number should be
21+
# incremented each time you make changes to the application. Versions are not expected to
22+
# follow Semantic Versioning. They should reflect the version the application is using.
23+
appVersion: 2019.cu15
24+
25+
icon: https://docs.microsoft.com/vi-vn/troubleshoot/media/hub-landing/sql-database-blue.svg

linux/rancher/Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.PHONY: lint dry-run
2+
3+
lint:
4+
helm lint --values ./values.test.yaml
5+
6+
template:
7+
helm template --values ./values.test.yaml . --debug

linux/rancher/Readme

Lines changed: 0 additions & 1 deletion
This file was deleted.

linux/rancher/app-readme.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# SQL Server
2+
3+
[Microsoft SQL Server](https://en.wikipedia.org/wiki/Microsoft_SQL_Server/) is a relational database management system developed by Microsoft. As a database server, it is a software product with the primary function of storing and retrieving data as requested by other software applications—which may run either on the same computer or on another computer across a network (including the Internet). Microsoft markets at least a dozen different editions of Microsoft SQL Server, aimed at different audiences and for workloads ranging from small single-machine applications to large Internet-facing applications with many concurrent users.
4+
5+
This helm chart creates a SQL Server workload using StatefulSet along with a Service and Azure Disk storage class.

linux/rancher/questions.yml

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
questions:
2+
- variable: ACCEPT_EULA
3+
label: ACCEPT_EULA
4+
# no current support for html
5+
# description: Accepts the SQL Server <a href="http://go.microsoft.com/fwlink/?LinkId=746388">EULA</a> (any value confirms acceptance).
6+
description: Accepts the SQL Server EULA (any value confirms acceptance). The EULA is posted @ http://go.microsoft.com/fwlink/?LinkId=746388
7+
required: true
8+
group: SQL Server options
9+
10+
- variable: USE_PRODUCT_KEY
11+
label: Use a SQL Server Product Key
12+
description: Enter a Product Key instead of choosing a SQL Server Edition
13+
type: boolean
14+
default: false
15+
group: SQL Server options
16+
17+
- variable: MSSQL_PID
18+
label: SQL Server Edition aka. MSSQL_PID
19+
description: Select a SQL Server Edition
20+
type: enum
21+
options:
22+
- Evaluation
23+
- Developer
24+
- Express
25+
- Web
26+
- Standard
27+
- Enterprise
28+
required: true
29+
show_if: USE_PRODUCT_KEY=false
30+
group: SQL Server options
31+
32+
- variable: MSSQL_PID
33+
label: SQL Server License Key
34+
description: Enter a Product Key of the format "#####-#####-#####-#####-#####"
35+
required: true
36+
show_if: USE_PRODUCT_KEY=true
37+
group: SQL Server options
38+
39+
- variable: MSSQL_SA_PASSWORD
40+
label: MSSQL SA user password
41+
description: Sets the SA user password. Password requirements @ https://docs.microsoft.com/en-us/sql/relational-databases/security/password-policy?view=sql-server-ver15#password-complexity
42+
type: password
43+
min: 8
44+
max: 128
45+
default: ""
46+
valid_chars: a-zA-Z0-9(`~!@#$%^&*_-+=|\\{}[]:;\"'<>,.?)/
47+
required: true
48+
group: SQL Server options
49+
50+
- variable: MSSQL_AGENT_ENABLED
51+
label: Enable SQL Server Agent
52+
description: Enables the SQL Server Agent
53+
type: boolean
54+
group: SQL Server options
55+
56+
- variable: defaultContainerImage
57+
label: Use default SQL Server container image
58+
type: boolean
59+
default: true
60+
show_subquestion_if: false
61+
group: Container Image Options
62+
subquestions:
63+
- variable: image.repository
64+
default: mcr.microsoft.com/mssql/server
65+
description: Image Repository
66+
label: Image Repository
67+
- variable: image.pullPolicy
68+
default: IfNotPresent
69+
label: Image Pull Policy
70+
type: enum
71+
options:
72+
- IfNotPresent
73+
- Always
74+
- Never
75+
- variable: image.tag
76+
default: 2019-latest
77+
label: Image Tag
78+
79+
- variable: replicas
80+
description: Replicas of the SQL Server StatefulSet
81+
label: Replicas
82+
type: int
83+
group: Kubernetes StatefulSet options
84+
85+
- variable: podSecurityContext.fsGroup
86+
description: |
87+
Specifies a supplementary group id for all processes of the container.
88+
See https://kubernetes.io/docs/tasks/configure-pod-container/security-context for
89+
additional details.
90+
label: podSecurityContext.fsGroup
91+
group: Kubernetes Pod options
92+
93+
- variable: containers.ports.containerPort
94+
description: >
95+
Specifies containerPort for SQL Server
96+
label: SQL Server Container Port
97+
group: Kubernetes Pod Options
98+
99+
- variable: service.port
100+
description: Kubernetes service port for SQL Server
101+
group: Kubernetes Service Options
102+
label: Kubernetes Service Port
103+
type: int

linux/rancher/readme.md

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
# Readme.md
2+
3+
This HELM chart is a sample "as-is" chart provided for reference to help guide with SQL Server deployment on Kubernetes cluster.
4+
5+
## Prerequisites:
6+
7+
1. This chart is built on helm v3. It requires a kubernetes cluster to be running for you to deploy SQL container using this chart.
8+
2. Ensure you have the helm installed on the client from where you will connect to the kubernetes cluster to deploy using the helm chart.
9+
3. For minimum hardware requirement for the host to run SQL Server containers please refer to the system requirements section for SQL on Linux.
10+
4. Requires the following variables to be set or changed in the values.yaml file :<br/>
11+
a. Please ensure that you accept the EULA for SQL Server, by changing the value of ACCEPT_EULA.value=y in values.yaml file or set it during the helm install command --set ACCEPT_EULA.value=Y.<br/>
12+
b. Please do choose the right edition of SQL Server that you would like to install you can change the value of the MSSQL_PID.value in the values file to the edition that you want to install or you can also
13+
change it during the helm install command using the option --set MSSQL_PID.value=Enterprise, If you do not pass the flag and do not change it in the yaml, then by default it is going to install developer edition.<br/> c. Also please do provide your customized value for the sa_password, if you do not provide it then by default the sa_password will the value as shown in the below table.<br/>
14+
15+
Note: Once you deploy SQL server containers using the chart below, please log into SQL Server using sa account and change the password for sa, this ensures that as DBA you have the control of the sa user and password.
16+
17+
18+
## Chart usage:
19+
20+
On the client machine where you have the Helm tools installed, download the chart on your machine and make the required changes to the values.yaml file as per your requirement. To see the list of settings that can be changed using the values.yaml file please refer to the table below.
21+
22+
23+
24+
| Configuration parameters | Description | Default_Value |
25+
|----------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------- |
26+
| Values.image.repository | The SQL image to be downloaded and used for container deployment. | mcr.microsoft&#46;com/mssql/server |
27+
| Values.image.tag | The tag of the image to be download for the specific SQL image. | 2019-latest |
28+
| Values.ACCEPT_EULA.value | Set the ACCEPT_EULA variable to any value to confirm your acceptance of the SQL Server EULA, please refer environment variable for more details. | Y |
29+
| Values.MSSQL_PID.value | Set the SQL Server edition or product key. please refer environment variable for more details | Developer |
30+
| Values.MSSQL_AGENT_ENABLED.value | Enable SQL Server Agent. For example, 'true' is enabled and 'false' is disabled. By default, agent is disabled. please refer environment variable for more details. | TRUE |
31+
| Values.containers.ports.containerPort | Port on which the SQL Server is listening inside the container. | 1433 |
32+
| Values.podSecurityContext.fsgroup | Security context at the pod level. | 10001 |
33+
| Values.service.port | The service port number. | 1433 |
34+
| Values.replicas | This value controls the number of SQL Server deployments that would be done, consider this as the number of SQL Server instances that will run. | 3 |
35+
36+
<br/>
37+
38+
## Deployment details:
39+
40+
> [!NOTE]
41+
> Here are my deployment details, please make changes to the values.yaml or other files as per your requirement.
42+
43+
<br/>
44+
45+
In this scenario, I am deploying three SQL Server containers on a Azure Kubernetes Service (AKS) as statefulset deployments. You can follow [Setup and connect to AKS](https://docs.microsoft.com/en-us/azure/aks/kubernetes-walkthrough-portal) to read instructions on setting up AKS and connecting to it. Also the storage class that I am using here is "Azure-disk". Please do find details below for each of the yaml file used in the template folder of this chart.
46+
47+
| File Name | Description |
48+
|-|-|
49+
| _helpers.tpl | Template file with all the template definitions that will be used in this chart. |
50+
| deployment.yaml | A manifest file to describing the deployment details for SQL Server. |
51+
| mssqlconfig.yaml | SQL server mssql.conf file and its content that you would like to mount to the SQL Server container. For parameters that you can pass in this file please refer mssql.conf documentation. To modify the mssql.conf settings please modify this file. |
52+
| sc.yaml | A manifest file that describes the storage class (SC) to be deployed. To make any changes to the sc please modify this file accordingly. |
53+
| service.yaml | A manifest file that defines the kubernetes service type and port. Because this is a statefulset deployment, this manifest files helps in creating the headless service. Please modify this for any service modification that is needed. |
54+
55+
<br/>
56+
57+
With this information, and probably after you have modified the required files you are now ready to deploy SQL Server using this chart. From the client machine where you have the helm chart installed, change the
58+
directory of the CLI to the directory where you have the chart downloaded and to deploy SQL Server using this chart run the command:
59+
<br/>
60+
61+
62+
``` bash
63+
helm install mssql . --set ACCEPT_EULA.value=Y --set MSSQL_PID.value=Developer
64+
```
65+
<br/>
66+
67+
After a few minutes this should deploy the SQL Server containers and you can see all the artifacts using the command :
68+
<br/>
69+
70+
```bash
71+
D:\helm-charts\sql-server-rancher>kubectl get all
72+
```
73+
74+
The output should look as shown below:
75+
76+
<br/>
77+
78+
```bash
79+
NAME READY STATUS RESTARTS AGE
80+
pod/mssql-sql-server-rancher-0 1/1 Running 0 12m
81+
pod/mssql-sql-server-rancher-1 1/1 Running 0 12m
82+
pod/mssql-sql-server-rancher-2 1/1 Running 0 12m
83+
84+
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
85+
service/mssql-sql-server-rancher ClusterIP None <none> 1433/TCP 16m
86+
87+
NAME READY AGE
88+
statefulset.apps/mssql-sql-server-rancher 3/3 16m
89+
```
90+
91+
This chart also includes an extra folder called "services" this folder has two more manifest files as described below:
92+
93+
| Name | Description |
94+
|------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
95+
| ex_service.yaml | This containes sample code to create the external load balancer service for each of the pods created above, so SQL Server can be accessed outside the cluster |
96+
| ag_endpoint.yaml | This containes sample code to expose the AG endpoint ports within the cluster, so each pod can talk to one another on the AG port. This will be needed if you are setting up AG between the pods. |
97+
98+
<br/>
99+
100+
Once you deploy the above files as well, using the commands shown below, you should have an external load balancer service created for each of the pods and another cluster IP service for each of the pod exposing the AG (alwayson) port for each pod within the cluster.
101+
102+
103+
```bash
104+
D:\helm-charts\sql-server-rancher>kubectl apply -f "D:\helm-charts\sql-server-rancher\services\ex_service.yaml"
105+
D:\helm-charts\sql-server-rancher>kubectl apply -f "D:\helm-charts\sql-server-rancher\services\ag_endpoint.yaml"
106+
```
107+
108+
109+
Finally, after all the deployments here are the resources that you should see:
110+
111+
112+
```bash
113+
D:\>kubectl get all
114+
NAME READY STATUS RESTARTS AGE
115+
pod/mssql-sql-server-rancher-0 1/1 Running 0 127m
116+
pod/mssql-sql-server-rancher-1 1/1 Running 0 126m
117+
pod/mssql-sql-server-rancher-2 1/1 Running 0 125m
118+
119+
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
120+
service/kubernetes ClusterIP 10.0.0.1 <none> 443/TCP 220d
121+
service/mssql-mirror-0 ClusterIP 10.0.148.0 <none> 5022/TCP 124m
122+
service/mssql-mirror-1 ClusterIP 10.0.254.58 <none> 5022/TCP 124m
123+
service/mssql-mirror-2 ClusterIP 10.0.196.129 <none> 5022/TCP 124m
124+
service/mssql-sql-server-rancher ClusterIP None <none> 1433/TCP 127m
125+
service/mssql-sql-server-rancher-0 LoadBalancer 10.0.238.203 104.211.231.206 1433:30923/TCP 124m
126+
service/mssql-sql-server-rancher-1 LoadBalancer 10.0.96.108 104.211.203.78 1433:32695/TCP 124m
127+
service/mssql-sql-server-rancher-2 LoadBalancer 10.0.78.10 104.211.203.159 1433:31042/TCP 124m
128+
129+
NAME READY AGE
130+
statefulset.apps/mssql-sql-server-rancher 3/3 127m
131+
```
132+
133+
## Connect to SQL Server
134+
135+
Now you are ready to connect to the SQL Server using any of the familiar tools that you work with, like the [SSMS](https://docs.microsoft.com/en-us/sql/ssms/download-sql-server-management-studio-ssms?view=sql-server-ver15) (SQL Server Management Studio) or [SQLCMD](https://docs.microsoft.com/en-us/sql/tools/sqlcmd-utility?view=sql-server-ver15) or [ADS](https://docs.microsoft.com/en-us/sql/azure-data-studio/download-azure-data-studio?view=sql-server-ver15) (Azure Data Studio), etc. The IP address that you will use to connect is the External-IP address for the pod service which in this case one such example is: to connect to mssql-sql-server-rancher-0 SQL Server, the IP address 104.211.231.206 will be used in ssms or any other client.
136+
137+
For more details on the SQL Server deployment on AKS using manual method please refer [Deploy a SQL Server container in Kubernetes with Azure Kubernetes Services (AKS)](https://docs.microsoft.com/en-us/sql/linux/tutorial-sql-server-containers-kubernetes?view=sql-server-ver15).
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "sql-server-rancher.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11+
If release name contains chart name it will be used as a full name.
12+
*/}}
13+
{{- define "sql-server-rancher.fullname" -}}
14+
{{- if .Values.fullnameOverride }}
15+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
16+
{{- else }}
17+
{{- $name := default .Chart.Name .Values.nameOverride }}
18+
{{- if contains $name .Release.Name }}
19+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
20+
{{- else }}
21+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
22+
{{- end }}
23+
{{- end }}
24+
{{- end }}
25+
26+
{{/*
27+
Create chart name and version as used by the chart label.
28+
*/}}
29+
{{- define "sql-server-rancher.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "sql-server-rancher.labels" -}}
37+
helm.sh/chart: {{ include "sql-server-rancher.chart" . }}
38+
{{ include "sql-server-rancher.selectorLabels" . }}
39+
{{- if .Chart.AppVersion }}
40+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
41+
{{- end }}
42+
app.kubernetes.io/managed-by: {{ .Release.Service }}
43+
{{- end }}
44+
45+
{{/*
46+
Selector labels
47+
*/}}
48+
{{- define "sql-server-rancher.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "sql-server-rancher.name" . }}
50+
app.kubernetes.io/instance: {{ .Release.Name }}
51+
{{- end }}
52+
53+
{{/*
54+
Create the name of the service account to use
55+
*/}}
56+
{{- define "sql-server-rancher.serviceAccountName" -}}
57+
{{- if .Values.serviceAccount.create }}
58+
{{- default (include "sql-server-rancher.fullname" .) .Values.serviceAccount.name }}
59+
{{- else }}
60+
{{- default "default" .Values.serviceAccount.name }}
61+
{{- end }}
62+
{{- end }}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
kind: ConfigMap
2+
apiVersion: v1
3+
metadata:
4+
name: mssql
5+
data:
6+
mssql.conf: |
7+
[EULA]
8+
accepteula = Y
9+
accepteulaml = Y
10+
11+
[coredump]
12+
captureminiandfull = true
13+
coredumptype = full
14+
15+
[hadr]
16+
hadrenabled = 1
17+
18+
[language]
19+
lcid = 1033

linux/rancher/templates/sc.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
kind: StorageClass
2+
apiVersion: storage.k8s.io/v1
3+
metadata:
4+
name: azure-disk
5+
provisioner: kubernetes.io/azure-disk
6+
parameters:
7+
storageaccounttype: Standard_LRS
8+
kind: Managed

linux/rancher/templates/secret.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
apiVersion: v1
2+
kind: Secret
3+
metadata:
4+
name: mssql-secret
5+
labels:
6+
{{- include "sql-server-rancher.labels" . | nindent 4 }}
7+
type: Opaque
8+
data:
9+
mssql_sa_password : {{ .Values.MSSQL_SA_PASSWORD | b64enc | quote }}

0 commit comments

Comments
 (0)