|
| 1 | +--- |
| 2 | +page_title: Azure Kubernetes Service |
| 3 | +subcategory: Development |
| 4 | +--- |
| 5 | + |
| 6 | +# Azure Kubernetes Service |
| 7 | + |
| 8 | +## Installing the Azure command-line interface tool |
| 9 | + |
| 10 | +Install the `az` tool following the official documentation on the Microsoft documentation portal: [https://docs.microsoft.com/en-us/cli/azure/install-azure-cli](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli) |
| 11 | + |
| 12 | +## Enabling experimental features |
| 13 | + |
| 14 | +In order to automatically provision GPU nodes for the cluster, enable the following experimental features through the `aks-preview` extension: |
| 15 | + |
| 16 | +```bash |
| 17 | +az extension add --name aks-preview |
| 18 | +az provider register --namespace Microsoft.ContainerService |
| 19 | +az feature register \ |
| 20 | + --namespace Microsoft.ContainerService \ |
| 21 | + --name GPUDedicatedVHDPreview |
| 22 | +``` |
| 23 | + |
| 24 | +## Creating a test cluster |
| 25 | + |
| 26 | +The following commands will create an AKS cluster with a single node, keeping everything in a new resource group for easier deletion when done: |
| 27 | + |
| 28 | +```bash |
| 29 | +az group create \ |
| 30 | + --name testKubernetesResourceGroup \ |
| 31 | + --location eastus |
| 32 | +``` |
| 33 | + |
| 34 | +```bash |
| 35 | +az aks create \ |
| 36 | + --resource-group testKubernetesResourceGroup \ |
| 37 | + --name testKubernetesCluster \ |
| 38 | + --node-vm-size Standard_NC6 \ |
| 39 | + --node-count 1 \ |
| 40 | + --aks-custom-headers UseGPUDedicatedVHD=true |
| 41 | +``` |
| 42 | + |
| 43 | +<details><summary><i>Click to reveal a budget-friendly cluster configuration without GPU...</summary> |
| 44 | + |
| 45 | +```bash |
| 46 | +az aks create \ |
| 47 | + --resource-group testKubernetesResourceGroup \ |
| 48 | + --name testKubernetesCluster \ |
| 49 | + --node-vm-size Standard_A2_v2 \ |
| 50 | + --node-count 1 |
| 51 | +``` |
| 52 | + |
| 53 | +</details> |
| 54 | + |
| 55 | +## Retrieving the credentials |
| 56 | + |
| 57 | +Azure has some wrappers for Kubernetes authentication, and can generate the required credentials. The following command will produce a full-fledged `kubeconfig` string that can be directly stored in a `KUBERNETES_CONFIGURATION` CI/CD environment secret: |
| 58 | + |
| 59 | +```bash |
| 60 | +az aks get-credentials \ |
| 61 | + --resource-group testKubernetesResourceGroup \ |
| 62 | + --name testKubernetesCluster \ |
| 63 | + --file - |
| 64 | +``` |
| 65 | + |
| 66 | +-> **Note:** Omitting the `--file -` option causes settings to be stored in the local computer's `~/.kube/config` file (which is automatically used by `kubectl` should you ever need to run a manual sanity check on the cluster). |
| 67 | + |
| 68 | +## Deleting the test cluster |
| 69 | + |
| 70 | +Once you've finished testing you can run the following command to delete the entire resource group (including the cluster and all its nodes): |
| 71 | + |
| 72 | +```bash |
| 73 | +az group delete --name testKubernetesResourceGroup |
| 74 | +``` |
| 75 | + |
| 76 | +~> **Warning:** Try to delete the entire resource group as soon as you finish using the cluster to avoid unnecessary expenses. 🔥💵 |
0 commit comments