# Set Up an Azure AKS Cluster

cnvrg can natively run using an EKS cluster hosted on your own AWS account and an EKS cluster can also be used to run all your cnvrg job. This allows you to leverage cnvrg and Kubernetes to create one flexible compute and DS environment.

In this guide, you will learn how to:

  • Create a AKS cluster using the Azure CLI

# Create a User in Azure with the Correct Permissions

Creating an AKS cluster requires certain permissions within Azure. To be able to complete the guide and create the cluster, ensure your user account has been added to an Azure subscription with the role contributor. You can then create the cluster using the subscription.

Of course, any permission level higher than contributor should also be suitable.

# Prerequisites: prepare your local environment

Before you can complete the installation you must install and prepare the following dependencies on your local machine:

# Use the Azure CLI to Connect to your Account

NOTE

You can skip this step if you have already logged in to the azure CLI and set the subscription for your account.

To be able to setup the cluster you will first need to log in to your Azure account in the Azure portal and create a subscription (for example, Pay As You Go).

To connect with your Azure account, use the Azure CLI:

  1. Login:
az login

TIP

If you have multiple Azure Active Directories, you can specify the directory to use with the --tenant flag.

  1. Set your subscription. Fill in the name of you subscription at the beginning with the correct information for your cluster:
SUBSCRIPTION_NAME=<subscription-name>

az account set --subscription ${SUBSCRIPTION_NAME}

# Create a Service Principle

NOTE

You can skip this step if you have already created a service principle.

To ensure we can set the correct access privileges for our AKS cluster, we will make a service principle. If you are an admin in Azure, this is created automatically.

az ad sp create-for-rbac --skip-assignment --name myAKSClusterServicePrincipal

# Create a Resource Group

NOTE

You can skip this step if you have already created a resource group.

If you do not yet have a group made for the cnvrg resources within Azure, create one with the following command. You will need to choose a location for the resources and a subscription. The location will affect which resources are available. Fill in the variables at the beginning with the correct information for your cluster:

SUBSCRIPTION_NAME=<subscription-name>
LOCATION=<zone>
RESOURCE_GROUP=<group_name>

az group create --name ${RESOURCE_GROUP} \
--location ${ZONE} \
--subscription ${SUBSCRIPTION_NAME}

TIP

You can get a list of all available locations by running the following command:

az account list-locations

# Create the AKS Cluster

To create the cluster in Azure, use the following command. Fill in the variables at the beginning with the correct information for your cluster:

SUBSCRIPTION_NAME=<subscription-name>
CLUSTER_NAME=<cluster-name>
RESOURCE_GROUP=<group_name>

az aks create --name ${CLUSTER_NAME} \
  --resource-group ${RESOURCE_GROUP} \
  --node-count 2 \
  --node-vm-size Standard_D8s_v3 \
  --enable-addons monitoring \
  --generate-ssh-keys \
  --subscription ${SUBSCRIPTION_NAME} \
  --enable-cluster-autoscaler

# Retrieve the Credentials (kubeconfig) for the Newly Created Cluster

Running the following command will save the kubeconfig for the new cluster locally. This allows you to be able to interact with it using kubectl.

The kubeconfig will be saved in ~/.kube/config

SUBSCRIPTION_NAME=<subscription-name>
CLUSTER_NAME=<cluster-name>
RESOURCE_GROUP=<group_name>

az aks get-credentials --name ${CLUSTER_NAME} --resource-group ${RESOURCE_GROUP} --subscription ${SUBSCRIPTION_NAME}

# Check the Cluster is Working Correctly

Run the following command to get a list of the nodes in the cluster. If this command runs correctly and returns the list of nodes, everything is working as expected:

kubectl get nodes

# Conclusion

Congratulations, you have now set up a working AKS cluster in Azure! You can now use Helm to finish the setup and get the cluster ready to be used for deploying the cnvrg app or running cnvrg jobs.

Follow this guide to complete the setup.

Last Updated: 4/6/2020, 6:43:35 AM