Difference between revisions of "Mssql"
Jump to navigation
Jump to search
(6 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
https://learn.microsoft.com/en-us/sql/linux/sql-server-linux-containers-deploy-helm-charts-kubernetes | 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 | ||
+ | - https://learn.microsoft.com/en-us/sql/linux/sql-server-linux-configure-environment-variables?view=sql-server-ver15 | ||
+ | - https://stackoverflow.com/questions/68238963/what-are-the-default-sql-server-credentials-created-via-docker | ||
Line 7: | Line 17: | ||
kubectl config set-context --current --namespace=$NS | kubectl config set-context --current --namespace=$NS | ||
git clone --depth=1 --branch=master https://github.com/microsoft/mssql-docker.git | 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/ |
+ | |||
+ | cd mssql-docker/linux/sample-helm-chart-statefulset-deployment | ||
``` | ``` | ||
− | values.yaml - tag and password are changed from original | + | |
+ | 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-sql-statefull-deploy.mssql.svc,1433 -U SA -P ${MSSQLPASSWORD} | ||
+ | sqlcmd -S mssql-sql-statefull-deploy.mssql.svc -U sa -P ${MSSQLPASSWORD} > select @@version > go | ||
+ | ``` | ||
+ | |||
+ | ``` | ||
+ | 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. | # Default values for mssql-latest. | ||
Line 56: | Line 112: | ||
``` | ``` | ||
+ | |||
+ | ## 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 | |
− | + | ``` | |
− | |||
− | + | ``` | |
− | select | + | # sqlcmd -S mssql-latest-deploy.mssql.svc,1433 -U SA -P ${MSSQLPASSWORD} |
− | go | + | sqlcmd -S 127.0.0.1 -U sa -P ${MSSQLPASSWORD} > select @@version > go |
``` | ``` |
Latest revision as of 20:55, 10 March 2023
https://github.com/microsoft/mssql-docker/tree/master/linux/sample-helm-chart-statefulset-deployment
https://gist.github.com/dbafromthecold/a126b33c2b8fe0c02b9081e8d447c21a
ENV Variables
- https://learn.microsoft.com/en-us/sql/linux/sql-server-linux-configure-environment-variables?view=sql-server-ver15
- https://stackoverflow.com/questions/68238963/what-are-the-default-sql-server-credentials-created-via-docker
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-sql-statefull-deploy.mssql.svc,1433 -U SA -P ${MSSQLPASSWORD} sqlcmd -S mssql-sql-statefull-deploy.mssql.svc -U sa -P ${MSSQLPASSWORD} > select @@version > go
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 mssql-latest-deploy.mssql.svc,1433 -U SA -P ${MSSQLPASSWORD} sqlcmd -S 127.0.0.1 -U sa -P ${MSSQLPASSWORD} > select @@version > go