diff --git a/samples/features/azure-arc/deployment/kubeadm/ubuntu-single-node-vm/README.md b/samples/features/azure-arc/deployment/kubeadm/ubuntu-single-node-vm/README.md index d5568439..1487a7e5 100644 --- a/samples/features/azure-arc/deployment/kubeadm/ubuntu-single-node-vm/README.md +++ b/samples/features/azure-arc/deployment/kubeadm/ubuntu-single-node-vm/README.md @@ -6,17 +6,17 @@ Using this sample bash script, you will deploy a single node Kubernetes cluster ## Pre-requisites 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. -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. +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. 1. Update existing packages using commands below to ensure that the OS image is up to date ``` bash -sudo apt update&&apt upgrade -y +sudo apt update&& sudo apt upgrade -y sudo systemctl reboot ``` ## Recommended Virtual Machine settings -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. +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. 1. Use checkpoint or snapshot capability in your hyper visor so that you can rollback the virtual machine to a clean state. @@ -34,14 +34,31 @@ curl --output setup-controller.sh https://raw.githubusercontent.com/microsoft/sq chmod +x setup-controller.sh ``` -3. Run the script (make sure you are running with sudo) +3. Run the script ``` bash -sudo ./setup-controller.sh +./setup-controller.sh ``` -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*. +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. +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. ## Cleanup 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. + +``` bash +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 +``` + +2. Make the script executable + +``` bash +chmod +x cleanup-controller.sh +``` + +3. Run the script + +``` bash +./cleanup-controller.sh +``` diff --git a/samples/features/azure-arc/deployment/kubeadm/ubuntu-single-node-vm/cleanup-controller.sh b/samples/features/azure-arc/deployment/kubeadm/ubuntu-single-node-vm/cleanup-controller.sh index ec100756..92c57ee2 100644 --- a/samples/features/azure-arc/deployment/kubeadm/ubuntu-single-node-vm/cleanup-controller.sh +++ b/samples/features/azure-arc/deployment/kubeadm/ubuntu-single-node-vm/cleanup-controller.sh @@ -1,39 +1,37 @@ #!/bin/bash -if [ "$EUID" -ne 0 ] - then echo "Please run as root" - exit -fi DIR_PREFIX=$1 -kubeadm reset --force +sudo kubeadm reset --force # Clean up azdata-cli package. # unalias azdata +unalias az sudo dpkg --remove --force-all azdata-cli +sudo dpkg --remove --force-all azure-cli -systemctl stop kubelet -rm -rf /var/lib/cni/ -rm -rf /var/lib/etcd/ -rm -rf /run/flannel/ -rm -rf /var/lib/kubelet/* -rm -rf /etc/cni/ -rm -rf /etc/kubernetes/ +sudo systemctl stop kubelet +sudo rm -rf /var/lib/cni/ +sudo rm -rf /var/lib/etcd/ +sudo rm -rf /run/flannel/ +sudo rm -rf /var/lib/kubelet/* +sudo rm -rf /etc/cni/ +sudo rm -rf /etc/kubernetes/ -ip link set cni0 down +sudo ip link set cni0 down #brctl delbr cni0 -ip link set flannel.1 down +sudo ip link set flannel.1 down #brctl delbr flannel.1 -iptables -F && iptables -t nat -F && iptables -t mangle -F && iptables -X +sudo iptables -F && sudo iptables -t nat -F && sudo iptables -t mangle -F && sudo iptables -X -rm -rf .azdata/ +sudo rm -rf .azdata/ # Remove mounts. # SERVICE_STOP_FAILED=0 -systemctl | grep "/var/lib/kubelet/pods" | while read -r line; do +sudo systemctl | grep "/var/lib/kubelet/pods" | while read -r line; do # Retrieve the mount path # @@ -50,7 +48,7 @@ systemctl | grep "/var/lib/kubelet/pods" | while read -r line; do echo "Mount "$MOUNT_PATH" no longer exists." echo "Stopping orphaned mount service: '$SERVICE'" - systemctl stop $SERVICE + sudo systemctl stop $SERVICE if [ $? -ne 0 ]; then SERVICE_STOP_FAILED=1 diff --git a/samples/features/azure-arc/deployment/kubeadm/ubuntu-single-node-vm/setup-controller.sh b/samples/features/azure-arc/deployment/kubeadm/ubuntu-single-node-vm/setup-controller.sh index 6676d0e1..83e29ee5 100644 --- a/samples/features/azure-arc/deployment/kubeadm/ubuntu-single-node-vm/setup-controller.sh +++ b/samples/features/azure-arc/deployment/kubeadm/ubuntu-single-node-vm/setup-controller.sh @@ -1,33 +1,55 @@ #!/bin/bash -set -Eeuo pipefail -if [ "$EUID" -ne 0 ] - then echo "Please run as root" - exit +# Get controller username and password as input. It is used as default for the controller. +# +if [ -z "$CONTROLLER_USERNAME" ] +then + read -p "Create Username for Azure Arc Data Controller: " username + echo + export CONTROLLER_USERNAME=$username fi +if [ -z "$CONTROLLER_PASSWORD" ] +then + while true; do + read -s -p "Create Password for Azure Arc Data Controller: " password + echo + read -s -p "Confirm your Password: " password2 + echo + [ "$password" = "$password2" ] && break + echo "Password mismatch. Please try again." + done + export CONTROLLER_PASSWORD=$password +fi + +# Prompt for private preview repository username and password provided by Microsoft +# +if [ -z "$DOCKER_USERNAME" ] +then + read -p 'Enter Azure Arc Data Controller repo username provided by Microsoft:' AADC_USERNAME + echo + export DOCKER_USERNAME=$AADC_USERNAME +fi +if [ -z "$DOCKER_PASSWORD" ] +then + read -sp 'Enter Azure Arc Data Controller repo password provided by Microsoft:' AADC_PASSWORD + echo + export DOCKER_PASSWORD=$AADC_PASSWORD +fi + +set -Eeuo pipefail # This is a script to create single-node Kubernetes cluster and deploy Azure Arc Data Controller on it. # export AZUREARCDATACONTROLLER_DIR=aadatacontroller -# Get password as input. It is used as default for controller, SQL Server Master instance (sa account). -# -while true; do - read -s -p "Create Password for Azure Arc Data Controller: " password - echo - read -s -p "Confirm your Password: " password2 - echo - [ "$password" = "$password2" ] && break - echo "Password mismatch. Please try again." -done - # Name of virtualenv variable used. # export LOG_FILE="aadatacontroller.log" export DEBIAN_FRONTEND=noninteractive # Requirements file. -export AZDATA_PRIVATE_PREVIEW_DEB_PACKAGE="https://aka.ms/aadatacontrollerazdata" +export OSCODENAME=$(lsb_release -cs) +export AZDATA_PRIVATE_PREVIEW_DEB_PACKAGE="https://aka.ms/azdata-"$OSCODENAME # Kube version. # @@ -41,9 +63,6 @@ RETRY_INTERVAL=5 # Variables used for azdata cluster creation. # -export CONTROLLER_USERNAME=controlleradmin -export CONTROLLER_PASSWORD=$password - export ACCEPT_EULA=yes export CLUSTER_NAME=azure-arc-system export PV_COUNT="40" @@ -64,9 +83,9 @@ echo "Starting installing packages..." # Install docker. # -apt-get update -q +sudo apt-get update -q -apt --yes install \ +sudo apt --yes install \ software-properties-common \ apt-transport-https \ ca-certificates \ @@ -74,21 +93,14 @@ apt --yes install \ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - -add-apt-repository \ +sudo add-apt-repository \ "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" -apt update -q -apt-get install -q --yes docker-ce=18.06.2~ce~3-0~ubuntu --allow-downgrades -apt-mark hold docker-ce +sudo apt update -q +sudo apt-get install -q --yes docker-ce=18.06.2~ce~3-0~ubuntu --allow-downgrades +sudo apt-mark hold docker-ce -usermod --append --groups docker $USER - -# Prompt for private preview repository username and password provided by Microsoft -# -read -p 'Enter Azure Arc Data Controller repo username provided by Microsoft:' AADC_USERNAME -read -sp 'Enter Azure Arc Data Controller repo password provided by Microsoft:' AADC_PASSWORD -export DOCKER_USERNAME=$AADC_USERNAME -export DOCKER_PASSWORD=$AADC_PASSWORD +sudo usermod --append --groups docker $USER # Create working directory # @@ -96,8 +108,14 @@ rm -f -r setupscript mkdir -p setupscript cd setupscript/ +# Download and install azdata prerequisites +# +sudo apt install -y libodbc1 odbcinst odbcinst1debian2 unixodbc + # Download and install azdata package # +echo "" +echo "Downloading azdata installer from" $AZDATA_PRIVATE_PREVIEW_DEB_PACKAGE curl --location $AZDATA_PRIVATE_PREVIEW_DEB_PACKAGE --output azdata_setup.deb sudo dpkg -i azdata_setup.deb cd - @@ -105,6 +123,9 @@ cd - azdata --version echo "Azdata has been successfully installed." +# Install Azure CLI +# +curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash # Load all pre-requisites for Kubernetes. # @@ -113,14 +134,14 @@ echo "Starting to setup pre-requisites for kubernetes..." # Setup the kubernetes preprequisites. # -echo $(hostname -i) $(hostname) >> /etc/hosts +echo $(hostname -i) $(hostname) >> sudo tee -a /etc/hosts swapoff -a -sed -i '/swap/s/^\(.*\)$/#\1/g' /etc/fstab +sudo sed -i '/swap/s/^\(.*\)$/#\1/g' /etc/fstab -curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - +curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - -cat </etc/apt/sources.list.d/kubernetes.list +cat < /etc/docker/daemon.json < /etc/docker/daemon.json <> /etc/sysctl.conf -echo net.ipv6.conf.default.disable_ipv6=1 >> /etc/sysctl.conf -echo net.ipv6.conf.lo.disable_ipv6=1 >> /etc/sysctl.conf +echo net.ipv6.conf.all.disable_ipv6=1 | sudo tee -a /etc/sysctl.conf +echo net.ipv6.conf.default.disable_ipv6=1 | sudo tee -a /etc/sysctl.conf +echo net.ipv6.conf.lo.disable_ipv6=1 | sudo tee -a /etc/sysctl.conf -sysctl net.bridge.bridge-nf-call-iptables=1 +sudo sysctl net.bridge.bridge-nf-call-iptables=1 # Setting up the persistent volumes for the kubernetes. # @@ -187,9 +208,9 @@ for i in $(seq 1 $PV_COUNT); do vol="vol$i" - mkdir -p /mnt/local-storage/$vol + sudo mkdir -p /mnt/local-storage/$vol - mount --bind /mnt/local-storage/$vol /mnt/local-storage/$vol + sudo mount --bind /mnt/local-storage/$vol /mnt/local-storage/$vol done echo "Kubernetes pre-requisites have been completed." @@ -205,10 +226,9 @@ echo "Starting to setup Kubernetes master..." sudo kubeadm init --pod-network-cidr=10.244.0.0/16 --kubernetes-version=$KUBE_VERSION mkdir -p $HOME/.kube -mkdir -p /home/$SUDO_USER/.kube sudo cp -f /etc/kubernetes/admin.conf $HOME/.kube/config -sudo chown $(id -u $SUDO_USER):$(id -g $SUDO_USER) $HOME/.kube/config +sudo chown $(id -u $USER):$(id -g $USER) $HOME/.kube/config # To enable a single node cluster remove the taint that limits the first node to master only service. # @@ -266,7 +286,7 @@ echo "Starting to deploy azdata cluster..." # Command to create cluster for single node cluster. # -azdata control create -n $CLUSTER_NAME -c azure-arc-kubeadm-private-preview --accept-eula $ACCEPT_EULA +azdata control create -n $CLUSTER_NAME -c azure-arc-kubeadm-private-preview-acr --accept-eula $ACCEPT_EULA echo "Azure Arc Data Controller cluster created." # Setting context to cluster. @@ -277,9 +297,5 @@ kubectl config set-context --current --namespace $CLUSTER_NAME # azdata login -n $CLUSTER_NAME -if [ -d "$HOME/.azdata/" ]; then - sudo chown -R $(id -u $SUDO_USER):$(id -g $SUDO_USER) $HOME/.azdata/ -fi - echo "Cluster successfully setup. Run 'azdata --help' to see all available options." }| tee $LOG_FILE diff --git a/samples/features/azure-arc/deployment/kubeadm/ubuntu/README.md b/samples/features/azure-arc/deployment/kubeadm/ubuntu/README.md index ad17a2a2..8c6ca322 100644 --- a/samples/features/azure-arc/deployment/kubeadm/ubuntu/README.md +++ b/samples/features/azure-arc/deployment/kubeadm/ubuntu/README.md @@ -4,11 +4,11 @@ In this example, we will deploy Kubernetes over multiple Linux machines (physica ## Pre-requisites -1. Multiple Ubuntu Linux machines or virtual machines. Recommended configuration is 8 CPUs, 32 GB memory each and at least 100 GB storage for each machine. Minimum number of machines required is three machines +1. Multiple Ubuntu Linux machines or virtual machines. Recommended configuration is 8 CPUs, 32 GB memory each and at least 128 GB storage for each machine. Minimum number of machines required is three machines 1. Designate one machine as the Kubernetes master 1. Rest of the machines will be used as the Kubernetes agents -**NOTE: Ensure there is sufficient local storage on your agents. Each volume will use up to 10GB by default. The script creates 25 volumes. Not all of the volumes will be used since it depends on the number of pods being deployed on each agent node. It is recommended to have at least 200 GB of storage on the agent nodes** +**NOTE: Ensure there is sufficient local storage on your agents. Each volume will use up to 10GB by default. The script creates 40 volumes. Not all of the volumes will be used since it depends on the number of pods being deployed on each agent node. It is recommended to have at least 200 GB of storage on the agent nodes** ### Useful resources