Skip to content
This repository has been archived by the owner on Feb 22, 2022. It is now read-only.

Commit

Permalink
SQL Server 2017 Linux HELM Chart (#3246)
Browse files Browse the repository at this point in the history
* Create SQL Server 2017 Linux HELM Chart

* Fixed spaces for ci/circleci

* Fixed spaces for ci/circleci #2

* Fixed spaces for ci/circleci #3

* Added secret yaml to deployment for SA Password

* Updated the chart to force user to specify EULA to Y for license terms

* Updated README.md to reflect commandline option to accept EULA

* Updated README.md and secret.yaml for sa_password generation

* Fixed formatting error in NOTES.txt

* Changed apiVersion in deployments.yaml to apps/v1beta2

* Allowed ability to override sapassword and change apiVersion in deployment.yaml

* ci/circleci fixes

* Updated release version, README.md, and hard-coded ports

* Added port name, configured probes, moved to stable

* Updated README.md
  • Loading branch information
thomasliddledba authored and k8s-ci-robot committed Feb 2, 2018
1 parent 0205ce7 commit 0c1830e
Show file tree
Hide file tree
Showing 8 changed files with 284 additions and 0 deletions.
10 changes: 10 additions & 0 deletions stable/mssql-linux/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
description: SQL Server 2017 Linux Helm Chart
name: mssql-linux
version: 0.1.6
icon: https://img-prod-cms-rt-microsoft-com.akamaized.net/cms/api/am/imageFileData/RE1I4Dx
sources:
- https://hub.docker.com/r/microsoft/mssql-server-linux/
maintainers:
- name: thomasliddledba
email: [email protected]
118 changes: 118 additions & 0 deletions stable/mssql-linux/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
# HELM Chart for Microsoft SQL Server 2017 on Linux

## Prerequisites
* This chart requires Docker Engine 1.8+ in any of their supported platforms. Please see vendor requirements [here for more information](https://docs.microsoft.com/en-us/sql/linux/quickstart-install-connect-docker).
* 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`.

## Chart Components
* Creates a SQL Server 2017 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.
```console
$ 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.

```console
$ 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 randonmized in the secret.yaml file. To retrieve the password, perform the following steps once you install the helm chart.
```console
$ kubectl exec mymssql-mssql-linux-8688756468 -- env | grep SA_PASSWORD
```

## 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.
```console
$ kubectl run mssqlcli --image=microsoft/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 2017 (RTM-CU3-GDR) (KB4052987) - 14.0.3015.40 (X64)
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.

| Parameter | Description | Default |
| --------- | ----------- | ------- |
| acceptEula.value | EULA that needs to be accepted. It will need to be changed via commandline or values.yaml. | N |
| edition.value | The edition of SQL Server to install. See section [Editions](#sql-server-for-linux-editions). | Express |
| sapassword | Overrides the randomly created password with a default password. [Please read password requirements](https://docs.microsoft.com/en-us/sql/relational-databases/security/password-policy). | Random (20-AlphNum) |
| image.repository | The docker hub repo for SQL Server | microsoft/mssql-server-linux |
| image.tag | The tag for the image | 2017-CU3 |
| image.pullPolicy | The pull policy for the deployment | IfNotPresent |
| service.name | Service Name | mssqlsrvr |
| service.type | Service Type | ClusterIP |

## 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
| Parameter | Description | Default |
| --------- | ----------- | ------- |
| livenessprobe.initialDelaySeconds | Tells the kubelet that it should wait XX second(s) before performing the first probe | 15 |
| livenessprobe.periodSeconds | Field specifies that the kubelet should perform a liveness probe every XX seconds(s) | 20 |

### Readiness Probes
| Parameter | Description | Default |
| --------- | ----------- | ------- |
| readinessprobe.initialDelaySeconds | Tells the kubelet that it should wait XX second(s) before performing the first probe | 5 |
| readinessprobe.periodSeconds | Field 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:
```yaml
resources:
limits:
cpu: 1
memory: 2Gi
requests:
cpu: 0.5
memory: 2Gi
```
## SQL Server for Linux Editions
Below are the supported versions of SQL Server on Linux. You can find out more information [here](https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-editions-and-components-2017).
* 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
25 changes: 25 additions & 0 deletions stable/mssql-linux/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
License Terms for MSSQL Server
Please read the License Terms Carefully. The can be found End-User Licensing Agreement.


License Terms: https://go.microsoft.com/fwlink/?linkid=857698
Docker Hub Resource: https://hub.docker.com/r/microsoft/mssql-server-linux

Note - By Default the Express Edition is installed as part of this Chart.
Edition for this installation: {{ .Values.edition.value }}


1. You can test that SQL Server is available by the service port with with the following set of command:
(Note: You will be prompted for the SA password)
$ kubectl run mssqlcli --image=microsoft/mssql-tools -ti --restart=Never --rm=true -- /bin/bash
$ sqlcmd -S {{ template "mssql.fullname" . }}.{{ .Release.Namespace }},1433 -U sa
$ Password: <Enter Password for SA>

2. Connection Library Information
https://docs.microsoft.com/en-us/sql/connect/sql-connection-libraries

3. Connecting with JDBC
https://docs.microsoft.com/en-us/sql/connect/jdbc/connecting-to-sql-server-with-the-jdbc-driver

SQL Server Name: {{ template "mssql.fullname" . }}.{{ .Release.Namespace }}
Port: 1433
16 changes: 16 additions & 0 deletions stable/mssql-linux/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "mssql.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "mssql.fullname" -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
54 changes: 54 additions & 0 deletions stable/mssql-linux/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
apiVersion: apps/v1beta2
kind: Deployment
metadata:
name: {{ template "mssql.fullname" . }}
labels:
app: {{ template "mssql.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app: {{ template "mssql.name" . }}
release: {{ .Release.Name }}
template:
metadata:
labels:
app: {{ template "mssql.name" . }}
release: {{ .Release.Name }}
spec:
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
- name: ACCEPT_EULA
value: "{{ .Values.acceptEula.value | upper }}"
- name: MSSQL_PID
value: "{{ .Values.edition.value }}"
- name: SA_PASSWORD
valueFrom:
secretKeyRef:
name: {{ template "mssql.fullname" . }}-secret
key: sapassword
ports:
- name: db
containerPort: 1433
livenessProbe:
tcpSocket:
port: db
initialDelaySeconds: {{ .Values.livenessprobe.initialDelaySeconds }}
periodSeconds: {{ .Values.livenessprobe.periodSeconds }}
readinessProbe:
tcpSocket:
port: db
initialDelaySeconds: {{ .Values.readinessprobe.initialDelaySeconds }}
periodSeconds: {{ .Values.readinessprobe.periodSeconds }}
resources:
{{ toYaml .Values.resources | indent 12 }}
{{- if .Values.nodeSelector }}
nodeSelector:
{{ toYaml .Values.nodeSelector | indent 8 }}
{{- end }}
16 changes: 16 additions & 0 deletions stable/mssql-linux/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: v1
kind: Secret
metadata:
name: {{ template "mssql.fullname" . }}-secret
labels:
app: {{ template "mssql.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
type: Opaque
data:
{{ if .Values.sapassword }}
sapassword: {{ .Values.sapassword | b64enc | quote }}
{{ else }}
sapassword: {{ randAlphaNum 20 | b64enc | quote }}
{{ end }}
19 changes: 19 additions & 0 deletions stable/mssql-linux/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: v1
kind: Service
metadata:
name: {{ template "mssql.fullname" . }}
labels:
app: {{ template "mssql.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
type: {{ .Values.service.type }}
ports:
- name: db
port: 1433
targetPort: db
protocol: TCP
selector:
app: {{ template "mssql.name" . }}
release: {{ .Release.Name }}
26 changes: 26 additions & 0 deletions stable/mssql-linux/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
acceptEula:
value: "n"
edition:
value: Express
# Override sapassword in templates/secret.yaml
# sapassword: "MyStrongPassword1234"
image:
repository: microsoft/mssql-server-linux
tag: 2017-CU3
pullPolicy: IfNotPresent
service:
type: ClusterIP
livenessprobe:
initialDelaySeconds: 15
periodSeconds: 20
readinessprobe:
initialDelaySeconds: 5
periodSeconds: 10
resources: {}
# limits:
# cpu: 100m
# memory: 2Gi
# requests:
# cpu: 100m
# memory: 2Gi
nodeSelector: {}

0 comments on commit 0c1830e

Please sign in to comment.