hashicorp / terraform-provider-azurerm

Terraform provider for Azure Resource Manager
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
Mozilla Public License 2.0
4.6k stars 4.64k forks source link

Support exporting private cluster IP address from kubernetes_cluster #18310

Open OmpahDev opened 2 years ago

OmpahDev commented 2 years ago

Is there an existing issue for this?

Community Note

Description

When creating a private kubernetes cluster using kubernetes_cluster, the hostname mentioned in the kubeconfig file is only resolvable from the virtual network, not from the internet. In my workflow, we then need to add an A record to our DNS server so that we can resolve the endpoint from our workstations. But there doesn't appear to be way to export the private IP address of the Kubernetes API server from a kubernetes_cluster resource, only the FQDN, so we can't use Terraform to actually add this DNS record, forcing us to create a terribly inefficient workflow where we use terraform to set up the cluster, then manually find the IP Address, add it to our DNS records, then resume using terraform to set up things inside the cluster.

New or Affected Resource(s)/Data Source(s)

azurerm_kubernetes_cluster

Potential Terraform Configuration

output "aks_hostname" {
  value = azurerm_kubernetes_cluster.main.kube_config.0.host
}

output "aks_hostname_ip" {
  value = azurerm_kubernetes_cluster.main.api_server_private_ip
}

References

No response

ms-henglu commented 2 years ago

Hi @tdevopsottawa ,

Thank you for taking time to report this issue!

Would you please share how to find the private IP address? Thanks!

OmpahDev commented 2 years ago

@ms-henglu When an AKS cluster is created, Microsoft creates a bunch of resources at the same time, in an MC resource group. One of those resources created is a Network Interface - the private IP address is attached to that Network Interface.

sai-ns commented 10 months ago

@tdevopsottawa I know this is an year old issue. But were you able to figure out a way to get the private IP address? We are planning to use local exec to run az cli command to retrieve the IP but was looking for a better approach.