Skip to content

Commit cfdbb1b

Browse files
authored
Merge pull request #2776 from jackfrancis/azuremanagedcluster-docs-example
docs: fix AzureManagedCluster example
2 parents 132aa7e + 3fb9c41 commit cfdbb1b

File tree

2 files changed

+48
-28
lines changed

2 files changed

+48
-28
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,7 @@ _releasenotes
8181

8282
# calico manifests archive
8383
release-*/manifests/calico-*.yaml
84+
85+
# mentioned in the capz book
86+
/sp.json
87+
/cluster.yaml

docs/book/src/topics/managedcluster.md

Lines changed: 44 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ The combination of AzureManagedControlPlane/AzureManagedCluster
1313
corresponds to provisioning an AKS cluster. AzureManagedMachinePool
1414
corresponds one-to-one with AKS node pools. This also means that
1515
creating an AzureManagedControlPlane requires at least one AzureManagedMachinePool
16-
with `spec.mode` `System`, since AKS expects at least one system pool at creation
17-
time. For more documentation on system node pool refer [AKS Docs](https://docs.microsoft.com/en-us/azure/aks/use-system-pools)
16+
with `spec.mode` `System`, since AKS expects at least one system pool at creation
17+
time. For more documentation on system node pool refer [AKS Docs](https://docs.microsoft.com/en-us/azure/aks/use-system-pools)
1818

1919
## Deploy with clusterctl
2020

@@ -26,25 +26,29 @@ executing clusterctl.
2626
# Kubernetes values
2727
export CLUSTER_NAME="my-cluster"
2828
export WORKER_MACHINE_COUNT=2
29-
export KUBERNETES_VERSION="v1.19.6"
29+
export KUBERNETES_VERSION="v1.24.6"
3030

3131
# Azure values
3232
export AZURE_LOCATION="southcentralus"
3333
export AZURE_RESOURCE_GROUP="${CLUSTER_NAME}"
3434
# set AZURE_SUBSCRIPTION_ID to the GUID of your subscription
3535
# this example uses an sdk authentication file and parses the subscriptionId with jq
3636
# this file may be created using
37-
#
38-
# `az ad sp create-for-rbac --role Contributor --scopes="/subscriptions/${AZURE_SUBSCRIPTION_ID}" --sdk-auth > sp.json`
39-
#
40-
# when logged in with a service principal, it's also available using
41-
#
42-
# `az account show --sdk-auth`
43-
#
44-
# Otherwise, you can set this value manually.
45-
#
46-
export AZURE_SUBSCRIPTION_ID="$(cat ~/sp.json | jq -r .subscriptionId | tr -d '\n')"
37+
```
38+
39+
Create a new service principal and save to a local file:
40+
41+
```bash
42+
az ad sp create-for-rbac --role Contributor --scopes="/subscriptions/${AZURE_SUBSCRIPTION_ID}" --sdk-auth > sp.json
43+
```
44+
45+
export AZURE_SUBSCRIPTION_ID="$(cat sp.json | jq -r .subscriptionId | tr -d '\n')"
46+
export AZURE_CLIENT_SECRET="$(cat sp.json | jq -r .clientSecret | tr -d '\n')"
47+
export AZURE_CLIENT_ID="$(cat sp.json | jq -r .clientId | tr -d '\n')"
4748
export AZURE_NODE_MACHINE_TYPE="Standard_D2s_v3"
49+
export AZURE_CLUSTER_IDENTITY_SECRET_NAME="cluster-identity-secret"
50+
export AZURE_CLUSTER_IDENTITY_SECRET_NAMESPACE="default"
51+
export CLUSTER_IDENTITY_NAME="cluster-identity"
4852
```
4953
5054
Managed clusters also require the following feature flags set as environment variables:
@@ -54,7 +58,19 @@ export EXP_MACHINE_POOL=true
5458
export EXP_AKS=true
5559
```
5660

57-
Execute clusterctl to template the resources, then apply to a management cluster:
61+
Create a local kind cluster to run the management cluster components:
62+
63+
```bash
64+
kind create cluster
65+
```
66+
67+
Create an identity secret on the management cluster:
68+
69+
```bash
70+
kubectl create secret generic "${AZURE_CLUSTER_IDENTITY_SECRET_NAME}" --from-literal=clientSecret="${AZURE_CLIENT_SECRET}"
71+
```
72+
73+
Execute clusterctl to template the resources, then apply to your kind management cluster:
5874

5975
```bash
6076
clusterctl init --infrastructure azure
@@ -196,7 +212,7 @@ spec:
196212
resourceGroup: test-rg
197213
subnet:
198214
cidrBlock: 10.0.2.0/24
199-
name: test-subnet
215+
name: test-subnet
200216
```
201217
### Multitenancy
202218
@@ -246,7 +262,7 @@ spec:
246262
### AKS Managed Azure Active Directory Integration
247263

248264
Azure Kubernetes Service can be configured to use Azure Active Directory for user authentication.
249-
AAD for managed clusters can be configured by enabling the `managed` spec in `AzureManagedControlPlane` to `true`
265+
AAD for managed clusters can be configured by enabling the `managed` spec in `AzureManagedControlPlane` to `true`
250266
and by providing Azure AD GroupObjectId in `AdminGroupObjectIDs` array. The group is needed as admin group for
251267
the cluster to grant cluster admin permissions. You can use an existing Azure AD group, or create a new one. For more documentation about AAD refer [AKS AAD Docs](https://docs.microsoft.com/en-us/azure/aks/managed-aad)
252268

@@ -301,7 +317,7 @@ spec:
301317
osDiskSizeGB: 512
302318
sku: Standard_D2s_v3
303319
nodeLabels:
304-
dedicated: kafka
320+
dedicated: kafka
305321
```
306322
307323
### AKS Node Pool MaxPods configuration
@@ -381,12 +397,12 @@ spec:
381397
382398
383399
### Enable AKS features with custom headers (--aks-custom-headers)
384-
To enable some AKS cluster / node pool features you need to pass special headers to the cluster / node pool create request.
400+
To enable some AKS cluster / node pool features you need to pass special headers to the cluster / node pool create request.
385401
For example, to [add a node pool for GPU nodes](https://docs.microsoft.com/en-us/azure/aks/gpu-cluster#add-a-node-pool-for-gpu-nodes),
386-
you need to pass a custom header `UseGPUDedicatedVHD=true` (with `--aks-custom-headers UseGPUDedicatedVHD=true` argument).
387-
To do this with CAPZ, you need to add special annotations to AzureManagedCluster (for cluster
388-
features) or AzureManagedMachinePool (for node pool features). These annotations should have a prefix `infrastructure.cluster.x-k8s.io/custom-header-` followed
389-
by the name of the AKS feature. For example, to create a node pool with GPU support, you would add the following
402+
you need to pass a custom header `UseGPUDedicatedVHD=true` (with `--aks-custom-headers UseGPUDedicatedVHD=true` argument).
403+
To do this with CAPZ, you need to add special annotations to AzureManagedCluster (for cluster
404+
features) or AzureManagedMachinePool (for node pool features). These annotations should have a prefix `infrastructure.cluster.x-k8s.io/custom-header-` followed
405+
by the name of the AKS feature. For example, to create a node pool with GPU support, you would add the following
390406
annotation to AzureManagedMachinePool:
391407
```
392408
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
@@ -456,8 +472,8 @@ spec:
456472
457473
## Immutable fields for Managed Clusters (AKS)
458474
459-
Some fields from the family of Managed Clusters CRD are immutable. Which means
460-
those can only be set during the creation time.
475+
Some fields from the family of Managed Clusters CRD are immutable. Which means
476+
those can only be set during the creation time.
461477
462478
Following is the list of immutable fields for managed clusters:
463479
@@ -512,7 +528,7 @@ If a user tries to delete the MachinePool which refers to the last system node p
512528
Here is an Example:
513529
514530
```yaml
515-
# MachinePool deleted
531+
# MachinePool deleted
516532
apiVersion: cluster.x-k8s.io/v1beta1
517533
kind: MachinePool
518534
metadata:
@@ -558,18 +574,18 @@ metadata:
558574
labels:
559575
cluster.x-k8s.io/cluster-name: capz-managed-aks
560576
name: agentpool2 # change the name of the machinepool
561-
namespace: default
577+
namespace: default
562578
ownerReferences:
563579
- apiVersion: cluster.x-k8s.io/v1beta1
564580
kind: Cluster
565581
name: capz-managed-aks
566-
uid: 152ecf45-0a02-4635-987c-1ebb89055fa2
582+
uid: 152ecf45-0a02-4635-987c-1ebb89055fa2
567583
# uid: ae4a235a-f0fa-4252-928a-0e3b4c61dbea # remove the uid set for machinepool
568584
spec:
569585
clusterName: capz-managed-aks
570586
minReadySeconds: 0
571587
providerIDList:
572-
- azure:///subscriptions/9107f2fb-e486-a434-a948-52e2929b6f18/resourceGroups/MC_rg_capz-managed-aks_eastus/providers/Microsoft.Compute/virtualMachineScaleSets/aks-agentpool0-10226072-vmss/virtualMachines/0
588+
- azure:///subscriptions/9107f2fb-e486-a434-a948-52e2929b6f18/resourceGroups/MC_rg_capz-managed-aks_eastus/providers/Microsoft.Compute/virtualMachineScaleSets/aks-agentpool0-10226072-vmss/virtualMachines/0
573589
replicas: 1
574590
template:
575591
metadata: {}

0 commit comments

Comments
 (0)