In this post we’ll take a look at a new script that I wrote to quickly build a Kubernetes (AKS) cluster with several core components preconfigured and installed out of the box. As a CSA for Microsoft I sometimes need to create an AKS cluster that goes beyond the cluster you get with the az command and I got tired of installing ingress controllers, cert-manager, and the like over and over. If your use case is similar to mine you should get some usefulness from this.
Building an AKS cluster that has all the standard tooling like an ingress controller, cert-manager, Let’s Encrypt certificate, Promethus, tiller and Kubernetes dashboard without having to repeat myself over and over for every cluster created.
There were probably a few ways to address this problem but I went with the one that would just work without much of a fuss. You really only need Helm, Azure CLI, and kubectl installed and the rest should be pretty easy.
I recently created a bash script called az-k8s in msft-csu/azure-scripts that tries to make creating a “basic” Kubernetes cluster as easy and as quickly as possible. If you want all the knobs and dials to create a multi-pool Kubernetes cluster look elsewhere but if you are more interested in just getting a simple cluster up and running with the standard tools and packages installed then this might be what you are looking for.
For instance running the following command will produce an AKS cluster that includes Tiller, Prometheus, Nginx Ingress and Cert-Manager. (Note: an email address is needed by Let’s Encrypt for the certificate). In this example a randomized pattern for naming is used but sit back and drink a coffee and 10-15 minutes later you’ll have something fun to play with.
>> az-k8s -i firstname.lastname@example.org -p -b
You can also customize the number and size of nodes for the node pool by using -c ans -s. The following customizes the size and number of nodes and installs Prometheus and configures the Kubernetes Dashboard
>> az-k8s -c 4 -s Standard_D16_v3 -p -b
Using the -f option allows you to pass in a yaml file that will be applied after the cluster has been configured. For instance the following will install the hello-world application included in the yaml directory.
>> az-k8s -f ./yaml/hello-world.yaml
Need to add these components to a cluster that’s already been created. You just need to pass in the resource group and name of the cluster and the script will install the components you need. NOTE: This part of the script hasn’t been tested as much as some of the other parts so mileage may vary.
>> az-k8s -n <cluster-name> -g <resourcegroup> -i admin@azurepatterns -p -b
Like I said before if you are a Solution Architect or Sales Engineer and need to spin up K8s clusters on a regular basis hopefully this can help.
Open an Github Issue if you find any issues or want some additional functionality added and as always if you have a contribution just open an pull request .
This script is written using bash getopts. You need to always pass arguments with paramters before you pass other parameters or results may be different than expected.