kubeformation

Azure Container Service (AKS)

For AKS clusters, Kubeformation creates Azure Resource Manager templates (ARM).

The provider string is aks.

Pre-requisites

Step 0 - Write cluster.yaml

PS: This step can be skipped if kubeformation.sh is used. Jump right ahead to Step 1.

Here’s an example cluster.yaml:

version: v1
name: my-cluster
provider: aks
k8sVersion: 1.8.1
nodePools:
- name: pool1
  type: Standard_D2_v2
  size: 2
  labels:
    app: my-app
volumes:
- name: my-vol
  size: 10

Note:

Step 1 - Generate ARM template

Download the template from kubeformation.sh

or

Generate the template using CLI:

$ mkdir templates
$ kubeformation -f cluster.yaml -o templates

This will give us the following files:

Step 2 - Add parameters

The following parameters are required:

To create service principal, execute the following command:

$ az ad sp create-for-rbac --name my-cluster-sp

The output will be a JSON, of which appId is the SERVICE-PRINCIPAL-CLIENT-ID and password is SERVICE-PRINCIPAL-CLIENT-SECRET.

These parameters should be added to aks-params.json file, by replacing the placeholders.

Step 3 - Create the cluster

Get kubectl context to connect to the cluster:

$ az aks get-credentials -g my-resource-group -n my-cluster

Step 4 - Create K8s Persistent Volumes

If the cluster spec also contains volumes, along with underlying disks, the Kubernetes PV & PVC objects also have to be created, so that the disks can be used by other k8s deployments etc.

Edit k8s-volumes.yaml and replace the placeholders for:

Create the k8s resources:

$ kubectl create -f k8s-volumes.yaml

Tearing down

Delete the resource group to tear down the cluster and disks:

$ az group delete -n my-resource-group

We also need to delete the resource group Azure created automatically to completely tear down all the resources:

$ az group delete -n MC_my-resource-group_my-cluster_westeurope