#!/bin/bash

# John Hummel 20220601
# This script uses the Microsoft Azure CLI `az` command to set up a Kubernetes cluster that 
# can host Wallaroo Community Edition.
# For more details, see the Wallaroo Documentation site:  https://docs.wallaroo.ai

# Variables for the script. 
# Updated these depending on your organization's requirements.

WALLAROO_RESOURCE_GROUP=wallaroocegroupdocs
WALLAROO_GROUP_LOCATION=eastus
WALLAROO_CONTAINER_REGISTRY=wallarooceacrdocs
WALLAROO_CLUSTER=wallarooceaksdocs
WALLAROO_SKU_TYPE=Basic
WALLAROO_VM_SIZE=Standard_D8s_v4
WALLAROO_CLUSTER_SIZE=4

# Create the resource group
az group create --name $WALLAROO_RESOURCE_GROUP --location $WALLAROO_GROUP_LOCATION

# Create the ACR

az acr create -n $WALLAROO_CONTAINER_REGISTRY -g $WALLAROO_RESOURCE_GROUP --sku $WALLAROO_SKU_TYPE --location $WALLAROO_GROUP_LOCATION

# Create Wallaroo Kubernetes cluster

az aks create \
--resource-group $WALLAROO_RESOURCE_GROUP \
--name $WALLAROO_CLUSTER \
--node-count $WALLAROO_CLUSTER_SIZE \
--generate-ssh-keys \
--vm-set-type VirtualMachineScaleSets \
--load-balancer-sku standard \
--node-vm-size $WALLAROO_VM_SIZE \
--nodepool-name general \
--attach-acr $WALLAROO_CONTAINER_REGISTRY \
--kubernetes-version=1.25.6 \
--zones 1 \
--location $WALLAROO_GROUP_LOCATION

# Download the Kubernetes credentials

az aks get-credentials --resource-group $WALLAROO_RESOURCE_GROUP --name $WALLAROO_CLUSTER
