我是 DevOps 和 Terraform 領域的新手,我想問以下問題。我已經在資源組“網路”中創建了一個名為“myVNET”的 VNET(使用門戶)。我正在嘗試使用 Terraform 實作 AKS 集群。我的 main.tf 檔案在下面
provider "azurerm" {
subscription_id = var.subscription_id
client_id = var.client_id
client_secret = var.client_secret
tenant_id = var.tenant_id
features {}
}
resource "azurerm_resource_group" "MyPlatform" {
name = var.resourcename
location = var.location
}
resource "azurerm_kubernetes_cluster" "aks-cluster" {
name = var.clustername
location = azurerm_resource_group.MyPlatform.location
resource_group_name = azurerm_resource_group.MyPlatform.name
dns_prefix = var.dnspreffix
default_node_pool {
name = "default"
node_count = var.agentnode
vm_size = var.size
}
service_principal {
client_id = var.client_id
client_secret = var.client_secret
}
network_profile {
network_plugin = "azure"
load_balancer_sku = "standard"
network_policy = "calico"
}
}
我的問題如下,如何將我的集群附加到我的 VNET?
uj5u.com熱心網友回復:
為此,您可以將子網 ID 分配給節點池vnet_subnet_id。
data "azurerm_subnet" "subnet" {
name = "<name of the subnet to run in>"
virtual_network_name = "MyVNET"
resource_group_name = "Networks"
}
...
resource "azurerm_kubernetes_cluster" "aks-cluster" {
...
default_node_pool {
name = "default"
...
vnet_subnet_id = data.azurerm_subnet.subnet.id
}
...
如果不直接使用它,您可以參考此現有模塊來構建您自己的模塊。
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/379591.html
標籤:天蓝色 Kubernetes 地形 azure-aks
上一篇:Azure表存盤樂觀并發處理?
