我正在使用this repo使用acs-engine在Azure上创建kubernetes集群 .
我想知道是否有人可以帮我确定如何引用主VM的公共IP地址 .
这将用于ssh到主VM( ssh user@public-ip
),这很重要,因为我想运行local-exec配置程序来使用Ansible配置我的集群 .
我不相信它是下面的 first_master_ip
main.tf
(这是在repo 's variables.tf), though I also don'上给出一个值,知道如何引用这个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 回答
我没有使用terraform的经验,但是acs-engine设置了一个公共ip通过你的主人(或跨多个主人的余额)的lb . 你可以使用
<dns_prefix>.<region>.cloudapp.azure.com
找到那个lb的ip .但是如果你需要ip来提供额外的东西,那么当你有多个主人时这是不够的 .