想知道,是否可以使用 Terraform 在 Azure 上设置多个堡垒服务器 + 可用性集。我想枚举给定可用性集中的堡垒节点,但不想使用负载均衡器。有什么例子,可以分享一下吗?
谢谢!!
想知道,是否可以使用 Terraform 在 Azure 上设置多个堡垒服务器 + 可用性集。我想枚举给定可用性集中的堡垒节点,但不想使用负载均衡器。有什么例子,可以分享一下吗?
谢谢!!
回答我的问题:
是的,可以有多个具有公共 IP 地址的堡垒节点。
示例配置:
文件:nic.tf
resource "azurerm_network_interface" "bastion_nic" { name
= "bastionnic${count.index + 1}" location = "${azurerm_resource_group.rg.location}" resource_group_name = "${azurerm_resource_group.rg.name}" network_security_group_id = "${azurerm_network_security_group.broker_nsg.id}" count
= "${var.bastion_instance_count}"
ip_configuration {
name = "bastionip${count.index + 1}"
subnet_id = "${azurerm_subnet.broker_subnet.id}"
private_ip_address_allocation = "Dynamic"
public_ip_address_id = "${element(azurerm_public_ip.bastion_pip.*.id, count.index + 1)}" } }
文件:ip.tf
resource "azurerm_public_ip" "bastion_pip" {
name = "bastionpip${ count.index + 1}"
resource_group_name = "${azurerm_resource_group.rg.name}"
location = "${azurerm_resource_group.rg.location}"
public_ip_address_allocation = "Static"
domain_name_label = "${var.kafka_cluster_prefix}-bastion${ count.index + 1}"
count = "${var.bastion_instance_count}"
}
文件:bastion.tf
resource "azurerm_virtual_machine" "bastion" {
name = "bastion${count.index + 1}"
count = "${var.bastion_instance_count}"
location = "${azurerm_resource_group.rg.location}"
availability_set_id = "${azurerm_availability_set.bastion.id}"
resource_group_name = "${azurerm_resource_group.rg.name}"
network_interface_ids = ["${element(azurerm_network_interface.bastion_nic.*.id, count.index + 1)}"]
vm_size = "${var.bastion_vm_size}"
delete_os_disk_on_termination = true
delete_data_disks_on_termination = true
}
文件:可用性.tf
resource "azurerm_availability_set" "bastion" {
name = "bastionavailabilityset"
managed = "true"
resource_group_name = "${azurerm_resource_group.rg.name}"
location = "${azurerm_resource_group.rg.location}"
}
如果您遵循该示例,您将能够在可用性集中部署多个具有公共 IP 地址的堡垒节点。您需要定义以下内容:
variables.tf 中的变量“ bastion_instance_count
”
干杯。如果您需要帮助,请联系我。