#!/bin/bash

resource_group="workshop-rg"

# Create a group that bundles all
time az group create --name ${resource_group} --location westeurope

# Use the template and parameter files to create resources within the group
time az deployment group create  --resource-group ${resource_group} --template-file azuredeploy.json --parameters @azuredeploy.parameters.json

# When done, generate a list of ip adresses for further processing
az vm list-ip-addresses --resource-group ${resource_group} --output json | jq -r '.[].virtualMachine.network.publicIpAddresses[].ipAddress' > tags/triodos/ips.txt

# Wait until VMs are ready (reachable and cloud init is done)
time ./workshopctl wait  triodos

# Group VMs in clusters
time ./workshopctl clusterize  triodos

# Install a bunch of useful tools (editors, git, jq...)
time ./workshopctl tools  triodos

# Install and start Docker
time ./workshopctl docker  triodos

# Create the user that students will use
time ./workshopctl createuser triodos

# Install a WEB SSH server on the machines (port 1080)
time ./workshopctl webssh triodos

# Install history viewer on port 1088
time ./workshopctl tailhist triodos

# Setup kubernetes clusters with kubeadm (must be run AFTER deploy)
time ./workshopctl kube triodos

# Install a bunch of CLI tools for Kubernetes
time ./workshopctl kubetools triodos

# Install Kubernetes and CNI binaries but don't start anything
#time ./workshopctl kubetest triodos

# # Check that all nodes are reporting as Ready
# time ./workshopctl kubetest triodos

# Generate ready-to-print cards for a group of VMs
time ./workshopctl cards triodos

# Show the IP addresses for a given tag
time ./workshopctl ips triodos


exit 0

docker run -d -p 10000:10000 snsyzb/webssh wssh --address=0.0.0.0 --port=10000
