@@ -70,43 +70,52 @@ Create a KIND cluster:
70
70
kind create cluster --name capi-helm
71
71
```
72
72
73
+ Identity: Two ways to authenticate to Azure, using a Service Principal or Managed Identity.
74
+
75
+ use a Service Principal:
76
+
73
77
Create a secret to include the password of the Service Principal identity created in Azure
74
78
This secret will be referenced by the AzureClusterIdentity used by the AzureCluster
75
79
76
80
``` bash
77
81
kubectl create secret generic " ${AZURE_CLUSTER_IDENTITY_SECRET_NAME} " --from-literal=clientSecret=" ${AZURE_CLIENT_SECRET} "
78
82
```
79
83
80
- Initialize Cluster API and install Azure CAPZ provider version 0.5.3(uses alphav4 capi)
84
+ Use Managed Identity(recommended):
85
+
86
+ - Follow the steps on this link to create a managed identity and assign it to the AKS cluster resource group < https://capz.sigs.k8s.io/topics/identities#user-assigned-managed-identity >
87
+
88
+ Initialize Cluster API and install Azure CAPZ provider version v1.13.1(uses v1beta1 capi)
81
89
82
90
``` bash
83
- clusterctl init --infrastructure azure:v0.5.3
91
+ clusterctl init --infrastructure azure
84
92
```
85
93
86
94
Deploy a cluster with Helm (please customize parameters as required)
87
95
88
- Requirement: SSH public key ~ /.ssh/id_rsa.pub, to create a key use command "ssh-keygen -t rsa"
96
+ ** Using Service Principal: **
89
97
90
98
``` bash
91
99
helm install capz1 charts/azure-managed-cluster/ \
92
100
--namespace default \
93
101
--set subscriptionID=" ${AZURE_SUBSCRIPTION_ID} " \
94
102
--set identity.clientId=" ${AZURE_CLIENT_ID} " \
103
+ --set identity.clientSecret=" ${AZURE_CLIENT_SECRET} " \
104
+ --set identity.type=ServicePrincipal \
95
105
--set identity.tenantId=" ${AZURE_TENANT_ID} " \
96
106
--set cluster.resourceGroupName=aksclusters \
97
107
--set cluster.nodeResourceGroupName=capz1 \
98
108
--set cluster.name=aks1 \
99
- --set controlplane.sshPublicKey=" $( cat ~ /.ssh/id_rsa.pub) " \
100
- --set agentpools[0].name=capz1np0 \
101
- --set agentpools[0].mode=System \
102
- --set agentpools[0].nodecount=1 \
103
- --set agentpools[0].sku=Standard_B2s \
104
- --set agentpools[0].osDiskSizeGB=100 \
105
- --set agentpools[1].name=capz1np1 \
106
- --set agentpools[1].mode=User \
107
- --set agentpools[1].nodecount=1 \
108
- --set agentpools[1].sku=Standard_B2s \
109
- --set agentpools[1].osDiskSizeGB=100
109
+ --set agentpools.0.name=capz1np0 \
110
+ --set agentpools.0.nodecount=1 \
111
+ --set agentpools.0.sku=Standard_B4ms \
112
+ --set agentpools.0.osDiskSizeGB=100 \
113
+ --set agentpools.0.mode=System \
114
+ --set agentpools.1.name=capz1np1 \
115
+ --set agentpools.1.nodecount=1 \
116
+ --set agentpools.1.sku=Standard_B4ms \
117
+ --set agentpools.1.osDiskSizeGB=10 \
118
+ --set agentpools.1.mode=User
110
119
```
111
120
112
121
or more simply (after you edit the values file with your own values):
@@ -116,10 +125,29 @@ helm install capz1 charts/azure-managed-cluster/ --values aks1.yaml \
116
125
--namespace default \
117
126
--set controlplane.sshPublicKey=" $( cat ~ /.ssh/id_rsa.pub) " \
118
127
--set subscriptionID=" ${AZURE_SUBSCRIPTION_ID} " \
119
- --set identity.clientId=" ${AZURE_CLIENT_ID} " \
120
- --set identity.tenantId=" ${AZURE_TENANT_ID} "
128
+ --set identity.clientID=" ${AZURE_CLIENT_ID} " \
129
+ --set identity.tenantID=" ${AZURE_TENANT_ID} " \
130
+ --set identity.clientSecret=" ${AZURE_CLIENT_SECRET} " \
131
+ --set identity.type=ServicePrincipal
121
132
```
122
133
134
+ ** Using Managed Identity**
135
+
136
+ NB: Ensure the AZURE_USER_ASSIGNED_IDENTITY_RESOURCE_ID is set by getting the resource id of the managed identity created in Azure
137
+
138
+
139
+ ``` bash
140
+
141
+ helm install capz1 charts/azure-managed-cluster/ \
142
+ --namespace default \
143
+ --set subscriptionID=" ${AZURE_SUBSCRIPTION_ID} " \
144
+ --set identity.clientID=" ${AZURE_CLIENT_ID} " \
145
+ --set identity.tenantID=" ${AZURE_TENANT_ID} " \
146
+ --set identity.type=UserAssignedMSI \
147
+ --set identity.resourceID=" ${AZURE_USER_ASSIGNED_IDENTITY_RESOURCE_ID} "
148
+
149
+
150
+
123
151
Check the status with:
124
152
```
125
153
kubectl get cluster-api
@@ -129,7 +157,7 @@ kubectl logs -n capz-system -l control-plane=capz-controller-manager -c manager
129
157
Get the credentials
130
158
131
159
```
132
- kubectl get secret {cluster-name} -kubeconfig -o yaml -o jsonpath={.data.value} | base64 --decode > aks1.kubeconfig
160
+ kubectl get secret capi-helm -kubeconfig -o yaml -o jsonpath={.data.value} | base64 --decode > aks1.kubeconfig
133
161
```
134
162
135
163
Test the cluster!
@@ -148,22 +176,22 @@ kubectl create namespace default2
148
176
helm install capz2 charts/azure-managed-cluster/ \
149
177
--namespace default2 \
150
178
--set subscriptionID=" ${AZURE_SUBSCRIPTION_ID} " \
151
- --set identity.clientId =" ${AZURE_CLIENT_ID} " \
152
- --set identity.tenantId =" ${AZURE_TENANT_ID} " \
179
+ --set identity.clientID =" ${AZURE_CLIENT_ID} " \
180
+ --set identity.tenantID =" ${AZURE_TENANT_ID} " \] =
153
181
--set cluster.resourceGroupName=aksclusters \
154
182
--set cluster.nodeResourceGroupName=capz2 \
155
183
--set cluster.name=aks2 \
156
184
--set controlplane.sshPublicKey=" $( cat ~ /.ssh/id_rsa.pub) " \
157
- --set agentpools[0] .name=capz2np0 \
158
- --set agentpools[0].mode=System \
159
- --set agentpools[0].nodecount=1 \
160
- --set agentpools[0].sku=Standard_B2s \
161
- --set agentpools[0].osDiskSizeGB=100 \
162
- --set agentpools[1] .name=capz2np1 \
163
- --set agentpools[1].mode=User \
164
- --set agentpools[1].nodecount=1 \
165
- --set agentpools[1].sku=Standard_B2s \
166
- --set agentpools[1].osDiskSizeGB=100
185
+ --set agentpools.0 .name=capz2np0 \
186
+ --set agentpools.0.nodecount=1 \
187
+ --set agentpools.0.sku=Standard_B2s \
188
+ --set agentpools.0.osDiskSizeGB=100 \
189
+ --set agentpools.0.mode=System \
190
+ --set agentpools.1 .name=capz2np1 \
191
+ --set agentpools.1.nodecount=1 \
192
+ --set agentpools.1.sku=Standard_B2s \
193
+ --set agentpools.1.osDiskSizeGB=10 \
194
+ --set agentpools.1.mode=User
167
195
```
168
196
169
197
or more simply (after you edit the values file with your own values):
@@ -173,8 +201,8 @@ helm install capz2 charts/azure-managed-cluster/ --values aks2.yaml \
173
201
--namespace default2 \
174
202
--set controlplane.sshPublicKey=" $( cat ~ /.ssh/id_rsa.pub) " \
175
203
--set subscriptionID=" ${AZURE_SUBSCRIPTION_ID} " \
176
- --set identity.clientId =" ${AZURE_CLIENT_ID} " \
177
- --set identity.tenantId= " ${AZURE_TENANT_ID} "
204
+ --set identity.clientID =" ${AZURE_CLIENT_ID} " \
205
+ --set identity.tenantID " ${AZURE_TENANT_ID} "
178
206
```
179
207
180
208
Clean up:
@@ -184,5 +212,6 @@ helm delete capz1
184
212
helm delete capz2 -n default2
185
213
kubectl delete namespace default2
186
214
215
+ kind delete clusters capi
187
216
kind delete clusters capi-helm
188
217
```
0 commit comments