<p>I have created an AKS cluster using the following Terraform code</p>
<pre><code>resource &quot;azurerm_virtual_network&quot; &quot;test&quot; {
  name                = var.virtual_network_name
  location            = azurerm_resource_group.rg.location
  resource_group_name = azurerm_resource_group.rg.name
  address_space       = [var.virtual_network_address_prefix]

  subnet {
    name           = var.aks_subnet_name
    address_prefix = var.aks_subnet_address_prefix
  }

  subnet {
    name           = &quot;appgwsubnet&quot;
    address_prefix = var.app_gateway_subnet_address_prefix
  }

  tags = var.tags
}

data &quot;azurerm_subnet&quot; &quot;kubesubnet&quot; {
  name                 = var.aks_subnet_name
  virtual_network_name = azurerm_virtual_network.test.name
  resource_group_name  = azurerm_resource_group.rg.name
  depends_on           = [azurerm_virtual_network.test]
}

resource &quot;azurerm_kubernetes_cluster&quot; &quot;k8s&quot; {
  name       = var.aks_name
  location   = azurerm_resource_group.rg.location
  dns_prefix = var.aks_dns_prefix

  resource_group_name = azurerm_resource_group.rg.name

  http_application_routing_enabled = false

  linux_profile {
    admin_username = var.vm_user_name

    ssh_key {
      key_data = file(var.public_ssh_key_path)
    }
  }

  default_node_pool {
    name            = &quot;agentpool&quot;
    node_count      = var.aks_agent_count
    vm_size         = var.aks_agent_vm_size
    os_disk_size_gb = var.aks_agent_os_disk_size
    vnet_subnet_id  = data.azurerm_subnet.kubesubnet.id
  }

  service_principal {
    client_id     = local.client_id
    client_secret = local.client_secret
  }

  network_profile {
    network_plugin     = &quot;azure&quot;
    dns_service_ip     = var.aks_dns_service_ip
    docker_bridge_cidr = var.aks_docker_bridge_cidr
    service_cidr       = var.aks_service_cidr
  }

  # Enabled the cluster configuration to the Azure kubernets with RBAC
  azure_active_directory_role_based_access_control { 
    managed                     = var.azure_active_directory_role_based_access_control_managed
    admin_group_object_ids      = var.active_directory_role_based_access_control_admin_group_object_ids
    azure_rbac_enabled          = var.azure_rbac_enabled
  }

  oms_agent {
    log_analytics_workspace_id  = module.log_analytics_workspace[0].id
  }

  timeouts {
    create = &quot;20m&quot;
    delete = &quot;20m&quot;
  }  

  depends_on = [data.azurerm_subnet.kubesubnet,module.log_analytics_workspace]
  tags       = var.tags
}

resource &quot;azurerm_role_assignment&quot; &quot;ra1&quot; {
  scope                = data.azurerm_subnet.kubesubnet.id
  role_definition_name = &quot;Network Contributor&quot;
  principal_id         = local.client_objectid
  depends_on = [data.azurerm_subnet.kubesubnet]
}
</code></pre>
<p>and followed the below steps to install the ISTIO as per the <a href="https://istio.io/latest/docs/setup/install/helm/" rel="nofollow noreferrer">ISTIO documentation</a></p>
<pre><code>#Prerequisites
helm repo add istio https://istio-release.storage.googleapis.com/charts
helm repo update

#create namespace
kubectl create namespace istio-system

# helm install istio-base and istiod
helm install istio-base istio/base -n istio-system
helm install istiod istio/istiod -n istio-system --wait

# Check the installation status
helm status istiod -n istio-system

#create namespace and enable istio-injection for envoy proxy containers
kubectl create namespace istio-ingress
kubectl label namespace istio-ingress istio-injection=enabled

## helm install istio-ingress for traffic management
helm install istio-ingress istio/gateway -n istio-ingress --wait

## Mark the default namespace as istio-injection=enabled
kubectl label namespace default istio-injection=enabled

## Install the App and Gateway
kubectl apply -f https://raw.githubusercontent.com/istio/istio/release-1.16/samples/bookinfo/platform/kube/bookinfo.yaml
kubectl apply -f https://raw.githubusercontent.com/istio/istio/release-1.16/samples/bookinfo/networking/bookinfo-gateway.yaml

# Check the Services, Pods and Gateway
kubectl get services
kubectl get pods
kubectl get gateway

# Ensure the app is running
kubectl exec &quot;$(kubectl get pod -l app=ratings -o jsonpath='{.items[0].metadata.name}')&quot; -c ratings -- curl -sS productpage:9080/productpage | grep -o &quot;&lt;title&gt;.*&lt;/title&gt;&quot;
</code></pre>
<p>and it is responding as shown below</p>
<p><a href="https://i.stack.imgur.com/5EHbb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5EHbb.png" alt="enter image description here" /></a></p>
<p><a href="https://i.stack.imgur.com/MfKvS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MfKvS.png" alt="enter image description here" /></a></p>
<pre><code># Check the 
$INGRESS_NAME=&quot;istio-ingress&quot;
$INGRESS_NS=&quot;istio-ingress&quot;
kubectl get svc &quot;$INGRESS_NAME&quot; -n &quot;$INGRESS_NS&quot;
</code></pre>
<p>it returns the external IP as shown below</p>
<p><a href="https://i.stack.imgur.com/AMU9t.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AMU9t.png" alt="enter image description here" /></a></p>
<p>However, I am not able to access the application</p>
<p><a href="https://i.stack.imgur.com/97RHe.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/97RHe.png" alt="enter image description here" /></a></p>
<p>Also I am getting an error while trying to run the following commands to find the ports</p>
<pre><code>kubectl -n &quot;$INGRESS_NS&quot; get service &quot;$INGRESS_NAME&quot; -o jsonpath='{.spec.ports[?(@.name==&quot;http2&quot;)].port}'
kubectl -n &quot;$INGRESS_NS&quot; get service &quot;$INGRESS_NAME&quot; -o jsonpath='{.spec.ports[?(@.name==&quot;https&quot;)].port}'
kubectl -n &quot;$INGRESS_NS&quot; get service &quot;$INGRESS_NAME&quot; -o jsonpath='{.spec.ports[?(@.name==&quot;tcp&quot;)].port}'
</code></pre>

<p>This is because the ingress gateway selector when installed with Helm is <code>istio: ingress</code>, instead of <code>istio: ingressgateway</code> when installed with istioctl.</p>
<p>If you modify the Gateway to reflect this, then it should work:</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: networking.istio.io/v1beta1
kind: Gateway
metadata:
  name: bookinfo-gateway
  namespace: default
spec:
  selector:
    istio: ingress
...
</code></pre>
<p>One way to show this (without knowing this issue previously) is with <code>istioctl analyze</code>:</p>
<pre><code>$ istioctl analyze
Error [IST0101] (Gateway default/bookinfo-gateway) Referenced selector not found: &quot;istio=ingressgateway&quot;
Error: Analyzers found issues when analyzing namespace: default.
See https://istio.io/v1.16/docs/reference/config/analysis for more information about causes and resolutions.
</code></pre>
