引用Azure ACS群集主VM公共IP?

时间:2018-05-25 13:48:30

标签: azure terraform azure-acs terraform-provider-aws

我使用this repo使用acs-engine在Azure上创建kubernetes集群。

我想知道是否有人可以帮我确定如何引用主VM的公共IP地址。

这将用于ssh到主VM(ssh user@public-ip),这很重要,因为我想运行local-exec配置程序来使用Ansible配置我的集群。

我不相信它是下面的first_master_ip main.tf(这是repo&#39s变量的值。)但是我也没有&# 39;也不知道如何引用这个IP。

我尝试过的另一件事是使用azure命令行获取主VM公共IP地址,但是我也没有取得任何成功,因为我不知道如何获得cluster-name,将与az acs kubernetes browse -g <resource-group-name> -n <cluster-name>

一起传递

任何帮助都会非常感激,因为我真的遇到了障碍。

provider "azurerm" {
  subscription_id = "${var.azure_subscription_id}"
  client_id       = "${var.azure_client_id}"
  client_secret   = "${var.azure_client_secret}"
  tenant_id       = "${var.azure_tenant_id}"
}

# Azure Resource Group
resource "azurerm_resource_group" "default" {
  name     = "${var.resource_group_name}"
  location = "${var.azure_location}"
}

resource "azurerm_public_ip" "test" {
  name                         = "acceptanceTestPublicIp1"
  location                     = "${var.azure_location}"
  resource_group_name          = "${azurerm_resource_group.default.name}"
  public_ip_address_allocation = "static"
}

data "template_file" "acs_engine_config" {
  template = "${file(var.acs_engine_config_file)}"

  vars {
    master_vm_count = "${var.master_vm_count}"
    dns_prefix      = "${var.dns_prefix}"
    vm_size         = "${var.vm_size}"

    first_master_ip                 = "${var.first_master_ip}"
    worker_vm_count                 = "${var.worker_vm_count}"
    admin_user                      = "${var.admin_user}"
    ssh_key                         = "${var.ssh_key}"
    service_principle_client_id     = "${var.azure_client_id}"
    service_principle_client_secret = "${var.azure_client_secret}"
  }

}

# Locally output the rendered ACS Engine Config (after substitution has been performed)
resource "null_resource" "render_acs_engine_config" {
  provisioner "local-exec" {
    command = "echo '${data.template_file.acs_engine_config.rendered}' > ${var.acs_engine_config_file_rendered}"
  }

  depends_on = ["data.template_file.acs_engine_config"]
}

# Locally run the ACS Engine to produce the Azure Resource Template for the K8s cluster
resource "null_resource" "run_acs_engine" {
  provisioner "local-exec" {
    command = "acs-engine generate ${var.acs_engine_config_file_rendered}"
  }

  depends_on = ["null_resource.render_acs_engine_config"]
}

1 个答案:

答案 0 :(得分:0)

我没有使用terraform的经验,但是acs-engine设置了一个公共ip,通过你的主人(或跨多个主人的余额)。您可以使用<dns_prefix>.<region>.cloudapp.azure.com找到该lb的IP。

但是如果你需要ip来提供额外的东西,那么当你拥有多个主人时这是不够的。

相关问题