Skip to content

Commit 6521782

Browse files
committed
Fixing bug bash bugs.
1 parent af6c2aa commit 6521782

3 files changed

Lines changed: 73 additions & 42 deletions

File tree

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

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ 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 16 CPUs, 96GB RAM and 100GB 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

@@ -34,14 +34,31 @@ curl --output setup-controller.sh https://raw.githubusercontent.com/ananto-msft/
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 first cleanup your enviroment using [cleanup-controller.sh](cleanup-controller.sh/) before redoing 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 setup-controller.sh https://raw.githubusercontent.com/ananto-msft/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: 15 additions & 17 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

95
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: 36 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,46 @@
11
#!/bin/bash
2-
set -Eeuo pipefail
32

4-
# 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.
54
#
6-
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
723

8-
# 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
925
#
10-
while true; do
11-
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
1229
echo
13-
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
1435
echo
15-
[ "$password" = "$password2" ] && break
16-
echo "Password mismatch. Please try again."
17-
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
1844

1945
# Name of virtualenv variable used.
2046
#
@@ -37,9 +63,6 @@ RETRY_INTERVAL=5
3763

3864
# Variables used for azdata cluster creation.
3965
#
40-
export CONTROLLER_USERNAME=controlleradmin
41-
export CONTROLLER_PASSWORD=$password
42-
4366
export ACCEPT_EULA=yes
4467
export CLUSTER_NAME=azure-arc-system
4568
export PV_COUNT="40"
@@ -79,13 +102,6 @@ sudo apt-mark hold docker-ce
79102

80103
sudo usermod --append --groups docker $USER
81104

82-
# Prompt for private preview repository username and password provided by Microsoft
83-
#
84-
read -p 'Enter Azure Arc Data Controller repo username provided by Microsoft:' AADC_USERNAME
85-
read -sp 'Enter Azure Arc Data Controller repo password provided by Microsoft:' AADC_PASSWORD
86-
export DOCKER_USERNAME=$AADC_USERNAME
87-
export DOCKER_PASSWORD=$AADC_PASSWORD
88-
89105
# Create working directory
90106
#
91107
rm -f -r setupscript

0 commit comments

Comments
 (0)