Difference between revisions of "Mssql"

From UVOO Tech Wiki
Jump to navigation Jump to search
Line 145: Line 145:
 
   port: 1433
 
   port: 1433
  
 +
```
 +
 +
```
 +
sqlcmd -S 127.0.0.1 -U sa -P ${MSSQLPASSWORD} > select @@version > go
 
```
 
```

Revision as of 20:25, 10 March 2023

https://learn.microsoft.com/en-us/sql/linux/sql-server-linux-containers-deploy-helm-charts-kubernetes

https://github.com/microsoft/mssql-docker/tree/master/linux/sample-helm-chart-statefulset-deployment

https://gist.github.com/dbafromthecold/a126b33c2b8fe0c02b9081e8d447c21a

https://github.com/MicrosoftDocs/sql-docs/blob/live/docs/linux/sql-server-linux-containers-deploy-helm-charts-kubernetes.md

ENV Variables

NS=mssql
# envtpl --keep-template service.yaml.tpl
kubectl config set-context --current --namespace=$NS
git clone --depth=1 --branch=master https://github.com/microsoft/mssql-docker.git
# cd mssql-docker/linux/sample-helm-chart/

cd mssql-docker/linux/sample-helm-chart-statefulset-deployment

update values.yaml

helm install mssql-latest-deploy . --set ACCEPT_EULA.value=Y --set MSSQL_PID.value=Developer

install sqlcmd on Debian/Ubuntu

#!/bin/bash
set -eu
apt-get install -y gnupg2
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.list
apt-get update
apt-get install mssql-tools unixodbc-dev
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc
export MSSQLPASSWORD=PleaseChangeMe
sqlcmd -S mssql-latest-deploy.mssql.svc,1433 -U SA -P ${MSSQLPASSWORD}
create database foo;
go

USE foo;
go

CREATE TABLE test ( name varchar(20) );
go

insert into test (name) values ('footest1');
select * from test;
go

Values.yaml

non-stateful values.yaml - tag and password are changed from original

# Default values for mssql-latest.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

replicas: 1

image:
  repository: mcr.microsoft.com/mssql/server
  pullPolicy: IfNotPresent
  tag: "2022-latest"

ACCEPT_EULA:
    value: "y"
MSSQL_PID:
    value: "Developer"
MSSQL_AGENT_ENABLED:
    value: "true"
hostname: mssqllatest
sa_password: "PleaseChangeMe"
containers:
  ports:
      containerPort: 1433

podAnnotations: {}

podSecurityContext:
   fsGroup: 10001

service:
  type: LoadBalancer
  port: 1433

pvc:
 StorageClass: "managed-csi"
 userdbaccessMode: ReadWriteOnce
 userdbsize: 5Gi
 userlogaccessMode: ReadWriteOnce
 userlogsize: 5Gi
 tempdbaccessMode: ReadWriteOnce
 tempsize: 2Gi
 mssqldataaccessMode: ReadWriteOnce
 mssqldbsize: 2Gi

stateful set values

# Default values for mssql-latest.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

replicas: 3

image:
  repository: mcr.microsoft.com/mssql/server
  pullPolicy: IfNotPresent
  # Overrides the image tag whose default is the chart appVersion.
  tag: "2019-latest"

ACCEPT_EULA:
    value: "y"
MSSQL_PID:
    value: "Developer"
MSSQL_AGENT_ENABLED:
    value: "false"

containers:
  ports:
      containerPort: 1433

podAnnotations: {}

podSecurityContext:
   fsGroup: 10001

service:
  port: 1433

sqlcmd -S 127.0.0.1 -U sa -P ${MSSQLPASSWORD} > select @@version > go