diff --git a/linux/sample-helm-chart/Chart.yaml b/linux/sample-helm-chart-deployment/Chart.yaml similarity index 98% rename from linux/sample-helm-chart/Chart.yaml rename to linux/sample-helm-chart-deployment/Chart.yaml index caca28fe..b18cd49b 100644 --- a/linux/sample-helm-chart/Chart.yaml +++ b/linux/sample-helm-chart-deployment/Chart.yaml @@ -1,5 +1,5 @@ apiVersion: v2 -name: mssql-latest +name: mssql-server description: A Helm chart for Kubernetes # A chart can be either an 'application' or a 'library' chart. diff --git a/linux/sample-helm-chart/readme.md b/linux/sample-helm-chart-deployment/readme.md similarity index 95% rename from linux/sample-helm-chart/readme.md rename to linux/sample-helm-chart-deployment/readme.md index aba6bd36..063a549d 100644 --- a/linux/sample-helm-chart/readme.md +++ b/linux/sample-helm-chart-deployment/readme.md @@ -27,7 +27,7 @@ On the client machine where you have the Helm tools installed, download the char | Values.MSSQL_PID.value | Set the SQL Server edition or product key. please refer environment variable for more details | Developer | | 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 | | Values.hostname | The name that you would like to see when you run the select @@servername for the SQL instance running inside the container. | mssqllatest | -| Values.sa_password | Configure the SA user password. | StrongPass1! | +| Values.sa_password | Configure the SA user password. | Toughpass1! | | Values.containers.ports.containerPort | Port on which the SQL Server is listening inside the container. | 1433 | | Values.podSecurityContext.fsgroup | Security context at the pod level. | 10001 | | Values.service.type | The type of the service to be created within the kubernetes cluster. | LoadBalancer | @@ -65,35 +65,35 @@ directory of the CLI to the directory where you have the chart downloaded and to ``` bash -helm install mssql-latest-deploy . --set ACCEPT_EULA.value=Y --set MSSQL_PID.value=Developer +helm install mssql-server-deploy . --set ACCEPT_EULA.value=Y --set MSSQL_PID.value=Developer ``` After a few seconds this should deploy the SQL Server containers and you can see all the artifacts using the command : ```bash -D:\helm-charts\mssql-latest\mssql-latest>kubectl get all +D:\helm-charts\mssql-server\mssql-server>kubectl get all ``` The output should look as shown below: ```bash NAME READY STATUS RESTARTS AGE -pod/mssql-latest-deploy-645c4dddd8-647zk 1/1 Running 4 23h +pod/mssql-server-deploy-645c4dddd8-647zk 1/1 Running 4 23h NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE service/kubernetes ClusterIP 10.0.0.1 443/TCP 140d -service/mssql-latest-deploy LoadBalancer 10.0.57.19 20.44.43.212 1433:30544/TCP 23h +service/mssql-server-deploy LoadBalancer 10.0.57.19 20.44.43.212 1433:30544/TCP 23h NAME READY UP-TO-DATE AVAILABLE AGE -deployment.apps/mssql-latest-deploy 1/1 1 1 23h +deployment.apps/mssql-server-deploy 1/1 1 1 23h NAME DESIRED CURRENT READY AGE -replicaset.apps/mssql-latest-deploy-645c4dddd8 1 1 1 23h +replicaset.apps/mssql-server-deploy-645c4dddd8 1 1 1 23h ``` ## Connect to SQL Server -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 mssql-latest-deploy service which in this case is 20.44.43.212 that will be used to connect to SQL Server. +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 mssql-server-deploy service which in this case is 20.44.43.212 that will be used to connect to SQL Server. 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). diff --git a/linux/sample-helm-chart/templates/_helpers.tpl b/linux/sample-helm-chart-deployment/templates/_helpers.tpl similarity index 74% rename from linux/sample-helm-chart/templates/_helpers.tpl rename to linux/sample-helm-chart-deployment/templates/_helpers.tpl index f4b91c0c..1f9f8b63 100644 --- a/linux/sample-helm-chart/templates/_helpers.tpl +++ b/linux/sample-helm-chart-deployment/templates/_helpers.tpl @@ -1,7 +1,7 @@ {{/* Expand the name of the chart. */}} -{{- define "mssql-latest.name" -}} +{{- define "mssql-server.name" -}} {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} {{- end }} @@ -10,7 +10,7 @@ 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). If release name contains chart name it will be used as a full name. */}} -{{- define "mssql-latest.fullname" -}} +{{- define "mssql-server.fullname" -}} {{- if .Values.fullnameOverride }} {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} {{- else }} @@ -26,16 +26,16 @@ If release name contains chart name it will be used as a full name. {{/* Create chart name and version as used by the chart label. */}} -{{- define "mssql-latest.chart" -}} +{{- define "mssql-server.chart" -}} {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} {{- end }} {{/* Common labels */}} -{{- define "mssql-latest.labels" -}} -helm.sh/chart: {{ include "mssql-latest.chart" . }} -{{ include "mssql-latest.selectorLabels" . }} +{{- define "mssql-server.labels" -}} +helm.sh/chart: {{ include "mssql-server.chart" . }} +{{ include "mssql-server.selectorLabels" . }} {{- if .Chart.AppVersion }} app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} {{- end }} @@ -45,26 +45,25 @@ app.kubernetes.io/managed-by: {{ .Release.Service }} {{/* Selector labels */}} -{{- define "mssql-latest.selectorLabels" -}} -app.kubernetes.io/name: {{ include "mssql-latest.name" . }} +{{- define "mssql-server.selectorLabels" -}} +app.kubernetes.io/name: {{ include "mssql-server.name" . }} app.kubernetes.io/instance: {{ .Release.Name }} {{- end }} {{/* Create the name of the service account to use */}} -{{- define "mssql-latest.serviceAccountName" -}} +{{- define "mssql-server.serviceAccountName" -}} {{- if .Values.serviceAccount.create }} -{{- default (include "mssql-latest.fullname" .) .Values.serviceAccount.name }} +{{- default (include "mssql-server.fullname" .) .Values.serviceAccount.name }} {{- else }} {{- default "default" .Values.serviceAccount.name }} {{- end }} {{- end }} - {{/* Create the name for the SA password secret key. */}} -{{- define "mssql.sapassword" -}} +{{- define "mssql-server.sapassword" -}} sa_password {{- end -}} diff --git a/linux/sample-helm-chart-deployment/templates/deployment.yaml b/linux/sample-helm-chart-deployment/templates/deployment.yaml new file mode 100644 index 00000000..9eac2dfb --- /dev/null +++ b/linux/sample-helm-chart-deployment/templates/deployment.yaml @@ -0,0 +1,81 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "mssql-server.name" . }} + labels: + {{- include "mssql-server.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.replicas}} + selector: + matchLabels: + {{- include "mssql-server.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "mssql-server.selectorLabels" . | nindent 8 }} + spec: + {{- if .Values.nodeSelector }} + nodeSelector: +{{ toYaml .Values.nodeSelector | indent 8 }} + {{- end }} + {{- if .Values.tolerations }} + tolerations: +{{ toYaml .Values.tolerations | indent 6 }} + {{- end }} + hostname: {{ .Values.hostname}} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + command: + - /bin/bash + - -c + - cp /var/opt/config/mssql.conf /var/opt/mssql/mssql.conf && /opt/mssql/bin/sqlservr + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - containerPort: {{ .Values.containers.ports.containerPort}} + env: + - name: MSSQL_PID + value: "{{ .Values.MSSQL_PID.value}}" + - name: ACCEPT_EULA + value: "{{ .Values.ACCEPT_EULA.value | upper}}" + - name: MSSQL_AGENT_ENABLED + value: "{{ .Values.MSSQL_AGENT_ENABLED.value}}" + - name: SA_PASSWORD + valueFrom: + secretKeyRef: + name: {{ include "mssql-server.name" . }}-secret + key: {{ template "mssql-server.sapassword" . }} + volumeMounts: + - name: {{ include "mssql-server.name" . }}-data-volume + mountPath: "/var/opt/mssql" +{{/* mountPath: {{ .Values.pvc.dataMountPath }} + - name: {{ include "mssql-server.name" . }}-log-volume + mountPath: {{ .Values.pvc.logMountPath }} + - name: {{ include "mssql-server.name" . }}-dump-volume + mountPath: {{ .Values.pvc.dumpMountPath }} + - name: {{ include "mssql-server.name" . }}-backup-volume + mountPath: {{ .Values.pvc.backupMountPath }} */}} + - name: {{ include "mssql-server.name" . }}-config-volume + mountPath: /var/opt/config + volumes: + - name: {{ include "mssql-server.name" . }}-data-volume + persistentVolumeClaim: + claimName: {{ include "mssql-server.name" . }}-data +{{/* - name: {{ include "mssql-server.name" . }}-log-volume + persistentVolumeClaim: + claimName: {{ include "mssql-server.name" . }}-log + - name: {{ include "mssql-server.name" . }}-dump-volume + persistentVolumeClaim: + claimName: {{ include "mssql-server.name" . }}-dump + - name: {{ include "mssql-server.name" . }}-backup-volume + persistentVolumeClaim: + claimName: {{ include "mssql-server.name" . }}-backup */}} + - name: {{ include "mssql-server.name" . }}-config-volume + configMap: + name: {{ include "mssql-server.name" . }}-config \ No newline at end of file diff --git a/linux/sample-helm-chart-deployment/templates/mssqlconfig.yaml b/linux/sample-helm-chart-deployment/templates/mssqlconfig.yaml new file mode 100644 index 00000000..dd60e7b8 --- /dev/null +++ b/linux/sample-helm-chart-deployment/templates/mssqlconfig.yaml @@ -0,0 +1,26 @@ +kind: ConfigMap +apiVersion: v1 +metadata: + name: {{ include "mssql-server.name" . }}-config +data: + mssql.conf: | + [EULA] + accepteula = Y + accepteulaml = Y + + [coredump] + captureminiandfull = true + coredumptype = full + + [hadr] + hadrenabled = 1 + + [language] + lcid = 1033 +{{/* + [filelocation] +{{- printf "defaultdatadir = %s" .Values.pvc.dataMountPath | nindent 4 -}} +{{- printf "defaultlogdir = %s" .Values.pvc.logMountPath | nindent 4 -}} +{{- printf "defaultdumpdir = %s" .Values.pvc.dumpMountPath | nindent 4 -}} +{{- printf "defaultbackupdir = %s" .Values.pvc.backupMountPath | nindent 4 -}} +*/}} \ No newline at end of file diff --git a/linux/sample-helm-chart-deployment/templates/pvc.yaml b/linux/sample-helm-chart-deployment/templates/pvc.yaml new file mode 100644 index 00000000..f10b0a59 --- /dev/null +++ b/linux/sample-helm-chart-deployment/templates/pvc.yaml @@ -0,0 +1,56 @@ +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: {{ include "mssql-server.name" . }}-data +# annotations: +# volume.beta.kubernetes.io/storage-class: {{ .Values.pvc.storageClass | quote }} +spec: + storageClassName: {{ .Values.pvc.storageClass | quote }} + accessModes: + - {{ .Values.pvc.dataAccessMode | quote}} + resources: + requests: + storage: {{ .Values.pvc.dataSize}} +{{/*--- +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: {{ include "mssql-server.name" . }}-log +# annotations: +# volume.beta.kubernetes.io/storage-class: {{ .Values.pvc.storageClass}} +spec: + storageClassName: {{ .Values.pvc.storageClass | quote }} + accessModes: + - {{ .Values.pvc.logAccessMode | quote}} + resources: + requests: + storage: {{ .Values.pvc.logSize}} +--- +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: {{ include "mssql-server.name" . }}-dump +# annotations: +# volume.beta.kubernetes.io/storage-class: {{ .Values.pvc.storageClass}} +spec: + storageClassName: {{ .Values.pvc.storageClass | quote }} + accessModes: + - {{ .Values.pvc.dumpAccessMode | quote}} + resources: + requests: + storage: {{ .Values.pvc.dumpSize}} +--- +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: {{ include "mssql-server.name" . }}-backup +# annotations: +# volume.beta.kubernetes.io/storage-class: {{ .Values.pvc.storageClass}} +spec: + storageClassName: {{ .Values.pvc.storageClass | quote }} + accessModes: + - {{ .Values.pvc.backupAccessMode | quote}} + resources: + requests: + storage: {{ .Values.pvc.backupSize}} +*/}} \ No newline at end of file diff --git a/linux/sample-helm-chart/templates/secret.yaml b/linux/sample-helm-chart-deployment/templates/secret.yaml similarity index 53% rename from linux/sample-helm-chart/templates/secret.yaml rename to linux/sample-helm-chart-deployment/templates/secret.yaml index be2ffc50..6c8dc35e 100644 --- a/linux/sample-helm-chart/templates/secret.yaml +++ b/linux/sample-helm-chart-deployment/templates/secret.yaml @@ -1,9 +1,9 @@ -apiVersion: v1 -kind: Secret -metadata: - name: mssql-secret - labels: - {{- include "mssql-latest.labels" . | nindent 4 }} -type: Opaque -data: +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "mssql-server.name" . }}-secret + labels: + {{- include "mssql-server.labels" . | nindent 4 }} +type: Opaque +data: sa_password : {{ .Values.sa_password | b64enc | quote}} \ No newline at end of file diff --git a/linux/sample-helm-chart-deployment/templates/service.yaml b/linux/sample-helm-chart-deployment/templates/service.yaml new file mode 100644 index 00000000..31b00d86 --- /dev/null +++ b/linux/sample-helm-chart-deployment/templates/service.yaml @@ -0,0 +1,18 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "mssql-server.name" . }} + labels: + {{- include "mssql-server.labels" . | nindent 4 }} + {{- with .Values.service.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: {{ .Values.service.port }} + protocol: TCP + selector: + {{- include "mssql-server.selectorLabels" . | nindent 4 }} \ No newline at end of file diff --git a/linux/sample-helm-chart/values.yaml b/linux/sample-helm-chart-deployment/values.yaml similarity index 53% rename from linux/sample-helm-chart/values.yaml rename to linux/sample-helm-chart-deployment/values.yaml index 2bbae807..c03564a3 100644 --- a/linux/sample-helm-chart/values.yaml +++ b/linux/sample-helm-chart-deployment/values.yaml @@ -1,15 +1,22 @@ -# Default values for mssql-latest. +# Default values for mssql-server. # This is a YAML-formatted file. # Declare variables to be passed into your templates. replicas: 1 +nameOverride: '' +fullnameOverride: '' + image: repository: mcr.microsoft.com/mssql/server pullPolicy: IfNotPresent # Overrides the image tag whose default is the chart appVersion. tag: "2019-latest" +nodeSelector: {} + +tolerations: [] + ACCEPT_EULA: value: "y" MSSQL_PID: @@ -30,16 +37,19 @@ podSecurityContext: service: type: LoadBalancer port: 1433 + annotations: {} pvc: - StorageClass: "azure-disk" - userdbaccessMode: ReadWriteOnce - userdbsize: 5Gi - userlogaccessMode: ReadWriteOnce - userlogsize: 5Gi - tempdbaccessMode: ReadWriteOnce - tempsize: 2Gi - mssqldataaccessMode: ReadWriteOnce - mssqldbsize: 2Gi - - + storageClass: "" + dataAccessMode: ReadWriteOnce + dataSize: 5Gi +# dataMountPath: /var/opt/mssql/db/data +# logAccessMode: ReadWriteOnce +# logSize: 5Gi +# logMountPath: /var/opt/mssql/db/log +# dumpAccessMode: ReadWriteOnce +# dumpSize: 2Gi +# dumpMountPath: /var/opt/mssql/db/dump +# backupAccessMode: ReadWriteOnce +# backupSize: 2Gi +# backupMountPath: /var/opt/mssql/db/backup diff --git a/linux/sample-helm-chart-statefulset-deployment/templates/sc.yaml b/linux/sample-helm-chart-statefulset-deployment/templates/sc.yaml deleted file mode 100644 index 6b75debf..00000000 --- a/linux/sample-helm-chart-statefulset-deployment/templates/sc.yaml +++ /dev/null @@ -1,8 +0,0 @@ -kind: StorageClass -apiVersion: storage.k8s.io/v1beta1 -metadata: - name: azure-disk -provisioner: kubernetes.io/azure-disk -parameters: - storageaccounttype: Standard_LRS - kind: Managed \ No newline at end of file diff --git a/linux/sample-helm-chart-statefulset-deployment/.helmignore b/linux/sample-helm-chart-statefulset/.helmignore similarity index 100% rename from linux/sample-helm-chart-statefulset-deployment/.helmignore rename to linux/sample-helm-chart-statefulset/.helmignore diff --git a/linux/sample-helm-chart-statefulset-deployment/Chart.yaml b/linux/sample-helm-chart-statefulset/Chart.yaml similarity index 100% rename from linux/sample-helm-chart-statefulset-deployment/Chart.yaml rename to linux/sample-helm-chart-statefulset/Chart.yaml diff --git a/linux/sample-helm-chart-statefulset-deployment/readme.md b/linux/sample-helm-chart-statefulset/readme.md similarity index 100% rename from linux/sample-helm-chart-statefulset-deployment/readme.md rename to linux/sample-helm-chart-statefulset/readme.md diff --git a/linux/sample-helm-chart-statefulset-deployment/services/Ag_endpoint.yaml b/linux/sample-helm-chart-statefulset/services/Ag_endpoint.yaml similarity index 93% rename from linux/sample-helm-chart-statefulset-deployment/services/Ag_endpoint.yaml rename to linux/sample-helm-chart-statefulset/services/Ag_endpoint.yaml index b999489a..db980d06 100644 --- a/linux/sample-helm-chart-statefulset-deployment/services/Ag_endpoint.yaml +++ b/linux/sample-helm-chart-statefulset/services/Ag_endpoint.yaml @@ -1,35 +1,37 @@ -apiVersion: v1 -kind: Service -metadata: - name: mssql-mirror-0 -spec: - selector: - statefulset.kubernetes.io/pod-name: mssql-sql-statefull-deploy-0 - ports: - - protocol: TCP - port: 5022 - targetPort: 5022 ---- -apiVersion: v1 -kind: Service -metadata: - name: mssql-mirror-1 -spec: - selector: - statefulset.kubernetes.io/pod-name: mssql-sql-statefull-deploy-1 - ports: - - protocol: TCP - port: 5022 - targetPort: 5022 ---- -apiVersion: v1 -kind: Service -metadata: - name: mssql-mirror-2 -spec: - selector: - statefulset.kubernetes.io/pod-name: mssql-sql-statefull-deploy-2 - ports: - - protocol: TCP - port: 5022 - targetPort: 5022 +{{- if .Values.ag_service.enabled }} +apiVersion: v1 +kind: Service +metadata: + name: mssql-mirror-0 +spec: + selector: + statefulset.kubernetes.io/pod-name: mssql-sql-statefull-deploy-0 + ports: + - protocol: TCP + port: 5022 + targetPort: 5022 +--- +apiVersion: v1 +kind: Service +metadata: + name: mssql-mirror-1 +spec: + selector: + statefulset.kubernetes.io/pod-name: mssql-sql-statefull-deploy-1 + ports: + - protocol: TCP + port: 5022 + targetPort: 5022 +--- +apiVersion: v1 +kind: Service +metadata: + name: mssql-mirror-2 +spec: + selector: + statefulset.kubernetes.io/pod-name: mssql-sql-statefull-deploy-2 + ports: + - protocol: TCP + port: 5022 + targetPort: 5022 +{{- end }} diff --git a/linux/sample-helm-chart-statefulset-deployment/services/ex_service.yaml b/linux/sample-helm-chart-statefulset/services/ex_service.yaml similarity index 94% rename from linux/sample-helm-chart-statefulset-deployment/services/ex_service.yaml rename to linux/sample-helm-chart-statefulset/services/ex_service.yaml index 0aa72219..1400e88b 100644 --- a/linux/sample-helm-chart-statefulset-deployment/services/ex_service.yaml +++ b/linux/sample-helm-chart-statefulset/services/ex_service.yaml @@ -1,3 +1,4 @@ +{{- if .Values.ex_service.enabled }} apiVersion: v1 kind: Service metadata: @@ -39,3 +40,4 @@ spec: - protocol: TCP port: 1433 targetPort: 1433 +{{- end }} diff --git a/linux/sample-helm-chart-statefulset-deployment/templates/_helpers.tpl b/linux/sample-helm-chart-statefulset/templates/_helpers.tpl similarity index 100% rename from linux/sample-helm-chart-statefulset-deployment/templates/_helpers.tpl rename to linux/sample-helm-chart-statefulset/templates/_helpers.tpl diff --git a/linux/sample-helm-chart-statefulset-deployment/templates/mssqlconfig.yaml b/linux/sample-helm-chart-statefulset/templates/mssqlconfig.yaml similarity index 93% rename from linux/sample-helm-chart-statefulset-deployment/templates/mssqlconfig.yaml rename to linux/sample-helm-chart-statefulset/templates/mssqlconfig.yaml index cf877c3e..eea82fa3 100644 --- a/linux/sample-helm-chart-statefulset-deployment/templates/mssqlconfig.yaml +++ b/linux/sample-helm-chart-statefulset/templates/mssqlconfig.yaml @@ -1,20 +1,20 @@ -kind: ConfigMap -apiVersion: v1 -metadata: - name: mssql -data: - mssql.conf: | - [EULA] - accepteula = Y - accepteulaml = Y - - [coredump] - captureminiandfull = true - coredumptype = full - - [hadr] - hadrenabled = 1 - - [language] - lcid = 1033 +kind: ConfigMap +apiVersion: v1 +metadata: + name: mssql +data: + mssql.conf: | + [EULA] + accepteula = Y + accepteulaml = Y + + [coredump] + captureminiandfull = true + coredumptype = full + + [hadr] + hadrenabled = 1 + + [language] + lcid = 1033 \ No newline at end of file diff --git a/linux/sample-helm-chart-statefulset/templates/secret.yaml b/linux/sample-helm-chart-statefulset/templates/secret.yaml new file mode 100644 index 00000000..f4c6feea --- /dev/null +++ b/linux/sample-helm-chart-statefulset/templates/secret.yaml @@ -0,0 +1,9 @@ +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "sql-statefull-deploy.name" . }}-secret + labels: + {{- include "sql-statefull-deploy.labels" . | nindent 4 }} +type: Opaque +data: + SA_PASSWORD : {{ .Values.sa_password | b64enc | quote}} \ No newline at end of file diff --git a/linux/sample-helm-chart-statefulset-deployment/templates/service.yaml b/linux/sample-helm-chart-statefulset/templates/service.yaml similarity index 78% rename from linux/sample-helm-chart-statefulset-deployment/templates/service.yaml rename to linux/sample-helm-chart-statefulset/templates/service.yaml index 58459151..3e3bc7b3 100644 --- a/linux/sample-helm-chart-statefulset-deployment/templates/service.yaml +++ b/linux/sample-helm-chart-statefulset/templates/service.yaml @@ -4,6 +4,10 @@ metadata: name: {{ include "sql-statefull-deploy.fullname" . }} labels: {{- include "sql-statefull-deploy.labels" . | nindent 4 }} + {{- with .Values.service.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} spec: clusterIP: None ports: diff --git a/linux/sample-helm-chart-statefulset-deployment/templates/deployment.yaml b/linux/sample-helm-chart-statefulset/templates/statefulset.yaml similarity index 81% rename from linux/sample-helm-chart-statefulset-deployment/templates/deployment.yaml rename to linux/sample-helm-chart-statefulset/templates/statefulset.yaml index 136d5424..7a0756d8 100644 --- a/linux/sample-helm-chart-statefulset-deployment/templates/deployment.yaml +++ b/linux/sample-helm-chart-statefulset/templates/statefulset.yaml @@ -19,6 +19,14 @@ spec: labels: {{- include "sql-statefull-deploy.selectorLabels" . | nindent 8 }} spec: + {{- if .Values.nodeSelector }} + nodeSelector: +{{ toYaml .Values.nodeSelector | indent 8 }} + {{- end }} + {{- if .Values.tolerations }} + tolerations: +{{ toYaml .Values.tolerations | indent 6 }} + {{- end }} securityContext: {{- toYaml .Values.podSecurityContext | nindent 8 }} containers: @@ -41,7 +49,7 @@ spec: - name: SA_PASSWORD valueFrom: secretKeyRef: - name: mssql + name: {{ include "sql-statefull-deploy.name" . }}-secret key: SA_PASSWORD volumeMounts: - name: mssql @@ -57,7 +65,8 @@ spec: name: mssql spec: accessModes: - - ReadWriteOnce + - {{ .Values.pvc.accessMode }} + storageClassName: {{ .Values.pvc.storageClass }} resources: requests: - storage: 8Gi \ No newline at end of file + storage: {{ .Values.pvc.size }} \ No newline at end of file diff --git a/linux/sample-helm-chart-statefulset-deployment/values.yaml b/linux/sample-helm-chart-statefulset/values.yaml similarity index 67% rename from linux/sample-helm-chart-statefulset-deployment/values.yaml rename to linux/sample-helm-chart-statefulset/values.yaml index 709ad6cd..cecda87a 100644 --- a/linux/sample-helm-chart-statefulset-deployment/values.yaml +++ b/linux/sample-helm-chart-statefulset/values.yaml @@ -4,12 +4,19 @@ replicas: 3 +nameOverride: '' +fullnameOverride: '' + image: repository: mcr.microsoft.com/mssql/server pullPolicy: IfNotPresent # Overrides the image tag whose default is the chart appVersion. tag: "2019-latest" +nodeSelector: {} + +tolerations: [] + ACCEPT_EULA: value: "y" MSSQL_PID: @@ -17,6 +24,8 @@ MSSQL_PID: MSSQL_AGENT_ENABLED: value: "false" +sa_password: "Toughpass1!" + containers: ports: containerPort: 1433 @@ -27,4 +36,16 @@ podSecurityContext: fsGroup: 10001 service: - port: 1433 \ No newline at end of file + port: 1433 + annotations: {} + +ag_service: + enabled: true + +ex_service: + enabled: true + +pvc: + storageClass: "" + accessMode: ReadWriteOnce + size: 8Gi diff --git a/linux/sample-helm-chart/templates/deployment.yaml b/linux/sample-helm-chart/templates/deployment.yaml deleted file mode 100644 index 0e2827e9..00000000 --- a/linux/sample-helm-chart/templates/deployment.yaml +++ /dev/null @@ -1,72 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: {{ include "mssql-latest.fullname" . }} - labels: - {{- include "mssql-latest.labels" . | nindent 4 }} -spec: - replicas: {{ .Values.replicas}} - selector: - matchLabels: - {{- include "mssql-latest.selectorLabels" . | nindent 6 }} - template: - metadata: - {{- with .Values.podAnnotations }} - annotations: - {{- toYaml . | nindent 8 }} - {{- end }} - labels: - {{- include "mssql-latest.selectorLabels" . | nindent 8 }} - spec: - hostname: {{ .Values.hostname}} - securityContext: - {{- toYaml .Values.podSecurityContext | nindent 8 }} - containers: - - name: {{ .Chart.Name }} - command: - - /bin/bash - - -c - - cp /var/opt/config/mssql.conf /var/opt/mssql/mssql.conf && /opt/mssql/bin/sqlservr - image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" - imagePullPolicy: {{ .Values.image.pullPolicy }} - ports: - - containerPort: {{ .Values.containers.ports.containerPort}} - env: - - name: MSSQL_PID - value: "{{ .Values.MSSQL_PID.value}}" - - name: ACCEPT_EULA - value: "{{ .Values.ACCEPT_EULA.value | upper}}" - - name: MSSQL_AGENT_ENABLED - value: "{{ .Values.MSSQL_AGENT_ENABLED.value}}" - - name: SA_PASSWORD - valueFrom: - secretKeyRef: - name: mssql-secret - key: {{ template "mssql.sapassword" . }} - volumeMounts: - - name: mssqldb - mountPath: /var/opt/mssql - - name: mssqluserdb - mountPath: /var/opt/mssql/userdata - - name: mssqllog - mountPath: /var/opt/mssql/userlog - - name: mssqltemp - mountPath: /var/opt/mssql/tempdb - - name: mssql-config-volume - mountPath: /var/opt/config - volumes: - - name: mssqldb - persistentVolumeClaim: - claimName: mssql-data - - name: mssqluserdb - persistentVolumeClaim: - claimName: mssql-userdb - - name: mssqllog - persistentVolumeClaim: - claimName: mssql-log - - name: mssqltemp - persistentVolumeClaim: - claimName: mssql-temp - - name: mssql-config-volume - configMap: - name: mssql-config \ No newline at end of file diff --git a/linux/sample-helm-chart/templates/mssqlconfig.yaml b/linux/sample-helm-chart/templates/mssqlconfig.yaml deleted file mode 100644 index d1e11cc3..00000000 --- a/linux/sample-helm-chart/templates/mssqlconfig.yaml +++ /dev/null @@ -1,23 +0,0 @@ -kind: ConfigMap -apiVersion: v1 -metadata: - name: mssql-config -data: - mssql.conf: | - [EULA] - accepteula = Y - accepteulaml = Y - - [coredump] - captureminiandfull = true - coredumptype = full - - [hadr] - hadrenabled = 1 - - [language] - lcid = 1033 - - [filelocation] - defaultdatadir = /var/opt/mssql/userdata - defaultlogdir = /var/opt/mssql/userlog \ No newline at end of file diff --git a/linux/sample-helm-chart/templates/pvc.yaml b/linux/sample-helm-chart/templates/pvc.yaml deleted file mode 100644 index 411d21ac..00000000 --- a/linux/sample-helm-chart/templates/pvc.yaml +++ /dev/null @@ -1,60 +0,0 @@ -kind: StorageClass -apiVersion: storage.k8s.io/v1 -metadata: - name: azure-disk -provisioner: kubernetes.io/azure-disk -parameters: - storageaccounttype: Standard_LRS - kind: Managed ---- -kind: PersistentVolumeClaim -apiVersion: v1 -metadata: - name: mssql-data - annotations: - volume.beta.kubernetes.io/storage-class: {{ .Values.pvc.StorageClass | quote }} -spec: - accessModes: - - {{ .Values.pvc.mssqldataaccessMode | quote}} - resources: - requests: - storage: {{ .Values.pvc.mssqldbsize}} ---- -kind: PersistentVolumeClaim -apiVersion: v1 -metadata: - name: mssql-userdb - annotations: - volume.beta.kubernetes.io/storage-class: {{ .Values.pvc.StorageClass}} -spec: - accessModes: - - {{ .Values.pvc.userdbaccessMode | quote}} - resources: - requests: - storage: {{ .Values.pvc.userdbsize}} ---- -kind: PersistentVolumeClaim -apiVersion: v1 -metadata: - name: mssql-log - annotations: - volume.beta.kubernetes.io/storage-class: {{ .Values.pvc.StorageClass}} -spec: - accessModes: - - {{ .Values.pvc.userlogaccessMode | quote}} - resources: - requests: - storage: {{ .Values.pvc.userlogsize}} ---- -kind: PersistentVolumeClaim -apiVersion: v1 -metadata: - name: mssql-temp - annotations: - volume.beta.kubernetes.io/storage-class: {{ .Values.pvc.StorageClass}} -spec: - accessModes: - - {{ .Values.pvc.tempdbaccessMode | quote}} - resources: - requests: - storage: {{ .Values.pvc.tempsize}} \ No newline at end of file diff --git a/linux/sample-helm-chart/templates/service.yaml b/linux/sample-helm-chart/templates/service.yaml deleted file mode 100644 index a24f844b..00000000 --- a/linux/sample-helm-chart/templates/service.yaml +++ /dev/null @@ -1,14 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: {{ include "mssql-latest.fullname" . }} - labels: - {{- include "mssql-latest.labels" . | nindent 4 }} -spec: - type: {{ .Values.service.type }} - ports: - - port: {{ .Values.service.port }} - targetPort: {{ .Values.service.port }} - protocol: TCP - selector: - {{- include "mssql-latest.selectorLabels" . | nindent 4 }} \ No newline at end of file