Most of the time we use the familiar Azure portal to consume Azure Resources. That is all well and good. However sometimes we find that having the Azure CLI to do this is more easier, as once we perfect the script we can just run it, instead of having to use the Portal. In this post I present a PowerShell script that I used to
- (a) turn on preview features,
- (b) register them,
- (c) check they are turned on, and
- (d) finally to consume them.
As of now, some of the preview features can only be turned by using the CLI.
Pre-requisites:
- An Azure subscription
- Access rights to the subscription
- Azure CLI installed on your local (Client) machine from where you will be running the script.
First let’s get connected.
#################################################
##### AKS Preview features ######################
#################################################
## This allows you to have multiple node pools within a single cluster.
## Now you can deploy different applications exclusively to these node pools
## Also for cluster auto-scaling, one should have node pools. Without that
## AUTO-Scaling is not possible. Ofcourse you can manually scale.
## Note that node pools are built on top of the VM Scale Set capability of Azure Compute.
az --version
az login --tenant microsoft.onmicrosoft.com
az account set --subscription cxxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxf
###################################
###### Set of Registrations #######
###################################
## (1) If not registered, register the container service.
az provider register --namespace Microsoft.ContainerService
## (2) Install the aks-preview extension
az extension add --name aks-preview
## (3) Update the extension to make sure you have the latest version installed
az extension update --name aks-preview
## (4) Register the feature on the Microsoft.ContainerService namespace to have the MultiAgentPool feature (which is preview)
az feature register --name MultiAgentpoolPreview --namespace Microsoft.ContainerService
## (5) Check the status of the feature - it takes time. Only when registered can you go further.
## This should show as "registered".
az feature list -o table --query "[?contains(name, 'Microsoft.ContainerService/MultiAgentpoolPreview')].{Name:name,State:properties.state}"
############################################
### Now for creating the cluster via CLI ###
############################################
# Create a basic single-node AKS cluster :: We will create all things in this RG.
az group create --name myResourceGroup --location eastus2euap
## Please note the additional options of vm-set-type and load-balancer-sku
az aks create `
--resource-group myResourceGroup `
--name myPreviewK8S `
--vm-set-type VirtualMachineScaleSets `
--node-count 2 `
--generate-ssh-keys `
--kubernetes-version 1.15.4 `
--load-balancer-sku standard
az aks get-credentials --resource-group myResourceGroup --name myPreviewK8S
## Now go onto experiment with adding node pools
az aks nodepool add `
--resource-group myResourceGroup `
--cluster-name myPreviewK8S `
--name mynodepool `
--node-count 3 `
--kubernetes-version 1.15.4
You must log in to post a comment.