|
| 1 | +--- |
| 2 | +title: Deploy Istio-based service mesh add-on for Azure Kubernetes Service (preview) |
| 3 | +description: Deploy Istio-based service mesh add-on for Azure Kubernetes Service (preview) |
| 4 | +ms.topic: article |
| 5 | +ms.custom: devx-track-azurecli |
| 6 | +ms.date: 04/09/2023 |
| 7 | +ms.author: shasb |
| 8 | +--- |
| 9 | + |
| 10 | +# Deploy Istio-based service mesh add-on for Azure Kubernetes Service (preview) |
| 11 | + |
| 12 | +This article shows you how to install the Istio-based service mesh add-on for Azure Kubernetes Service (AKS) cluster. |
| 13 | + |
| 14 | +For more information on Istio and the service mesh add-on, see [Istio-based service mesh add-on for Azure Kubernetes Service][istio-about]. |
| 15 | + |
| 16 | +[!INCLUDE [preview features callout](includes/preview/preview-callout.md)] |
| 17 | + |
| 18 | +## Before you begin |
| 19 | + |
| 20 | +### Set environment variables |
| 21 | + |
| 22 | +```bash |
| 23 | +export CLUSTER=<cluster-name> |
| 24 | +export RESOURCE_GROUP=<resource-group-name> |
| 25 | +export LOCATION=<location> |
| 26 | +``` |
| 27 | + |
| 28 | +### Verify Azure CLI and aks-preview extension versions |
| 29 | +The add-on requires: |
| 30 | +* Azure CLI version 2.44.0 or later installed. To install or upgrade, see [Install Azure CLI][install-azure-cli]. |
| 31 | +* `aks-preview` Azure CLI extension of version 0.5.133 or later installed |
| 32 | + |
| 33 | +You can run `az --version` to verify above versions. |
| 34 | + |
| 35 | +To install the aks-preview extension, run the following command: |
| 36 | + |
| 37 | +```azurecli-interactive |
| 38 | +az extension add --name aks-preview |
| 39 | +``` |
| 40 | + |
| 41 | +Run the following command to update to the latest version of the extension released: |
| 42 | + |
| 43 | +```azurecli-interactive |
| 44 | +az extension update --name aks-preview |
| 45 | +``` |
| 46 | + |
| 47 | +### Register the _AzureServiceMeshPreview_ feature flag |
| 48 | + |
| 49 | +Register the `AzureServiceMeshPreview` feature flag by using the [az feature register][az-feature-register] command: |
| 50 | + |
| 51 | +```azurecli-interactive |
| 52 | +az feature register --namespace "Microsoft.ContainerService" --name "AzureServiceMeshPreview" |
| 53 | +``` |
| 54 | + |
| 55 | +It takes a few minutes for the feature to register. Verify the registration status by using the [az feature show][az-feature-show] command: |
| 56 | + |
| 57 | +```azurecli-interactive |
| 58 | +az feature show --namespace "Microsoft.ContainerService" --name "AzureServiceMeshPreview" |
| 59 | +``` |
| 60 | + |
| 61 | +When the status reflects *Registered*, refresh the registration of the *Microsoft.ContainerService* resource provider by using the [az provider register][az-provider-register] command: |
| 62 | + |
| 63 | +```azurecli-interactive |
| 64 | +az provider register --namespace Microsoft.ContainerService |
| 65 | +``` |
| 66 | + |
| 67 | +## Install Istio add-on at the time of cluster creation |
| 68 | + |
| 69 | +To install the Istio add-on when creating the cluster, use the `--enable-azure-service-mesh` or`--enable-asm` parameter. |
| 70 | + |
| 71 | +```azurecli-interactive |
| 72 | +az group create --name ${RESOURCE_GROUP} --location ${LOCATION} |
| 73 | +
|
| 74 | +az aks create \ |
| 75 | +--resource-group ${RESOURCE_GROUP} \ |
| 76 | +--name ${CLUSTER} \ |
| 77 | +--enable-asm |
| 78 | +``` |
| 79 | + |
| 80 | +## Install Istio add-on for existing cluster |
| 81 | + |
| 82 | +The following example enables Istio add-on for an existing AKS cluster: |
| 83 | + |
| 84 | +> [!IMPORTANT] |
| 85 | +> You can't enable the Istio add-on on an existing cluster if an OSM add-on is already on your cluster. Uninstall the OSM add-on before installing the Istio add-on. |
| 86 | +> For more information, see [uninstall the OSM add-on from your AKS cluster][uninstall-osm-addon]. |
| 87 | +> Istio add-on can only be enabled on AKS clusters of version >= 1.23. |
| 88 | +
|
| 89 | +```azurecli-interactive |
| 90 | +az aks mesh enable --resource-group ${RESOURCE_GROUP} --name ${CLUSTER} |
| 91 | +``` |
| 92 | + |
| 93 | +## Verify successful installation |
| 94 | + |
| 95 | +To verify the Istio add-on is installed on your cluster, run the following command: |
| 96 | + |
| 97 | +```azurecli-interactive |
| 98 | +az aks show --resource-group ${RESOURCE_GROUP} --name ${CLUSTER} --query 'serviceMeshProfile.mode' |
| 99 | +``` |
| 100 | + |
| 101 | +Confirm the output shows `Istio`. |
| 102 | + |
| 103 | +Use `az aks get-credentials` to the credentials for your AKS cluster: |
| 104 | + |
| 105 | +```azurecli-interactive |
| 106 | +az aks get-credentials --resource-group ${RESOURCE_GROUP} --name ${CLUSTER} |
| 107 | +``` |
| 108 | + |
| 109 | +Use `kubectl` to verify that `istiod` (Istio control plane) pods are running successfully: |
| 110 | + |
| 111 | +```bash |
| 112 | +kubectl get pods -n aks-istio-system |
| 113 | +``` |
| 114 | + |
| 115 | +Confirm the `istiod` pod has a status of `Running`. For example: |
| 116 | + |
| 117 | +``` |
| 118 | +NAME READY STATUS RESTARTS AGE |
| 119 | +istiod-asm-1-17-74f7f7c46c-xfdtl 2/2 Running 0 2m |
| 120 | +``` |
| 121 | + |
| 122 | +## Enable sidecar injection |
| 123 | + |
| 124 | +To automatically install sidecar to any new pods, annotate your namespaces: |
| 125 | + |
| 126 | +```bash |
| 127 | +kubectl label namespace default istio.io/rev=asm-1-17 |
| 128 | +``` |
| 129 | + |
| 130 | +> [!IMPORTANT] |
| 131 | +> The default `istio-injection=enabled` labeling doesn't work. Explicit versioning (`istio.io/rev=asm-1-17`) is required. |
| 132 | +
|
| 133 | + |
| 134 | +For manual injection of sidecar using `istioctl kube-inject`, you need to specify extra parameters for `istioNamespace` (`-i`) and `revision` (`-r`). Example: |
| 135 | + |
| 136 | +```bash |
| 137 | +kubectl apply -f <(istioctl kube-inject -f sample.yaml -i aks-istio-system -r asm-1-17) -n foo |
| 138 | +``` |
| 139 | + |
| 140 | +## Deploy sample application |
| 141 | + |
| 142 | +Use `kubectl apply` to deploy the sample application on the cluster: |
| 143 | + |
| 144 | +```bash |
| 145 | +kubectl apply -f https://raw.githubusercontent.com/istio/istio/release-1.17/samples/bookinfo/platform/kube/bookinfo.yaml |
| 146 | +``` |
| 147 | + |
| 148 | +Confirm several deployments and services are created on your cluster. For example: |
| 149 | + |
| 150 | +``` |
| 151 | +service/details created |
| 152 | +serviceaccount/bookinfo-details created |
| 153 | +deployment.apps/details-v1 created |
| 154 | +service/ratings created |
| 155 | +serviceaccount/bookinfo-ratings created |
| 156 | +deployment.apps/ratings-v1 created |
| 157 | +service/reviews created |
| 158 | +serviceaccount/bookinfo-reviews created |
| 159 | +deployment.apps/reviews-v1 created |
| 160 | +deployment.apps/reviews-v2 created |
| 161 | +deployment.apps/reviews-v3 created |
| 162 | +service/productpage created |
| 163 | +serviceaccount/bookinfo-productpage created |
| 164 | +deployment.apps/productpage-v1 created |
| 165 | +``` |
| 166 | + |
| 167 | +Use `kubectl get services` to verify that the services were created successfully: |
| 168 | + |
| 169 | +```bash |
| 170 | +kubectl get services |
| 171 | +``` |
| 172 | + |
| 173 | +Confirm the following services were deployed: |
| 174 | + |
| 175 | +``` |
| 176 | +NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE |
| 177 | +details ClusterIP 10.0.180.193 <none> 9080/TCP 87s |
| 178 | +kubernetes ClusterIP 10.0.0.1 <none> 443/TCP 15m |
| 179 | +productpage ClusterIP 10.0.112.238 <none> 9080/TCP 86s |
| 180 | +ratings ClusterIP 10.0.15.201 <none> 9080/TCP 86s |
| 181 | +reviews ClusterIP 10.0.73.95 <none> 9080/TCP 86s |
| 182 | +``` |
| 183 | + |
| 184 | +```bash |
| 185 | +kubectl get pods |
| 186 | +``` |
| 187 | + |
| 188 | +Confirm that all the pods have status of `Running`. |
| 189 | + |
| 190 | +``` |
| 191 | +NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE |
| 192 | +details-v1-558b8b4b76-2llld 2/2 Running 0 2m41s |
| 193 | +productpage-v1-6987489c74-lpkgl 2/2 Running 0 2m40s |
| 194 | +ratings-v1-7dc98c7588-vzftc 2/2 Running 0 2m41s |
| 195 | +reviews-v1-7f99cc4496-gdxfn 2/2 Running 0 2m41s |
| 196 | +reviews-v2-7d79d5bd5d-8zzqd 2/2 Running 0 2m41s |
| 197 | +reviews-v3-7dbcdcbc56-m8dph 2/2 Running 0 2m41s |
| 198 | +``` |
| 199 | + |
| 200 | +> [!NOTE] |
| 201 | +> Each pod has two containers, one of which is the Envoy sidecar injected by Istio and the other is the application container. |
| 202 | +
|
| 203 | +To test this sample application against ingress, check out [next-steps](#next-steps). |
| 204 | + |
| 205 | +## Delete resources |
| 206 | + |
| 207 | +Use `kubectl delete` to delete the sample application: |
| 208 | + |
| 209 | +```bash |
| 210 | +kubectl delete -f https://raw.githubusercontent.com/istio/istio/release-1.17/samples/bookinfo/platform/kube/bookinfo.yaml |
| 211 | +``` |
| 212 | + |
| 213 | +If you don't intend to enable Istio ingress on your cluster and want to disable the Istio add-on, run the following command: |
| 214 | + |
| 215 | +```azurecli-interactive |
| 216 | +az aks mesh disable --resource-group ${RESOURCE_GROUP} --name ${CLUSTER} |
| 217 | +``` |
| 218 | + |
| 219 | +> [!CAUTION] |
| 220 | +> Disabling the service mesh addon will completely remove the Istio control plane from the cluster. |
| 221 | +
|
| 222 | +Istio `CustomResourceDefintion`s (CRDs) aren't be deleted by default. To clean them up, use: |
| 223 | + |
| 224 | +```bash |
| 225 | +kubectl delete crd $(kubectl get crd -A | grep "istio.io" | awk '{print $1}') |
| 226 | +``` |
| 227 | + |
| 228 | +Use `az group delete` to delete your cluster and the associated resources: |
| 229 | + |
| 230 | +```azurecli-interactive |
| 231 | +az group delete --name ${RESOURCE_GROUP} --yes --no-wait |
| 232 | +``` |
| 233 | + |
| 234 | +## Next steps |
| 235 | + |
| 236 | +* [Deploy external or internal ingresses for Istio service mesh add-on][istio-deploy-ingress] |
| 237 | + |
| 238 | +[istio-about]: istio-about.md |
| 239 | + |
| 240 | +[azure-cli-install]: /cli/azure/install-azure-cli |
| 241 | +[az-feature-register]: /cli/azure/feature#az-feature-register |
| 242 | +[az-feature-show]: /cli/azure/feature#az-feature-show |
| 243 | +[az-provider-register]: /cli/azure/provider#az-provider-register |
| 244 | + |
| 245 | +[uninstall-osm-addon]: open-service-mesh-uninstall-add-on.md |
| 246 | +[uninstall-istio-oss]: https://istio.io/latest/docs/setup/install/istioctl/#uninstall-istio |
| 247 | + |
| 248 | +[istio-deploy-ingress]: istio-deploy-ingress.md |
0 commit comments