Difference between revisions of "Mssql"
Jump to navigation
Jump to search
(Created page with "https://learn.microsoft.com/en-us/sql/linux/sql-server-linux-containers-deploy-helm-charts-kubernetes") |
|||
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 | ||
+ | |||
+ | |||
+ | ``` | ||
+ | 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/ | ||
+ | ``` | ||
+ | |||
+ | 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 | ||
+ | ``` | ||
+ | |||
+ | ``` | ||
+ | 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 | ||
+ | ``` |
Revision as of 17:26, 10 March 2023
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/
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
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