Skip to content

Commit 4477c49

Browse files
authored
Merge pull request #687 from ananto-msft/master
Adding sample deployment script for Azure Arc Data Controller private preview
2 parents c654388 + 23640d6 commit 4477c49

File tree

9 files changed

+618
-0
lines changed

9 files changed

+618
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Azure Arc Data Controller cluster
2+
3+
## __[Sample setup and deployment](deployment/)__
4+
This folder contains necessary instruction to setup and deploy sample Azure Arc Data Controller cluster.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
# Creating a Kubernetes cluster for Azure Arc Data Controller cluster
3+
4+
Azure Arc Data Controller cluster is deployed as docker containers on a Kubernetes cluster. These samples provide scripts that can be used to provision a Kubernetes clusters using different environments.
5+
6+
## __[Deploy a Kubernetes cluster using kubeadm](kubeadm/)__
7+
8+
Use the scripts in the **kubeadm** folder to deploy a Kubernetes cluster over one or more Linux machines (physical or virtualized) using `kubeadm` utility.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Create a Kubernetes cluster using Kubeadm on Ubuntu 16.04 LTS or 18.04 LTS
2+
3+
4+
## __[ubuntu](ubuntu/)__
5+
6+
This folder contains scripts that provide a template for deploying a Kubernetes cluster using kubeadm on one or more Linux machines.
7+
8+
## __[ubuntu-single-node-vm](ubuntu-single-node-vm/)__
9+
10+
This folder contains a sample script that can be used to create a single-node Kubernetes cluster on a Linux machine and deploy Azure Arc Data Controller cluster.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
2+
# Deploy a Azure Arc Data Controller 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 Azure Arc Data Controller on top of it. 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. 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 Azure Arc Data Controller
24+
25+
1. Download the script on the VM you are planning to use for the deployment
26+
27+
``` bash
28+
curl --output setup-controller.sh https://raw.githubusercontent.com/microsoft/sql-server-samples/master/samples/features/azure-arc/deployment/kubeadm/ubuntu-single-node-vm/setup-controller.sh
29+
```
30+
31+
2. Make the script executable
32+
33+
``` bash
34+
chmod +x setup-controller.sh
35+
```
36+
37+
3. Run the script (make sure you are running with sudo)
38+
39+
``` bash
40+
sudo ./setup-controller.sh
41+
```
42+
43+
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 *controlleradmin*.
44+
45+
## Cleanup
46+
47+
1. The [cleanup-controller.sh](cleanup-controller.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 capability in your hyper-visor to rollback the virtual machine to a clean state.
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
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+
11+
# Clean up azdata-cli package.
12+
#
13+
unalias azdata
14+
sudo dpkg --remove --force-all azdata-cli
15+
16+
systemctl stop kubelet
17+
rm -rf /var/lib/cni/
18+
rm -rf /var/lib/etcd/
19+
rm -rf /run/flannel/
20+
rm -rf /var/lib/kubelet/*
21+
rm -rf /etc/cni/
22+
rm -rf /etc/kubernetes/
23+
24+
ip link set cni0 down
25+
#brctl delbr cni0
26+
ip link set flannel.1 down
27+
#brctl delbr flannel.1
28+
iptables -F && iptables -t nat -F && iptables -t mangle -F && iptables -X
29+
30+
rm -rf .azdata/
31+
32+
# Remove mounts.
33+
#
34+
SERVICE_STOP_FAILED=0
35+
36+
systemctl | grep "/var/lib/kubelet/pods" | while read -r line; do
37+
38+
# Retrieve the mount path
39+
#
40+
MOUNT_PATH=`echo "$line" | grep -v echo | egrep -oh -m 1 "(/var/lib/kubelet/pods).+"`
41+
42+
if [ -z "$MOUNT_PATH" ]; then
43+
continue
44+
fi
45+
46+
if [[ ! -d "$MOUNT_PATH" ]] && [[ ! -f "$MOUNT_PATH" ]]; then
47+
48+
SERVICE=$(echo $line | cut -f1 -d' ')
49+
50+
echo "Mount "$MOUNT_PATH" no longer exists."
51+
echo "Stopping orphaned mount service: '$SERVICE'"
52+
53+
systemctl stop $SERVICE
54+
55+
if [ $? -ne 0 ]; then
56+
SERVICE_STOP_FAILED=1
57+
fi
58+
59+
echo ""
60+
fi
61+
done
62+
63+
if [ $SERVICE_STOP_FAILED -ne 0 ]; then
64+
echo "Not all services were stopped successfully. Please check the above output for more inforamtion."
65+
else
66+
echo "All orphaned services successfully stopped."
67+
fi
68+
69+
# Clean the mounted volumes.
70+
#
71+
72+
for i in $(seq 1 40); do
73+
74+
vol="vol$i"
75+
76+
sudo umount /mnt/local-storage/$vol
77+
78+
sudo rm -rf /mnt/local-storage/$vol
79+
80+
done
81+
82+
# Reset kube
83+
#
84+
sudo apt-get purge -y kubeadm --allow-change-held-packages
85+
sudo apt-get purge -y kubectl --allow-change-held-packages
86+
sudo apt-get purge -y kubelet --allow-change-held-packages
87+
sudo apt-get purge -y kubernetes-cni --allow-change-held-packages
88+
sudo apt-get purge -y kube* --allow-change-held-packages
89+
sudo apt -y autoremove
90+
sudo rm -rf ~/.kube
91+
92+
# Clean up working folders.
93+
#
94+
export AZUREARCDATACONTROLLER_DIR=aadatacontroller
95+
if [ -d "$AZUREARCDATACONTROLLER_DIR" ]; then
96+
echo "Removing working directory $AZUREARCDATACONTROLLER_DIR."
97+
rm -f -r $AZUREARCDATACONTROLLER_DIR
98+
fi

0 commit comments

Comments
 (0)