Created
June 6, 2021 03:49
-
-
Save yogesh174/2d2c967d4be30a11c82a2069ca7cba6c to your computer and use it in GitHub Desktop.
Multi-cloud K8s cluster with Terraform and Ansible
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
####################################### | |
######## Create resource group ######## | |
####################################### | |
resource "azurerm_resource_group" "k8s" { | |
name = var.azure_rg_name | |
location = var.azure_rg_location | |
} | |
######################################## | |
######## Create virtual network ######## | |
######################################## | |
resource "azurerm_virtual_network" "k8s" { | |
name = var.azure_vn_name | |
address_space = var.azure_vn_adress_space | |
location = azurerm_resource_group.k8s.location | |
resource_group_name = azurerm_resource_group.k8s.name | |
} | |
############################### | |
######## Create subnet ######## | |
############################### | |
resource "azurerm_subnet" "k8s" { | |
name = var.azure_subnet_name | |
resource_group_name = azurerm_resource_group.k8s.name | |
virtual_network_name = azurerm_virtual_network.k8s.name | |
address_prefixes = var.azure_subnet_adress_prefixes | |
} | |
################################## | |
######## Create public ip ######## | |
################################## | |
resource "azurerm_public_ip" "k8s_public_ip" { | |
count = var.azure_nodes | |
name = "k8s-${count.index}" | |
location = azurerm_resource_group.k8s.location | |
resource_group_name = azurerm_resource_group.k8s.name | |
allocation_method = "Static" | |
sku = "Basic" | |
} | |
########################################## | |
######## Create network interface ######## | |
########################################## | |
resource "azurerm_network_interface" "k8s" { | |
count = var.azure_nodes | |
name = "k8s-nic-${count.index}" | |
location = azurerm_resource_group.k8s.location | |
resource_group_name = azurerm_resource_group.k8s.name | |
ip_configuration { | |
name = "k8s" | |
subnet_id = azurerm_subnet.k8s.id | |
private_ip_address_allocation = "Dynamic" | |
public_ip_address_id = azurerm_public_ip.k8s_public_ip[count.index].id | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment