Skip to content

Instantly share code, notes, and snippets.

@brusMX
Last active September 28, 2017 04:51
Show Gist options
  • Save brusMX/b5706d7f32ae804dc92723ccc277896a to your computer and use it in GitHub Desktop.
Save brusMX/b5706d7f32ae804dc92723ccc277896a to your computer and use it in GitHub Desktop.
#!/bin/bash
# Interactively create an Azure Container service with kubernetes and custom Agent pools
# Author: Bruno Medina (@brusmx)
# Requirements:
# - Azure Cli 2.0
# - jq
#
# Example of usage:
# ./create-acs-k8s-custom-agent-pools.sh
# Making sure it's connected
DEFAULT_ACCOUNT=`az account show`
DEFAULT_ACCOUNT_ID=`echo $DEFAULT_ACCOUNT | jq -r '.id'`
if [ ! -z "$DEFAULT_ACCOUNT_ID" ]; then
# Create resource groups
RG_NAME=$(mktemp k8s-mixed-agents-rg-XXXXXXX)
# Supported regions for V2 are:
# UK West, UK South, West Central US, West US 2,
# Canada, East Canada, Central West India, South India, Central India
LOC=centralindia
CLUSTER_NAME=mixed-k8s-cluster
AGENT_POOLS="[{'name':'agentpool1','vmSize':'Standard_DS2_v2_Promo','count':1},{'name':'agentpool2','vmSize':'Standard_DS3_v2_Promo','count':1}]"
echo "Creating Resource Group"
az group create -n $RG_NAME -l $LOC
echo "... created."
echo "Creating k8s cluster..."
echo "K8s cluster name: ${CLUSTER_NAME}"
echo "Resource group name: ${RG_NAME}"
echo "Location: ${RG_NAME}"
az acs create -n $CLUSTER_NAME -g $RG_NAME -t kubernetes -a "${AGENT_POOLS}" --generate-ssh-keys --agent-ports 3389
else
echo "Your subscription couldn't be found, make sure you have logged in:"
echo "az login"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment