-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: thatInfrastructureGuy <[email protected]>
- Loading branch information
1 parent
6761189
commit c75a19f
Showing
9 changed files
with
432 additions
and
0 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -452,6 +452,54 @@ func TestAccAzureRMKubernetesCluster_advancedNetworkingAzureComplete(t *testing. | |
}) | ||
} | ||
|
||
func TestAccAzureRMKubernetesCluster_advancedNetworkingAzureCalicoPolicy(t *testing.T) { | ||
resourceName := "azurerm_kubernetes_cluster.test" | ||
ri := tf.AccRandTimeInt() | ||
clientId := os.Getenv("ARM_CLIENT_ID") | ||
clientSecret := os.Getenv("ARM_CLIENT_SECRET") | ||
config := testAccAzureRMKubernetesCluster_advancedNetworkingWithPolicy(ri, clientId, clientSecret, testLocation(), "azure", "calico") | ||
|
||
resource.ParallelTest(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
CheckDestroy: testCheckAzureRMKubernetesClusterDestroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: config, | ||
Check: resource.ComposeTestCheckFunc( | ||
testCheckAzureRMKubernetesClusterExists(resourceName), | ||
resource.TestCheckResourceAttr(resourceName, "network_profile.0.network_plugin", "azure"), | ||
resource.TestCheckResourceAttr(resourceName, "network_profile.0.network_policy", "calico"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func TestAccAzureRMKubernetesCluster_advancedNetworkingAzureCalicoPolicyComplete(t *testing.T) { | ||
resourceName := "azurerm_kubernetes_cluster.test" | ||
ri := tf.AccRandTimeInt() | ||
clientId := os.Getenv("ARM_CLIENT_ID") | ||
clientSecret := os.Getenv("ARM_CLIENT_SECRET") | ||
config := testAccAzureRMKubernetesCluster_advancedNetworkingWithPolicyComplete(ri, clientId, clientSecret, testLocation(), "azure", "calico") | ||
|
||
resource.ParallelTest(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
CheckDestroy: testCheckAzureRMKubernetesClusterDestroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: config, | ||
Check: resource.ComposeTestCheckFunc( | ||
testCheckAzureRMKubernetesClusterExists(resourceName), | ||
resource.TestCheckResourceAttr(resourceName, "network_profile.0.network_plugin", "azure"), | ||
resource.TestCheckResourceAttr(resourceName, "network_profile.0.network_policy", "calico"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testCheckAzureRMKubernetesClusterExists(resourceName string) resource.TestCheckFunc { | ||
return func(s *terraform.State) error { | ||
// Ensure we have enough information in state to look up in API | ||
|
@@ -1122,3 +1170,143 @@ resource "azurerm_kubernetes_cluster" "test" { | |
} | ||
`, rInt, location, rInt, rInt, rInt, rInt, rInt, rInt, rInt, clientId, clientSecret, networkPlugin) | ||
} | ||
|
||
func testAccAzureRMKubernetesCluster_advancedNetworkingWithPolicy(rInt int, clientId string, clientSecret string, location string, networkPlugin string, networkPolicy string) string { | ||
return fmt.Sprintf(` | ||
resource "azurerm_resource_group" "test" { | ||
name = "acctestRG-%d" | ||
location = "%s" | ||
} | ||
resource "azurerm_virtual_network" "test" { | ||
name = "acctestvirtnet%d" | ||
address_space = ["10.1.0.0/16"] | ||
location = "${azurerm_resource_group.test.location}" | ||
resource_group_name = "${azurerm_resource_group.test.name}" | ||
tags { | ||
environment = "Testing" | ||
} | ||
} | ||
resource "azurerm_subnet" "test" { | ||
name = "acctestsubnet%d" | ||
resource_group_name = "${azurerm_resource_group.test.name}" | ||
virtual_network_name = "${azurerm_virtual_network.test.name}" | ||
address_prefix = "10.1.0.0/24" | ||
} | ||
resource "azurerm_kubernetes_cluster" "test" { | ||
name = "acctestaks%d" | ||
location = "${azurerm_resource_group.test.location}" | ||
resource_group_name = "${azurerm_resource_group.test.name}" | ||
dns_prefix = "acctestaks%d" | ||
linux_profile { | ||
admin_username = "acctestuser%d" | ||
ssh_key { | ||
key_data = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCqaZoyiz1qbdOQ8xEf6uEu1cCwYowo5FHtsBhqLoDnnp7KUTEBN+L2NxRIfQ781rxV6Iq5jSav6b2Q8z5KiseOlvKA/RF2wqU0UPYqQviQhLmW6THTpmrv/YkUCuzxDpsH7DUDhZcwySLKVVe0Qm3+5N2Ta6UYH3lsDf9R9wTP2K/+vAnflKebuypNlmocIvakFWoZda18FOmsOoIVXQ8HWFNCuw9ZCunMSN62QGamCe3dL5cXlkgHYv7ekJE15IA9aOJcM7e90oeTqo+7HTcWfdu0qQqPWY5ujyMw/llas8tsXY85LFqRnr3gJ02bAscjc477+X+j/gkpFoN1QEmt [email protected]" | ||
} | ||
} | ||
agent_pool_profile { | ||
name = "default" | ||
count = "2" | ||
vm_size = "Standard_DS2_v2" | ||
vnet_subnet_id = "${azurerm_subnet.test.id}" | ||
} | ||
service_principal { | ||
client_id = "%s" | ||
client_secret = "%s" | ||
} | ||
network_profile { | ||
network_plugin = "%s" | ||
network_policy = "%s" | ||
} | ||
} | ||
`, rInt, location, rInt, rInt, rInt, rInt, rInt, clientId, clientSecret, networkPlugin, networkPolicy) | ||
} | ||
|
||
func testAccAzureRMKubernetesCluster_advancedNetworkingWithPolicyComplete(rInt int, clientId string, clientSecret string, location string, networkPlugin string, networkPolicy string) string { | ||
return fmt.Sprintf(` | ||
resource "azurerm_resource_group" "test" { | ||
name = "acctestRG-%d" | ||
location = "%s" | ||
} | ||
resource "azurerm_route_table" "test" { | ||
name = "akc-routetable-%d" | ||
location = "${azurerm_resource_group.test.location}" | ||
resource_group_name = "${azurerm_resource_group.test.name}" | ||
route { | ||
name = "akc-route-%d" | ||
address_prefix = "10.100.0.0/14" | ||
next_hop_type = "VirtualAppliance" | ||
next_hop_in_ip_address = "10.10.1.1" | ||
} | ||
} | ||
resource "azurerm_virtual_network" "test" { | ||
name = "acctestvirtnet%d" | ||
address_space = ["10.1.0.0/16"] | ||
location = "${azurerm_resource_group.test.location}" | ||
resource_group_name = "${azurerm_resource_group.test.name}" | ||
tags { | ||
environment = "Testing" | ||
} | ||
} | ||
resource "azurerm_subnet" "test" { | ||
name = "acctestsubnet%d" | ||
resource_group_name = "${azurerm_resource_group.test.name}" | ||
virtual_network_name = "${azurerm_virtual_network.test.name}" | ||
address_prefix = "10.1.0.0/24" | ||
route_table_id = "${azurerm_route_table.test.id}" | ||
} | ||
resource "azurerm_subnet_route_table_association" "test" { | ||
subnet_id = "${azurerm_subnet.test.id}" | ||
route_table_id = "${azurerm_route_table.test.id}" | ||
} | ||
resource "azurerm_kubernetes_cluster" "test" { | ||
name = "acctestaks%d" | ||
location = "${azurerm_resource_group.test.location}" | ||
resource_group_name = "${azurerm_resource_group.test.name}" | ||
dns_prefix = "acctestaks%d" | ||
linux_profile { | ||
admin_username = "acctestuser%d" | ||
ssh_key { | ||
key_data = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCqaZoyiz1qbdOQ8xEf6uEu1cCwYowo5FHtsBhqLoDnnp7KUTEBN+L2NxRIfQ781rxV6Iq5jSav6b2Q8z5KiseOlvKA/RF2wqU0UPYqQviQhLmW6THTpmrv/YkUCuzxDpsH7DUDhZcwySLKVVe0Qm3+5N2Ta6UYH3lsDf9R9wTP2K/+vAnflKebuypNlmocIvakFWoZda18FOmsOoIVXQ8HWFNCuw9ZCunMSN62QGamCe3dL5cXlkgHYv7ekJE15IA9aOJcM7e90oeTqo+7HTcWfdu0qQqPWY5ujyMw/llas8tsXY85LFqRnr3gJ02bAscjc477+X+j/gkpFoN1QEmt [email protected]" | ||
} | ||
} | ||
agent_pool_profile { | ||
name = "default" | ||
count = "2" | ||
vm_size = "Standard_DS2_v2" | ||
vnet_subnet_id = "${azurerm_subnet.test.id}" | ||
} | ||
service_principal { | ||
client_id = "%s" | ||
client_secret = "%s" | ||
} | ||
network_profile { | ||
network_plugin = "%s" | ||
network_policy = "%s" | ||
dns_service_ip = "10.10.0.10" | ||
docker_bridge_cidr = "172.18.0.1/16" | ||
service_cidr = "10.10.0.0/16" | ||
} | ||
} | ||
`, rInt, location, rInt, rInt, rInt, rInt, rInt, rInt, rInt, clientId, clientSecret, networkPlugin, networkPolicy) | ||
} |
Oops, something went wrong.