Skip to content

Commit b1f6ce2

Browse files
committed
Setup script for BDC with AD integration
1 parent c8bc392 commit b1f6ce2

5 files changed

Lines changed: 572 additions & 0 deletions

File tree

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
2+
# Deploy a SQL Server big data cluster on single node Kubernetes cluster (kubeadm)
3+
4+
Using this sample bash script, you will deploy a single node Kubernetes cluster using kubeadm and a SQL Server big data cluster that is integrated with Active Directory domain. The script must be run from the VM you are planning to use for your kubeadm deployment.
5+
6+
## Pre-requisites
7+
8+
1. A vanilla Ubuntu 16.04 or 18.04 virtual or physical machine on your corporate network. All dependencies will be setup by the script. Using Azure Linux VMs is not yet supported.
9+
1. Machine should have at least 8 CPUs, 64GB RAM and 100GB disk space. After installing the images you will be left with 50GB for data/logs across all components.
10+
1. Update existing packages using commands below to ensure that the OS image is up to date
11+
12+
``` bash
13+
sudo apt update&&apt upgrade -y
14+
sudo systemctl reboot
15+
```
16+
17+
## Recommended Virtual Machine settings
18+
19+
1. Use static memory configuration for the virtual machine. For example, in hyper-v installations do not use dynamic memory allocation but instead allocate the recommended 64 GB or higher.
20+
21+
1. Use checkpoint or snapshot capability in your hyper visor so that you can rollback the virtual machine to a clean state.
22+
23+
## Instructions to deploy SQL Server big data cluster
24+
25+
1. Download the script on the VM you are planning to use for the deployment
26+
27+
``` bash
28+
curl --output setup-bdc.sh https://raw.githubusercontent.com/microsoft/sql-server-samples/master/samples/features/sql-big-data-cluster/deployment/kubeadm/ubuntu-single-node-vm-ad/setup-bdc.sh
29+
curl --output endpoint-patch.json https://raw.githubusercontent.com/microsoft/sql-server-samples/master/samples/features/sql-big-data-cluster/deployment/kubeadm/ubuntu-single-node-vm-ad/endpoint-patch.json
30+
curl --output security-patch.json https://raw.githubusercontent.com/microsoft/sql-server-samples/master/samples/features/sql-big-data-cluster/deployment/kubeadm/ubuntu-single-node-vm-ad/security-patch.json
31+
```
32+
33+
1. Edit and modify the endpoint-patch.json & security-patch.json files to supply the values specific to your Active Directory environment
34+
35+
1. Make the script executable
36+
37+
``` bash
38+
chmod +x setup-bdc-ad.sh
39+
```
40+
41+
1. Run the script (make sure you are running with sudo)
42+
43+
``` bash
44+
sudo ./setup-bdc-ad.sh
45+
```
46+
47+
1. Refresh alias setup for azdata
48+
49+
``` bash
50+
source ~/.bashrc
51+
```
52+
53+
When prompted, provide your input for the password that will be used for all external endpoints: controller, SQL Server master and gateway. The password should be sufficiently complex based on existing rules for SQL Server password. The controller username is defaulted to *admin*.
54+
55+
## Cleanup
56+
57+
1. The [cleanup-bdc.sh](cleanup-bdc.sh/) script is provided as convenience to reset the environment in case of errors. However, we recommend that you use a virtual machine for testing purposes and use the snapshot capabiility in your hyper-visor to rollback the virtual machine to a clean state.
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
#!/bin/bash
2+
3+
if [ "$EUID" -ne 0 ]
4+
then echo "Please run as root"
5+
exit
6+
fi
7+
DIR_PREFIX=$1
8+
9+
kubeadm reset --force
10+
unalias azdata
11+
12+
systemctl stop kubelet
13+
rm -rf /var/lib/cni/
14+
rm -rf /var/lib/etcd/
15+
rm -rf /run/flannel/
16+
rm -rf /var/lib/kubelet/*
17+
rm -rf /etc/cni/
18+
rm -rf /etc/kubernetes/
19+
20+
ip link set cni0 down
21+
#brctl delbr cni0
22+
ip link set flannel.1 down
23+
#brctl delbr flannel.1
24+
iptables -F && iptables -t nat -F && iptables -t mangle -F && iptables -X
25+
26+
rm -rf .azdata/
27+
rm -rf bdcdeploy/
28+
29+
# Remove mounts.
30+
#
31+
SERVICE_STOP_FAILED=0
32+
33+
systemctl | grep "/var/lib/kubelet/pods" | while read -r line; do
34+
35+
# Retrieve the mount path
36+
#
37+
MOUNT_PATH=`echo "$line" | grep -v echo | egrep -oh -m 1 "(/var/lib/kubelet/pods).+"`
38+
39+
if [ -z "$MOUNT_PATH" ]; then
40+
continue
41+
fi
42+
43+
if [[ ! -d "$MOUNT_PATH" ]] && [[ ! -f "$MOUNT_PATH" ]]; then
44+
45+
SERVICE=$(echo $line | cut -f1 -d' ')
46+
47+
echo "Mount "$MOUNT_PATH" no longer exists."
48+
echo "Stopping orphaned mount service: '$SERVICE'"
49+
50+
systemctl stop $SERVICE
51+
52+
if [ $? -ne 0 ]; then
53+
SERVICE_STOP_FAILED=1
54+
fi
55+
56+
echo ""
57+
fi
58+
done
59+
60+
if [ $SERVICE_STOP_FAILED -ne 0 ]; then
61+
echo "Not all services were stopped successfully. Please check the above output for more inforamtion."
62+
else
63+
echo "All orphaned services successfully stopped."
64+
fi
65+
66+
# Clean the mounted volumes.
67+
#
68+
69+
for i in $(seq 1 30); do
70+
71+
vol="vol$i"
72+
73+
sudo umount /mnt/local-storage/$vol
74+
75+
sudo rm -rf /mnt/local-storage/$vol
76+
77+
done
78+
79+
# Reset kube
80+
#
81+
sudo apt-get purge -y kubeadm --allow-change-held-packages
82+
sudo apt-get purge -y kubectl --allow-change-held-packages
83+
sudo apt-get purge -y kubelet --allow-change-held-packages
84+
sudo apt-get purge -y kubernetes-cni --allow-change-held-packages
85+
sudo apt-get purge -y kube* --allow-change-held-packages
86+
sudo apt -y autoremove
87+
sudo rm -rf ~/.kube
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"patch": [
3+
{
4+
"op": "replace",
5+
"path": "spec.pools[?(@.spec.type=='Master')].spec",
6+
"value": {
7+
"type": "Master",
8+
"dnsName": "mastersql.contoso.local",
9+
"replicas": 1,
10+
"endpoints": [
11+
{
12+
"name": "Master",
13+
"serviceType": "NodePort",
14+
"port": 31433
15+
}
16+
]
17+
}
18+
}
19+
]
20+
}
21+
22+
23+
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"patch": [
3+
{
4+
"op": "add",
5+
"path": "security",
6+
"value": {
7+
"useInternalDomain": false,
8+
"ouDistinguishedName":"OU=bdc,DC=contoso,DC=local",
9+
"dnsIpAddresses": ["11.11.111.11"],
10+
"domainControllerFullyQualifiedDns": ["VM.CONTOSO.LOCAL"],
11+
"realm":"CONTOSO.LOCAL",
12+
"domainDnsName":"contoso.local",
13+
"bdcAdminPrincipals": [
14+
"Domain Admins", "Enterprise Admins"
15+
],
16+
"bdcUserPrincipals": [
17+
"Domain Users"
18+
]
19+
}
20+
},
21+
{
22+
"op": "add",
23+
"path": "spec.endpoints/0",
24+
"value": {
25+
"name": "Kerberos",
26+
"serviceType": "NodePort",
27+
"port": 30088
28+
}
29+
}
30+
]
31+
}

0 commit comments

Comments
 (0)