diff --git a/azure/terraform/modules/kubernetes/main.tf b/azure/terraform/modules/kubernetes/main.tf --- a/azure/terraform/modules/kubernetes/main.tf +++ b/azure/terraform/modules/kubernetes/main.tf @@ -1,12 +1,12 @@ - resource "azurerm_kubernetes_cluster" "aks_cluster" { name = var.cluster_name resource_group_name = data.azurerm_resource_group.aks_rg.name location = data.azurerm_resource_group.aks_rg.location dns_prefix = var.cluster_name + node_resource_group = "${var.cluster_name}-internal" default_node_pool { - name = "default" + name = "default" # node_count = 1 vm_size = var.node_type enable_auto_scaling = true @@ -30,8 +30,9 @@ private_cluster_enabled = true network_profile { - network_plugin = "kubenet" - network_policy = "calico" + network_plugin = "kubenet" + network_policy = "calico" + load_balancer_sku = "Standard" # needed to assign a private ip address } } @@ -48,3 +49,11 @@ subresource_names = ["management"] } } + +resource "azurerm_public_ip" "aks_cluster_public_ip" { + name = "${var.cluster_name}_ip" + resource_group_name = azurerm_kubernetes_cluster.aks_cluster.node_resource_group + location = data.azurerm_resource_group.aks_rg.location + allocation_method = "Static" + sku = "Standard" +} diff --git a/azure/terraform/modules/kubernetes/outputs.tf b/azure/terraform/modules/kubernetes/outputs.tf --- a/azure/terraform/modules/kubernetes/outputs.tf +++ b/azure/terraform/modules/kubernetes/outputs.tf @@ -3,6 +3,7 @@ name: ${azurerm_kubernetes_cluster.aks_cluster.name} internal_ip: ${azurerm_private_endpoint.aks_cluster_endpoint.private_service_connection.0.private_ip_address} +public_ip: ${azurerm_public_ip.aks_cluster_public_ip.ip_address} Execute the following command to add the credentials in your .kube/config: az aks get-credentials --resource-group ${data.azurerm_resource_group.aks_rg.name} --name ${azurerm_kubernetes_cluster.aks_cluster.name}