Skip to content

Commit a1b806a

Browse files
authored
Merge pull request #695 from ananto-msft/master
Merging all changes for Azure-Arc related fork to microsoft/sql-server-samples
2 parents 57f548d + 4b94b9c commit a1b806a

4 files changed

Lines changed: 117 additions & 86 deletions

File tree

samples/features/azure-arc/deployment/kubeadm/ubuntu-single-node-vm/README.md

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@ Using this sample bash script, you will deploy a single node Kubernetes cluster
66
## Pre-requisites
77

88
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.
9+
1. Machine should have at least 8 CPUs, 32GB RAM and 128GB disk space. After installing the images you will be left with 50GB for data/logs across all components.
1010
1. Update existing packages using commands below to ensure that the OS image is up to date
1111

1212
``` bash
13-
sudo apt update&&apt upgrade -y
13+
sudo apt update&& sudo apt upgrade -y
1414
sudo systemctl reboot
1515
```
1616

1717
## Recommended Virtual Machine settings
1818

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.
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 32 GB or higher.
2020

2121
1. Use checkpoint or snapshot capability in your hyper visor so that you can rollback the virtual machine to a clean state.
2222

@@ -34,14 +34,31 @@ curl --output setup-controller.sh https://raw.githubusercontent.com/microsoft/sq
3434
chmod +x setup-controller.sh
3535
```
3636

37-
3. Run the script (make sure you are running with sudo)
37+
3. Run the script
3838

3939
``` bash
40-
sudo ./setup-controller.sh
40+
./setup-controller.sh
4141
```
4242

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*.
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.
44+
In case the setup-controller.sh fails and does not complete successfully, you should cleanup your enviroment using [cleanup-controller.sh](cleanup-controller.sh/) before retrying the deployment.
4445

4546
## Cleanup
4647

4748
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.
49+
50+
``` bash
51+
curl --output cleanup-controller.sh https://raw.githubusercontent.com/microsoft/sql-server-samples/master/samples/features/azure-arc/deployment/kubeadm/ubuntu-single-node-vm/cleanup-controller.sh
52+
```
53+
54+
2. Make the script executable
55+
56+
``` bash
57+
chmod +x cleanup-controller.sh
58+
```
59+
60+
3. Run the script
61+
62+
``` bash
63+
./cleanup-controller.sh
64+
```

samples/features/azure-arc/deployment/kubeadm/ubuntu-single-node-vm/cleanup-controller.sh

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,37 @@
11
#!/bin/bash
22

3-
if [ "$EUID" -ne 0 ]
4-
then echo "Please run as root"
5-
exit
6-
fi
73
DIR_PREFIX=$1
84

9-
kubeadm reset --force
5+
sudo kubeadm reset --force
106

117
# Clean up azdata-cli package.
128
#
139
unalias azdata
10+
unalias az
1411
sudo dpkg --remove --force-all azdata-cli
12+
sudo dpkg --remove --force-all azure-cli
1513

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/
14+
sudo systemctl stop kubelet
15+
sudo rm -rf /var/lib/cni/
16+
sudo rm -rf /var/lib/etcd/
17+
sudo rm -rf /run/flannel/
18+
sudo rm -rf /var/lib/kubelet/*
19+
sudo rm -rf /etc/cni/
20+
sudo rm -rf /etc/kubernetes/
2321

24-
ip link set cni0 down
22+
sudo ip link set cni0 down
2523
#brctl delbr cni0
26-
ip link set flannel.1 down
24+
sudo ip link set flannel.1 down
2725
#brctl delbr flannel.1
28-
iptables -F && iptables -t nat -F && iptables -t mangle -F && iptables -X
26+
sudo iptables -F && sudo iptables -t nat -F && sudo iptables -t mangle -F && sudo iptables -X
2927

30-
rm -rf .azdata/
28+
sudo rm -rf .azdata/
3129

3230
# Remove mounts.
3331
#
3432
SERVICE_STOP_FAILED=0
3533

36-
systemctl | grep "/var/lib/kubelet/pods" | while read -r line; do
34+
sudo systemctl | grep "/var/lib/kubelet/pods" | while read -r line; do
3735

3836
# Retrieve the mount path
3937
#
@@ -50,7 +48,7 @@ systemctl | grep "/var/lib/kubelet/pods" | while read -r line; do
5048
echo "Mount "$MOUNT_PATH" no longer exists."
5149
echo "Stopping orphaned mount service: '$SERVICE'"
5250

53-
systemctl stop $SERVICE
51+
sudo systemctl stop $SERVICE
5452

5553
if [ $? -ne 0 ]; then
5654
SERVICE_STOP_FAILED=1

samples/features/azure-arc/deployment/kubeadm/ubuntu-single-node-vm/setup-controller.sh

Lines changed: 76 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,55 @@
11
#!/bin/bash
2-
set -Eeuo pipefail
3-
4-
if [ "$EUID" -ne 0 ]
5-
then echo "Please run as root"
6-
exit
7-
fi
82

9-
# This is a script to create single-node Kubernetes cluster and deploy Azure Arc Data Controller on it.
3+
# Get controller username and password as input. It is used as default for the controller.
104
#
11-
export AZUREARCDATACONTROLLER_DIR=aadatacontroller
5+
if [ -z "$CONTROLLER_USERNAME" ]
6+
then
7+
read -p "Create Username for Azure Arc Data Controller: " username
8+
echo
9+
export CONTROLLER_USERNAME=$username
10+
fi
11+
if [ -z "$CONTROLLER_PASSWORD" ]
12+
then
13+
while true; do
14+
read -s -p "Create Password for Azure Arc Data Controller: " password
15+
echo
16+
read -s -p "Confirm your Password: " password2
17+
echo
18+
[ "$password" = "$password2" ] && break
19+
echo "Password mismatch. Please try again."
20+
done
21+
export CONTROLLER_PASSWORD=$password
22+
fi
1223

13-
# Get password as input. It is used as default for controller, SQL Server Master instance (sa account).
24+
# Prompt for private preview repository username and password provided by Microsoft
1425
#
15-
while true; do
16-
read -s -p "Create Password for Azure Arc Data Controller: " password
26+
if [ -z "$DOCKER_USERNAME" ]
27+
then
28+
read -p 'Enter Azure Arc Data Controller repo username provided by Microsoft:' AADC_USERNAME
1729
echo
18-
read -s -p "Confirm your Password: " password2
30+
export DOCKER_USERNAME=$AADC_USERNAME
31+
fi
32+
if [ -z "$DOCKER_PASSWORD" ]
33+
then
34+
read -sp 'Enter Azure Arc Data Controller repo password provided by Microsoft:' AADC_PASSWORD
1935
echo
20-
[ "$password" = "$password2" ] && break
21-
echo "Password mismatch. Please try again."
22-
done
36+
export DOCKER_PASSWORD=$AADC_PASSWORD
37+
fi
38+
39+
set -Eeuo pipefail
40+
41+
# This is a script to create single-node Kubernetes cluster and deploy Azure Arc Data Controller on it.
42+
#
43+
export AZUREARCDATACONTROLLER_DIR=aadatacontroller
2344

2445
# Name of virtualenv variable used.
2546
#
2647
export LOG_FILE="aadatacontroller.log"
2748
export DEBIAN_FRONTEND=noninteractive
2849

2950
# Requirements file.
30-
export AZDATA_PRIVATE_PREVIEW_DEB_PACKAGE="https://aka.ms/aadatacontrollerazdata"
51+
export OSCODENAME=$(lsb_release -cs)
52+
export AZDATA_PRIVATE_PREVIEW_DEB_PACKAGE="https://aka.ms/azdata-"$OSCODENAME
3153

3254
# Kube version.
3355
#
@@ -41,9 +63,6 @@ RETRY_INTERVAL=5
4163

4264
# Variables used for azdata cluster creation.
4365
#
44-
export CONTROLLER_USERNAME=controlleradmin
45-
export CONTROLLER_PASSWORD=$password
46-
4766
export ACCEPT_EULA=yes
4867
export CLUSTER_NAME=azure-arc-system
4968
export PV_COUNT="40"
@@ -64,47 +83,49 @@ echo "Starting installing packages..."
6483

6584
# Install docker.
6685
#
67-
apt-get update -q
86+
sudo apt-get update -q
6887

69-
apt --yes install \
88+
sudo apt --yes install \
7089
software-properties-common \
7190
apt-transport-https \
7291
ca-certificates \
7392
curl
7493

7594
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
7695

77-
add-apt-repository \
96+
sudo add-apt-repository \
7897
"deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
7998

80-
apt update -q
81-
apt-get install -q --yes docker-ce=18.06.2~ce~3-0~ubuntu --allow-downgrades
82-
apt-mark hold docker-ce
83-
84-
usermod --append --groups docker $USER
99+
sudo apt update -q
100+
sudo apt-get install -q --yes docker-ce=18.06.2~ce~3-0~ubuntu --allow-downgrades
101+
sudo apt-mark hold docker-ce
85102

86-
# Prompt for private preview repository username and password provided by Microsoft
87-
#
88-
read -p 'Enter Azure Arc Data Controller repo username provided by Microsoft:' AADC_USERNAME
89-
read -sp 'Enter Azure Arc Data Controller repo password provided by Microsoft:' AADC_PASSWORD
90-
export DOCKER_USERNAME=$AADC_USERNAME
91-
export DOCKER_PASSWORD=$AADC_PASSWORD
103+
sudo usermod --append --groups docker $USER
92104

93105
# Create working directory
94106
#
95107
rm -f -r setupscript
96108
mkdir -p setupscript
97109
cd setupscript/
98110

111+
# Download and install azdata prerequisites
112+
#
113+
sudo apt install -y libodbc1 odbcinst odbcinst1debian2 unixodbc
114+
99115
# Download and install azdata package
100116
#
117+
echo ""
118+
echo "Downloading azdata installer from" $AZDATA_PRIVATE_PREVIEW_DEB_PACKAGE
101119
curl --location $AZDATA_PRIVATE_PREVIEW_DEB_PACKAGE --output azdata_setup.deb
102120
sudo dpkg -i azdata_setup.deb
103121
cd -
104122

105123
azdata --version
106124
echo "Azdata has been successfully installed."
107125

126+
# Install Azure CLI
127+
#
128+
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
108129

109130
# Load all pre-requisites for Kubernetes.
110131
#
@@ -113,32 +134,32 @@ echo "Starting to setup pre-requisites for kubernetes..."
113134

114135
# Setup the kubernetes preprequisites.
115136
#
116-
echo $(hostname -i) $(hostname) >> /etc/hosts
137+
echo $(hostname -i) $(hostname) >> sudo tee -a /etc/hosts
117138

118139
swapoff -a
119-
sed -i '/swap/s/^\(.*\)$/#\1/g' /etc/fstab
140+
sudo sed -i '/swap/s/^\(.*\)$/#\1/g' /etc/fstab
120141

121-
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
142+
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
122143

123-
cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
144+
cat <<EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list
124145
125146
deb http://apt.kubernetes.io/ kubernetes-xenial main
126147
127148
EOF
128149

129150
# Install docker and packages to allow apt to use a repository over HTTPS.
130151
#
131-
apt-get update -q
152+
sudo apt-get update -q
132153

133-
apt-get install -q -y ebtables ethtool
154+
sudo apt-get install -q -y ebtables ethtool
134155

135156
#apt-get install -y docker.ce
136157

137-
apt-get install -q -y apt-transport-https
158+
sudo apt-get install -q -y apt-transport-https
138159

139160
# Setup daemon.
140161
#
141-
cat > /etc/docker/daemon.json <<EOF
162+
sudo tee /etc/docker/daemon.json <<EOF
142163
{
143164
"exec-opts": ["native.cgroupdriver=systemd"],
144165
"log-driver": "json-file",
@@ -149,19 +170,19 @@ cat > /etc/docker/daemon.json <<EOF
149170
}
150171
EOF
151172

152-
mkdir -p /etc/systemd/system/docker.service.d
173+
sudo mkdir -p /etc/systemd/system/docker.service.d
153174

154175
# Restart docker.
155176
#
156-
systemctl daemon-reload
157-
systemctl restart docker
177+
sudo systemctl daemon-reload
178+
sudo systemctl restart docker
158179

159-
apt-get install -q -y kubelet=$KUBE_DPKG_VERSION kubeadm=$KUBE_DPKG_VERSION kubectl=$KUBE_DPKG_VERSION
180+
sudo apt-get install -q -y kubelet=$KUBE_DPKG_VERSION kubeadm=$KUBE_DPKG_VERSION kubectl=$KUBE_DPKG_VERSION
160181

161182
# Holding the version of kube packages.
162183
#
163-
apt-mark hold kubelet kubeadm kubectl
164-
curl https://raw.githubusercontent.com/kubernetes/helm/master/scripts/get | bash
184+
sudo apt-mark hold kubelet kubeadm kubectl
185+
curl https://raw.githubusercontent.com/kubernetes/helm/master/scripts/get | sudo bash
165186

166187
. /etc/os-release
167188
if [ "$UBUNTU_CODENAME" == "bionic" ]; then
@@ -174,22 +195,22 @@ sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1
174195
sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1
175196
sudo sysctl -w net.ipv6.conf.lo.disable_ipv6=1
176197

177-
echo net.ipv6.conf.all.disable_ipv6=1 >> /etc/sysctl.conf
178-
echo net.ipv6.conf.default.disable_ipv6=1 >> /etc/sysctl.conf
179-
echo net.ipv6.conf.lo.disable_ipv6=1 >> /etc/sysctl.conf
198+
echo net.ipv6.conf.all.disable_ipv6=1 | sudo tee -a /etc/sysctl.conf
199+
echo net.ipv6.conf.default.disable_ipv6=1 | sudo tee -a /etc/sysctl.conf
200+
echo net.ipv6.conf.lo.disable_ipv6=1 | sudo tee -a /etc/sysctl.conf
180201

181202

182-
sysctl net.bridge.bridge-nf-call-iptables=1
203+
sudo sysctl net.bridge.bridge-nf-call-iptables=1
183204

184205
# Setting up the persistent volumes for the kubernetes.
185206
#
186207
for i in $(seq 1 $PV_COUNT); do
187208

188209
vol="vol$i"
189210

190-
mkdir -p /mnt/local-storage/$vol
211+
sudo mkdir -p /mnt/local-storage/$vol
191212

192-
mount --bind /mnt/local-storage/$vol /mnt/local-storage/$vol
213+
sudo mount --bind /mnt/local-storage/$vol /mnt/local-storage/$vol
193214

194215
done
195216
echo "Kubernetes pre-requisites have been completed."
@@ -205,10 +226,9 @@ echo "Starting to setup Kubernetes master..."
205226
sudo kubeadm init --pod-network-cidr=10.244.0.0/16 --kubernetes-version=$KUBE_VERSION
206227

207228
mkdir -p $HOME/.kube
208-
mkdir -p /home/$SUDO_USER/.kube
209229

210230
sudo cp -f /etc/kubernetes/admin.conf $HOME/.kube/config
211-
sudo chown $(id -u $SUDO_USER):$(id -g $SUDO_USER) $HOME/.kube/config
231+
sudo chown $(id -u $USER):$(id -g $USER) $HOME/.kube/config
212232

213233
# To enable a single node cluster remove the taint that limits the first node to master only service.
214234
#
@@ -266,7 +286,7 @@ echo "Starting to deploy azdata cluster..."
266286

267287
# Command to create cluster for single node cluster.
268288
#
269-
azdata control create -n $CLUSTER_NAME -c azure-arc-kubeadm-private-preview --accept-eula $ACCEPT_EULA
289+
azdata control create -n $CLUSTER_NAME -c azure-arc-kubeadm-private-preview-acr --accept-eula $ACCEPT_EULA
270290
echo "Azure Arc Data Controller cluster created."
271291

272292
# Setting context to cluster.
@@ -277,9 +297,5 @@ kubectl config set-context --current --namespace $CLUSTER_NAME
277297
#
278298
azdata login -n $CLUSTER_NAME
279299

280-
if [ -d "$HOME/.azdata/" ]; then
281-
sudo chown -R $(id -u $SUDO_USER):$(id -g $SUDO_USER) $HOME/.azdata/
282-
fi
283-
284300
echo "Cluster successfully setup. Run 'azdata --help' to see all available options."
285301
}| tee $LOG_FILE

0 commit comments

Comments
 (0)