|
| 1 | +# Private Azure Kubernetes Service with Custom DNS Server |
| 2 | + |
| 3 | +This template deploys a private Azure Kubernetes Service cluster configured with custom DNS server. A new VNet with provided |
| 4 | +custom DNS server would be provisioned and the AKS cluster is deployed into this new VNet. The DNS server's VNet would |
| 5 | +also be linked to AKS provisioned private DNS zone, so that AKS cluster's private FQDN could be resolved successfully on |
| 6 | +custom DNS server. |
| 7 | + |
| 8 | +To use this template, ensure the following pre-requirements have been set: |
| 9 | + |
| 10 | +* Azure CLI and terraform installed locally |
| 11 | +* Pre-configure DNS servers outside of AKS VNet |
| 12 | +* Forward AKS cluster FQDN `azmk8s.io` (or only private cluster FQDN `privatelink.<region>.azmk8s.io`) to Azure DNS `168.63.129.16` |
| 13 | +* Get the DNS servers IP address, which would be set in `custom_dns` |
| 14 | +* Get the DNS server's VNet resource ID, which would be set in `custom_dns_vnet_id` |
| 15 | + |
| 16 | +## Resources |
| 17 | + |
| 18 | +| Terraform Resource Type | Description | |
| 19 | +|-------------------------|-------------| |
| 20 | +| `azurerm_resource_group` | The resource group all resources are deployed into | |
| 21 | +| `azurerm_virtual_network` | The VNet that AKS cluster would be deployed on | |
| 22 | +| `azurerm_subnet` | The subnet that AKS cluster would be deployed on | |
| 23 | +| `azurerm_kubernetes_cluster` | The AKS cluster | |
| 24 | +| `null_resource.dns_zone_link` | Link custom DNS server's VNet to AKS private DNS zone| |
| 25 | + |
| 26 | +## Variables |
| 27 | + |
| 28 | +| Name | Description | |
| 29 | +|------|-------------| |
| 30 | +| `resource_group_name` | Name of the Azure resource group| |
| 31 | +| `cluster_name` | Name of the AKS cluster| |
| 32 | +| `custom_dns` | IP of custom DNS server| |
| 33 | +| `custom_dns_vnet_id` |Resource ID of the Azure VNet that holds custom DNS server| |
| 34 | +| `client_id` | The service principal ID| |
| 35 | +| `client_secret` | The service principal password| |
| 36 | +| `agent_count` | The number of K8S nodes to provision| |
| 37 | +| `kubernetes_version` | The version of K8S to provision| |
| 38 | +| `ssh_public_key` | The SSH public key of K8S nodes | |
| 39 | +| `dns_prefix` | The DNS prefix of AKS cluster | |
| 40 | +| `location` | The location of Azure resources | |
| 41 | + |
| 42 | +## Usage |
| 43 | + |
| 44 | +```sh |
| 45 | +terraform plan \ |
| 46 | + -var 'resource_group_name=aks-quickstart' \ |
| 47 | + -var 'cluster_name=aks' \ |
| 48 | + -var 'custom_dns=<your-custom-dns-IP>' \ |
| 49 | + -var 'custom_dns_vnet_id=<your-custom-dns-vnet-id>' \ |
| 50 | + -var 'client_id=<your-client-id>' \ |
| 51 | + -var 'client_secret=<your-client-secret>' \ |
| 52 | + -out demo.tfplan |
| 53 | + |
| 54 | +terraform apply demo.tfplan |
| 55 | +``` |
0 commit comments