-
Notifications
You must be signed in to change notification settings - Fork 3
/
1.Basic Kubernetes Deployment.ps1
81 lines (42 loc) · 1.39 KB
/
1.Basic Kubernetes Deployment.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
############################################################################
############################################################################
#
# SQL Server & Kubernetes - Andrew Pruski
# @dbafromthecold
# https://github.com/dbafromthecold/SQLServerAndKubernetes
# Kubernetes Basic Deployment
#
############################################################################
############################################################################
# switch context to local cluster
kubectl config use-context docker-desktop
# view nodes
kubectl get nodes
# deploy pod
kubectl run sqlserver `
--image=mcr.microsoft.com/mssql/server:2022-CU5-ubuntu-20.04 `
--env ACCEPT_EULA=Y --env MSSQL_SA_PASSWORD=Testing1122
# view pod
kubectl get pods
# exec into pod
$PODNAME=$(kubectl get pods --no-headers -o custom-columns=":metadata.name")
kubectl exec -it $PODNAME -- bash
# navigate to sqlcmd
cd /opt/mssql-tools/bin/
# connect to sql
./sqlcmd -S . -U sa -P Testing1122
# confirm sql version
SELECT @@VERSION;
GO
# exit SQL and pod
exit
# expose service
kubectl expose pod sqlserver --type=LoadBalancer --port=1433 --target-port=1433
# get service IP
kubectl get services
# connect via mssql-cli
mssql-cli -S localhost -U sa -P Testing1122 -Q "SELECT @@VERSION AS [Version];"
# clean up
kubectl delete pod sqlserver
kubectl delete service sqlserver