説明
AKS の Pod 間通信を制限するには、クラスターでポリシーエンジンを選び、対象の Pod を選択する NetworkPolicy を適用します。
想定される影響
ポリシーの対象外にある Pod では、不要なネットワーク接続が許可されたままになる場合があります。
対処方法
azure、calico、cilium からネットワークプラグインとデータプレーンに合うエンジンを選んでください。受信・送信規則で DNS など必要な通信を許可します。受信は対象 Pod への接続、送信は対象 Pod からの接続で、許可・拒否の結果を確認してください。
例
どちらも Azure CNI を使い、2 つ目では network_policy = "azure" で Azure NPM を選びます。既存クラスターを変更する場合は AzureRM 5.6.0 のプランで置き換えの有無を確認し、移行を準備してください。新規の Linux クラスターでは Azure CNI Powered by Cilium も検討してください。
変更前
hcl
resource "azurerm_kubernetes_cluster" "example" {
name = "example-aks1"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
dns_prefix = "exampleaks1"
default_node_pool {
name = "default"
node_count = 1
vm_size = "Standard_D2_v2"
}
identity {
type = "SystemAssigned"
}
network_profile {
network_plugin = "azure"
}
}
変更後
hcl
resource "azurerm_kubernetes_cluster" "example" {
name = "example-aks1"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
dns_prefix = "exampleaks1"
default_node_pool {
name = "default"
node_count = 1
vm_size = "Standard_D2_v2"
}
identity {
type = "SystemAssigned"
}
network_profile {
network_plugin = "azure"
network_policy = "azure"
}
}