FIX: The specified service CIDR is conflicted with an existing subnet

If you are getting error like below, It could be due to the fact that aks service ip range might be conflicting with your vnet ip range.

│ Error: creating Kubernetes Cluster (Subscription: "<REDACTED>"
│ Resource Group Name: "test2-rg"
│ Kubernetes Cluster Name: "test2-aks"): managedclusters.ManagedClustersClient#CreateOrUpdate: Failure sending request: StatusCode=0 -- Original Error: Code="ServiceCidrOverlapExistingSubnetsCidr" Message="The specified service CIDR 10.0.16.0/20 is conflicted with an existing subnet CIDR 10.0.16.0/20" Target="networkProfile.serviceCIDR"

The default ip range for the aks service is 10.0.0.0/16 and if your vnet is also having the same range then it could be the cause of the problem.

You can either change the ip range of your vnet or change the ip range of the aks service.

In my case I changed the default aks service ip in the terraform script like so

  network_profile {
    network_plugin    = "azure"
    load_balancer_sku = "standard"
    service_cidr      = "10.1.0.0/16"
    dns_service_ip    = "10.1.0.10"
  }