|
| 1 | +# Kamino on AKS |
| 2 | + |
| 3 | +You can test-drive kamino on your AKS cluster to evaluate the potential value of an optimized OS disk image, with the following, important caveat: |
| 4 | + |
| 5 | +The AKS managed service will eventually overwrite changes that kamino makes to a node pool's underlying VMSS resource: |
| 6 | + |
| 7 | +- kamino-delivered changes to `virtualMachineProfile.storageProfile.imageReference.id` and `virtualMachineProfile.storageProfile.imageReference.resourceGroup` will be reverted the standard AKS OS image maintained by the AKS managed service |
| 8 | +- kamino updates to the `virtualMachineProfile.extensionProfile.extensions` array will be reverted |
| 9 | + |
| 10 | +## How to run kamino on your (non-production!) AKS cluster |
| 11 | + |
| 12 | +1. Get the resource group name that your cluster's VMSS are running in. E.g.: |
| 13 | + |
| 14 | +```sh |
| 15 | +$ az aks show -n aks-kamino -g aks-kamino | jq -r .nodeResourceGroup |
| 16 | +MC_aks-kamino_aks-kamino_westus2 |
| 17 | +``` |
| 18 | + |
| 19 | +2. Get the managed identity resource for your node VMs. E.g.: |
| 20 | + |
| 21 | +```sh |
| 22 | +$ az identity list -g MC_aks-kamino_aks-kamino_westus2 |
| 23 | +[ |
| 24 | + { |
| 25 | + "clientId": "<clientId value>", |
| 26 | + "clientSecretUrl": "<clientSecretUrl value>", |
| 27 | + "id": "<id value>", |
| 28 | + "location": "westus2", |
| 29 | + "name": "aks-kamino-agentpool", |
| 30 | + "principalId": "<principalId value>", |
| 31 | + "resourceGroup": "MC_aks-kamino_aks-kamino_westus2", |
| 32 | + "tags": {}, |
| 33 | + "tenantId": "<tenantId value>", |
| 34 | + "type": "Microsoft.ManagedIdentity/userAssignedIdentities" |
| 35 | + } |
| 36 | +] |
| 37 | +``` |
| 38 | + |
| 39 | +Now you can give your cluster node pool managed identity resource contributor access to the resource group using the actual value of `principalId` from above (substitute `<principalId value>` below with the actual value): |
| 40 | + |
| 41 | +```sh |
| 42 | +$ az role assignment create --assignee <principalId value> --role 'Contributor' --scope /subscriptions/<subscription ID that cluster is in>/resourcegroups/MC_aks-kamino_aks-kamino_westus2 |
| 43 | +{ |
| 44 | + "canDelegate": null, |
| 45 | + "condition": null, |
| 46 | + "conditionVersion": null, |
| 47 | + "description": null, |
| 48 | + "id": "<id value>", |
| 49 | + "name": "<name value>", |
| 50 | + "principalId": "<principalId value>", |
| 51 | + "principalName": "<principalName value>", |
| 52 | + "principalType": "ServicePrincipal", |
| 53 | + "resourceGroup": "MC_aks-kamino_aks-kamino_westus2", |
| 54 | + "roleDefinitionId": "<roleDefinitionId value>", |
| 55 | + "roleDefinitionName": "Contributor", |
| 56 | + "scope": "/subscriptions/<subscription ID that cluster is in>/resourceGroups/MC_aks-kamino_aks-kamino_westus2", |
| 57 | + "type": "Microsoft.Authorization/roleAssignments" |
| 58 | +} |
| 59 | +``` |
| 60 | + |
| 61 | +This additional access granted to your node pool managed identity allows the kamino runtime access to create the necessary infra in your cluster resource group. |
| 62 | + |
| 63 | +Now you can target a particular node running on your cluster, make an OS image snapshot from its OS image, and then use that OS image as a Shared Image Gallery image to build new VMSS VMs from. This will replicate any pre-pulled container images onto any newly scaled out nodes, as well as remove the need to run any startup scripts. This can demonstrably improve reliability and responsiveness of new node scale out operations. |
| 64 | + |
| 65 | +```sh |
| 66 | +$ k get nodes |
| 67 | +NAME STATUS ROLES AGE VERSION |
| 68 | +aks-nodepool1-68550425-vmss000000 Ready agent 5h9m v1.21.7 |
| 69 | +aks-nodepool2-35877414-vmss000000 Ready agent 5h v1.21.7 |
| 70 | +aks-nodepool2-35877414-vmss000002 Ready agent 4h42m v1.21.7 |
| 71 | +``` |
| 72 | + |
| 73 | +From the above set of nodes let's choose `aks-nodepool2-35877414-vmss000000` from nodepool2 to build a new image from, and to use as a base when building any new nodes in nodepool2: |
| 74 | + |
| 75 | +```sh |
| 76 | +$ helm install --repo https://jackfrancis.github.io/kamino/ \ |
| 77 | + update-nodepool2-os-image \ |
| 78 | + vmss-prototype --namespace default \ |
| 79 | + --set kamino.targetNode=aks-nodepool2-35877414-vmss000000 |
| 80 | +``` |
| 81 | + |
| 82 | +The above command will schedule the kamino runtime as a pod on any schedulable node other than the target node, and do the needful work. |
| 83 | + |
| 84 | +Again, at present this solution is not designed for production AKS clusters, as the managed service will overwrite the changes. But have fun testing! |
| 85 | + |
| 86 | +A more detailed walkthrough of how kamino works is [here](../helm/vmss-prototype/walkthrough.md). |
0 commit comments