-
Notifications
You must be signed in to change notification settings - Fork 2
/
2_0_SQLServer-Deployment.sh
60 lines (48 loc) · 1.86 KB
/
2_0_SQLServer-Deployment.sh
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
# Demo 02 - SQL Server Kubernetes deployment (Azure Kubernetes Services)
#
# 1- SQL Server Kubernetes deployment (AKS)
# 2- Check Kubernetes objects
# 3- Check SQL Server pod logs
# -----------------------------------------------------------------------------
# Reference:
# Kubernetes cheat sheet
# https://kubernetes.io/docs/reference/kubectl/cheatsheet/
#
# Deploy a SQL Server container in Kubernetes with Azure Kubernetes Services
# https://docs.microsoft.com/en-us/sql/linux/tutorial-sql-server-containers-kubernetes
#
# 1- SQL Server Kubernetes deployment (AKS)
# Set Kubernetes context to MicroK8s
kubectl config get-contexts
kubectl config use-context endurance-admin
# Create dedicated namespace (optional, however is the best practice)
kubectl create namespace plex-sql
# Set Kubernetes context to new namespace
kubectl config set-context --current --namespace=plex-sql
kubectl config get-contexts
# Create secret for SA password
# SA password = _EnDur@nc3_
kubectl apply -f ./Manifests/secret-sa-plex.yaml
# Create PVC (Persistent volume claim)
kubectl apply -f ./Manifests/pvc-data-plex.yaml
# Create service (NodePort)
kubectl apply -f ./Manifests/srvc-sql-plex.yaml
# Create SQL Server deployment (Pod)
kubectl apply -f ./Manifests/depl-sql-plex.yaml --record
# 2- Check Kubernetes objects
# All SQL Server objects in AKS
kubectl get secrets/sa-password-plex
kubectl get pvc/pvc-data-plex
kubectl get service/srvc-sql-plex
kubectl get deployments
# 3- Check SQL Server pod logs
# Get existing Pods in Kubernetes cluster
kubectl get pods -l app=sql-plex
# Get SQL Server Pod
sql_pod=`kubectl get pods -l app=sql-plex | grep sql-plex | awk {'print $1'}`
echo $sql_pod
# Get SQL Server container name
kubectl get pods $sql_pod -o jsonpath='{.spec.containers[*].name}'
# Describe SQL Server pod and check logs
kubectl describe pods $sql_pod
kubectl logs $sql_pod -f