Skip to content

Commit 5062ad2

Browse files
authored
Merge pull request #11 from ananto-msft/private-preview-bugbash-fixes
Private preview bugbash fixes
2 parents 4c40329 + d62fc60 commit 5062ad2

3 files changed

Lines changed: 108 additions & 80 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 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 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: 71 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,46 @@
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
#
@@ -42,9 +63,6 @@ RETRY_INTERVAL=5
4263

4364
# Variables used for azdata cluster creation.
4465
#
45-
export CONTROLLER_USERNAME=controlleradmin
46-
export CONTROLLER_PASSWORD=$password
47-
4866
export ACCEPT_EULA=yes
4967
export CLUSTER_NAME=azure-arc-system
5068
export PV_COUNT="40"
@@ -65,38 +83,35 @@ echo "Starting installing packages..."
6583

6684
# Install docker.
6785
#
68-
apt-get update -q
86+
sudo apt-get update -q
6987

70-
apt --yes install \
88+
sudo apt --yes install \
7189
software-properties-common \
7290
apt-transport-https \
7391
ca-certificates \
7492
curl
7593

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

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

81-
apt update -q
82-
apt-get install -q --yes docker-ce=18.06.2~ce~3-0~ubuntu --allow-downgrades
83-
apt-mark hold docker-ce
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
84102

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

94105
# Create working directory
95106
#
96107
rm -f -r setupscript
97108
mkdir -p setupscript
98109
cd setupscript/
99110

111+
# Download and install azdata prerequisites
112+
#
113+
sudo apt install -y libodbc1 odbcinst odbcinst1debian2 unixodbc
114+
100115
# Download and install azdata package
101116
#
102117
echo ""
@@ -108,6 +123,9 @@ cd -
108123
azdata --version
109124
echo "Azdata has been successfully installed."
110125

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

112130
# Load all pre-requisites for Kubernetes.
113131
#
@@ -116,32 +134,32 @@ echo "Starting to setup pre-requisites for kubernetes..."
116134

117135
# Setup the kubernetes preprequisites.
118136
#
119-
echo $(hostname -i) $(hostname) >> /etc/hosts
137+
echo $(hostname -i) $(hostname) >> sudo tee -a /etc/hosts
120138

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

124-
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 -
125143

126-
cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
144+
cat <<EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list
127145
128146
deb http://apt.kubernetes.io/ kubernetes-xenial main
129147
130148
EOF
131149

132150
# Install docker and packages to allow apt to use a repository over HTTPS.
133151
#
134-
apt-get update -q
152+
sudo apt-get update -q
135153

136-
apt-get install -q -y ebtables ethtool
154+
sudo apt-get install -q -y ebtables ethtool
137155

138156
#apt-get install -y docker.ce
139157

140-
apt-get install -q -y apt-transport-https
158+
sudo apt-get install -q -y apt-transport-https
141159

142160
# Setup daemon.
143161
#
144-
cat > /etc/docker/daemon.json <<EOF
162+
sudo tee /etc/docker/daemon.json <<EOF
145163
{
146164
"exec-opts": ["native.cgroupdriver=systemd"],
147165
"log-driver": "json-file",
@@ -152,19 +170,19 @@ cat > /etc/docker/daemon.json <<EOF
152170
}
153171
EOF
154172

155-
mkdir -p /etc/systemd/system/docker.service.d
173+
sudo mkdir -p /etc/systemd/system/docker.service.d
156174

157175
# Restart docker.
158176
#
159-
systemctl daemon-reload
160-
systemctl restart docker
177+
sudo systemctl daemon-reload
178+
sudo systemctl restart docker
161179

162-
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
163181

164182
# Holding the version of kube packages.
165183
#
166-
apt-mark hold kubelet kubeadm kubectl
167-
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
168186

169187
. /etc/os-release
170188
if [ "$UBUNTU_CODENAME" == "bionic" ]; then
@@ -177,22 +195,22 @@ sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1
177195
sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1
178196
sudo sysctl -w net.ipv6.conf.lo.disable_ipv6=1
179197

180-
echo net.ipv6.conf.all.disable_ipv6=1 >> /etc/sysctl.conf
181-
echo net.ipv6.conf.default.disable_ipv6=1 >> /etc/sysctl.conf
182-
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
183201

184202

185-
sysctl net.bridge.bridge-nf-call-iptables=1
203+
sudo sysctl net.bridge.bridge-nf-call-iptables=1
186204

187205
# Setting up the persistent volumes for the kubernetes.
188206
#
189207
for i in $(seq 1 $PV_COUNT); do
190208

191209
vol="vol$i"
192210

193-
mkdir -p /mnt/local-storage/$vol
211+
sudo mkdir -p /mnt/local-storage/$vol
194212

195-
mount --bind /mnt/local-storage/$vol /mnt/local-storage/$vol
213+
sudo mount --bind /mnt/local-storage/$vol /mnt/local-storage/$vol
196214

197215
done
198216
echo "Kubernetes pre-requisites have been completed."
@@ -208,10 +226,9 @@ echo "Starting to setup Kubernetes master..."
208226
sudo kubeadm init --pod-network-cidr=10.244.0.0/16 --kubernetes-version=$KUBE_VERSION
209227

210228
mkdir -p $HOME/.kube
211-
mkdir -p /home/$SUDO_USER/.kube
212229

213230
sudo cp -f /etc/kubernetes/admin.conf $HOME/.kube/config
214-
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
215232

216233
# To enable a single node cluster remove the taint that limits the first node to master only service.
217234
#
@@ -280,9 +297,5 @@ kubectl config set-context --current --namespace $CLUSTER_NAME
280297
#
281298
azdata login -n $CLUSTER_NAME
282299

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

0 commit comments

Comments
 (0)