You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/aks/web-app-routing.md
+61-37Lines changed: 61 additions & 37 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -46,11 +46,11 @@ az extension update --name aks-preview
46
46
47
47
### Create and export a self-signed SSL certificate (if you don't already own one)
48
48
49
-
If you already have an SSL certificate, you can skip this step, otherwise you can use these commands to create a self-signed SSL certificate to use with the Ingress. You will need to replace `<YOUR HOSTNAME>` with the DNS name that you will be using.
49
+
If you already have an SSL certificate, you can skip this step, otherwise you can use these commands to create a self-signed SSL certificate to use with the Ingress. You will need to replace *`<Hostname>`* with the DNS name that you will be using.
If you don't already have an Azure Key Vault, use this command to create one. Azure Key Vault is used to securely store the SSL certificates that will be loaded into the Ingress.
62
62
63
63
```azurecli-interactive
64
-
az keyvault create -g <RESOURCE GROUP NAME> -l <LOCATION> -n <KEYVAULT NAME>
64
+
az keyvault create -g <ResourceGroupName> -l <Location> -n <KeyVaultName>
az keyvault certificate import --vault-name <KeyVaultName> -n <KeyVaultCertificateName> -f aks-ingress-tls.pfx
73
73
```
74
74
75
75
### Create an Azure DNS zone (optional)
@@ -78,7 +78,7 @@ If you want the add-on to automatically managed creating hostnames, you need to
78
78
79
79
```azurecli-interactive
80
80
# Create a DNS zone
81
-
az network dns zone create -g <RESOURCE GROUP NAME> -n <ZONE NAME ex: contoso.com>
81
+
az network dns zone create -g <ResourceGroupName> -n <ZoneName>
82
82
```
83
83
84
84
## Enable Web Application Routing via the Azure CLI
@@ -95,13 +95,13 @@ The following additional add-ons are required:
95
95
> To enable the add-on to reload certificates from Azure Key Vault when they change, you should to enable the [secret autorotation feature](/azure/aks/csi-secrets-store-driver#enable-and-disable-autorotation) of the Secret Store CSI driver with the `--enable-secret-rotation` argument. When the autorotation is enabled, the driver updates the pod mount and the Kubernetes secret by polling for changes periodically, based on the rotation poll interval you can define. The default rotation poll interval is 2 minutes.
96
96
97
97
```azurecli-interactive
98
-
az aks create --resource-group myResourceGroup --name myAKSCluster --enable-addons azure-keyvault-secrets-provider,open-service-mesh,web_application_routing --generate-ssh-keys --enable-secret-rotation
98
+
az aks create -g <ResourceGroupName> -n <ClusterName> -l <Location> --enable-addons azure-keyvault-secrets-provider,open-service-mesh,web_application_routing --generate-ssh-keys --enable-secret-rotation
99
99
```
100
100
101
101
To enable Web Application Routing on an existing cluster, add the `--addons` parameter and specify *web_application_routing* as shown in the following example:
102
102
103
103
```azurecli-interactive
104
-
az aks enable-addons --resource-group myResourceGroup --name myAKSCluster --addons azure-keyvault-secrets-provider,open-service-mesh,web_application_routing --enable-secret-rotation
104
+
az aks enable-addons -g <ResourceGroupName> -n <ClusterName> --addons azure-keyvault-secrets-provider,open-service-mesh,web_application_routing --enable-secret-rotation
105
105
```
106
106
107
107
> [!NOTE]
@@ -117,36 +117,26 @@ The following additional add-on is required:
117
117
> To enable the add-on to reload certificates from Azure Key Vault when they change, you should to enable the [secret autorotation feature](/azure/aks/csi-secrets-store-driver#enable-and-disable-autorotation) of the Secret Store CSI driver with the `--enable-secret-rotation` argument. When the autorotation is enabled, the driver updates the pod mount and the Kubernetes secret by polling for changes periodically, based on the rotation poll interval you can define. The default rotation poll interval is 2 minutes.
118
118
119
119
```azurecli-interactive
120
-
az aks create --resource-group myResourceGroup --name myAKSCluster --enable-addons azure-keyvault-secrets-provider,web_application_routing --generate-ssh-keys --enable-secret-rotation
120
+
az aks create -g <ResourceGroupName> -n <ClusterName> -l <Location> --enable-addons azure-keyvault-secrets-provider,web_application_routing --generate-ssh-keys --enable-secret-rotation
121
121
```
122
122
123
123
To enable Web Application Routing on an existing cluster, add the `--addons` parameter and specify *web_application_routing* as shown in the following example:
124
124
125
125
```azurecli-interactive
126
-
az aks enable-addons --resource-group myResourceGroup --name myAKSCluster --addons azure-keyvault-secrets-provider,web_application_routing --enable-secret-rotation
126
+
az aks enable-addons-g <ResourceGroupName> -n <ClusterName> --addons azure-keyvault-secrets-provider,web_application_routing --enable-secret-rotation
127
127
```
128
128
129
129
---
130
130
131
-
> [!TIP]
132
-
> If you are going to use Azure DNS, update the add-on to pass in the `--dns-zone-resource-id`
131
+
## Retrieve the add-on's managed identity object ID
133
132
134
-
```azurecli-interactive
135
-
# Retrieve the resource ID
136
-
ZONEID=$(az network dns zone show --vault-name <KEYVAULT NAME> --name <ZONE NAME> -o jsonc | jq .id)
137
-
138
-
# Update the add-on
139
-
az aks addon update --resource-group myResourceGroup --name myAKSCluster --addon web_application_routing --dns-zone-resource-id=$ZONEID`
140
-
```
141
-
142
-
## Grant the add-on permissions to retrieve certficates from Azure Key Vault
143
-
The Web Application Routing add-on creates a user created managed identity in the cluster resource group. This managed identity will need to be granted permissions to retrieve SSL certificates from the Azure Key Vault. Provide your `<RESOURCE GROUP NAME>`, `<CLUSTER NAME>`, and `<LOCATION>` in the script below which will retrieve the managed identity's object ID.
133
+
Retrieve user managed identity object ID for the add-on. This will be used in the next steps to grant permissions against the Azure DNS zone and the Azure Key Vault. Provide your *`<ResourceGroupName>`*, *`<ClusterName>`*, and *`<Location>`* in the script below which will retrieve the managed identity's object ID.
144
134
145
135
```azurecli-interactive
146
136
# Provide values for your environment
147
-
RGNAME=<RESOURCE GROUP NAME>
148
-
CLUSTERNAME=<CLUSTER NAME>
149
-
LOCATION=<LOCATION>
137
+
RGNAME=<ResourceGroupName>
138
+
CLUSTERNAME=<ClusterName>
139
+
LOCATION=<Location>
150
140
151
141
# Retrieve user managed identity object ID for the add-on
152
142
SUBSCRIPTION_ID=$(az account show --query id --output tsv)
## Configure the add-on to use Azure DNS to manage creating DNS zones
150
+
151
+
If you are going to use Azure DNS, update the add-on to pass in the `--dns-zone-resource-id`.
152
+
153
+
Retrieve the resource ID for the DNS zone.
154
+
155
+
```azurecli-interactive
156
+
# Retrieve the resource ID
157
+
ZONEID=$(az network dns zone show -g <ResourceGroupName> -n <ZoneName> --query "id" --output tsv)
158
+
```
159
+
160
+
Grant **DNS Zone Contributor** permissions on the DNS zone to the add-on's managed identity.
161
+
162
+
```azureclie-interactive
163
+
az role assignment create --role "DNS Zone Contributor" --assignee $MANAGEDIDENTITY_OBJECTID --scope $ZONEID
164
+
```
165
+
166
+
Update the add-on to enable the integration with Azure DNS. This will create the **external-dns** controller.
167
+
168
+
```azureclie-interactive
169
+
az aks addon update -g <ResourceGroupName> -n <ClusterName> --addon web_application_routing --dns-zone-resource-id=$ZONEID
170
+
```
171
+
172
+
173
+
174
+
## Grant the add-on permissions to retrieve certficates from Azure Key Vault
175
+
The Web Application Routing add-on creates a user created managed identity in the cluster resource group. This managed identity will need to be granted permissions to retrieve SSL certificates from the Azure Key Vault.
176
+
159
177
Grant `GET` permissions for the Web Application Routing add-on to retrieve certificates from Azure Key Vault:
160
178
```azurecli-interactive
161
-
az keyvault set-policy --name $KEYVAULTNAME --object-id $MANAGEDIDENTITY_OBJECTID --secret-permissions get --certificate-permissions get
179
+
az keyvault set-policy --name <KeyVaultName> --object-id $MANAGEDIDENTITY_OBJECTID --secret-permissions get --certificate-permissions get
162
180
```
163
181
164
182
## Connect to your AKS cluster
@@ -174,9 +192,9 @@ az aks install-cli
174
192
To configure `kubectl` to connect to your Kubernetes cluster, use the [az aks get-credentials][az-aks-get-credentials] command. The following example gets credentials for the AKS cluster named *myAKSCluster* in *myResourceGroup*:
175
193
176
194
```azurecli-interactive
177
-
az aks get-credentials --resource-group myResourceGroup --name myAKSCluster
195
+
az aks get-credentials -g <ResourceGroupName> -n <ClusterName>
178
196
```
179
-
## Deploying an application that uses Web Application Routing
197
+
## Deploy an application
180
198
181
199
Web Application Routing uses annotations on Kubernetes Ingress objects to create the appropriate resources, create records on Azure DNS (when configured), and retrieve the SSL certificates from Azure Key Vault.
182
200
@@ -247,17 +265,20 @@ spec:
247
265
The Web Application Routing add-on creates an Ingress class on the cluster called `webapprouting.kubernetes.azure.com `. When you create an ingress object with this class, this will activate the add-on. To obtain the certificate URI to use in the Ingress from Azure Key Vault, run the following command.
248
266
249
267
```azurecli-interactive
250
-
az keyvault certificate show --vault-name <KEYVAULT NAME> --name <KEYVAULT-CERTIFICATE-NAME> -o jsonc | jq .id
268
+
az keyvault certificate show --vault-name <KeyVaultName> -n <KeyVaultCertificateName> ---query "id" --output tsv
251
269
```
252
270
253
-
Create a file named **ingress.yaml** and copy in the following YAML. Update `<MY_HOSTNAME>` with your DNS host name and `<MY_KEYVAULT_CERTIFICATE_URI>` with the ID returned from Azure Key Vault.
271
+
Create a file named **ingress.yaml** and copy in the following YAML.
272
+
273
+
> [!NOTE]
274
+
> Update *`<Hostname>`* with your DNS host name and *`<KeyVaultCertificateUri>`* with the ID returned from Azure Key Vault. `secretName` is the name of the secret that going to be generated to store the certificate. This is the certificate that's going to be presented in the browser.
The Web Application Routing add-on creates an Ingress class on the cluster called `webapprouting.kubernetes.azure.com `. When you create an ingress object with this class, this will activate the add-on. To obtain the certificate URI to use in the Ingress from Azure Key Vault, run the following command.
396
417
397
418
```azurecli-interactive
398
-
az keyvault certificate show --vault-name <KEYVAULT NAME> --name <KEYVAULT-CERTIFICATE-NAME> -o jsonc | jq .id
419
+
az keyvault certificate show --vault-name <KeyVaultName> -n <KeyVaultCertificateName> ---query "id" --output tsv
399
420
```
400
421
401
-
Create a file named **ingress.yaml** and copy in the following YAML. Update `<MY_HOSTNAME>` with your DNS host name and `<MY_KEYVAULT_CERTIFICATE_URI>` with the ID returned from Azure Key Vault.
422
+
Create a file named **ingress.yaml** and copy in the following YAML.
423
+
424
+
> [!NOTE]
425
+
> Update *`<Hostname>`* with your DNS host name and *`<KeyVaultCertificateUri>`* with the ID returned from Azure Key Vault. `secretName` is the name of the secret that going to be generated to store the certificate. This is the certificate that's going to be presented in the browser.
0 commit comments