-
Notifications
You must be signed in to change notification settings - Fork 4.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
kubernetes_cluster
-pod_cidrs
/service_cidrs
#16657
Changes from all commits
399ab1d
79cd0a0
1a63bf5
f3fda51
5367e77
7a96793
796a3cf
6aa5e1b
a0e0fbf
15cf1ad
bb7268c
a3877fa
4c81277
0d12d6c
c6e5698
a042d9a
feb0c28
47e8bb4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,7 @@ func TestAccKubernetesCluster_advancedNetworkingKubenet(t *testing.T) { | |
data.ImportStep(), | ||
}) | ||
} | ||
|
||
func TestAccKubernetesCluster_advancedNetworkingIPVersionsIPv4(t *testing.T) { | ||
data := acceptance.BuildTestData(t, "azurerm_kubernetes_cluster", "test") | ||
r := KubernetesClusterResource{} | ||
|
@@ -411,6 +412,66 @@ func TestAccKubernetesCluster_privateClusterOff(t *testing.T) { | |
}) | ||
} | ||
|
||
func TestAccKubernetesCluster_podCidrs(t *testing.T) { | ||
data := acceptance.BuildTestData(t, "azurerm_kubernetes_cluster", "test") | ||
r := KubernetesClusterResource{} | ||
|
||
data.ResourceTest(t, r, []acceptance.TestStep{ | ||
{ | ||
Config: r.podCidrs(data), | ||
Check: acceptance.ComposeTestCheckFunc( | ||
check.That(data.ResourceName).ExistsInAzure(r), | ||
), | ||
}, | ||
data.ImportStep(), | ||
}) | ||
} | ||
|
||
func TestAccKubernetesCluster_podCidrsDualStack(t *testing.T) { | ||
data := acceptance.BuildTestData(t, "azurerm_kubernetes_cluster", "test") | ||
r := KubernetesClusterResource{} | ||
|
||
data.ResourceTest(t, r, []acceptance.TestStep{ | ||
{ | ||
Config: r.podCidrsDualStack(data), | ||
Check: acceptance.ComposeTestCheckFunc( | ||
check.That(data.ResourceName).ExistsInAzure(r), | ||
), | ||
}, | ||
data.ImportStep(), | ||
}) | ||
} | ||
|
||
func TestAccKubernetesCluster_serviceCidrs(t *testing.T) { | ||
data := acceptance.BuildTestData(t, "azurerm_kubernetes_cluster", "test") | ||
r := KubernetesClusterResource{} | ||
|
||
data.ResourceTest(t, r, []acceptance.TestStep{ | ||
{ | ||
Config: r.serviceCidrs(data), | ||
Check: acceptance.ComposeTestCheckFunc( | ||
check.That(data.ResourceName).ExistsInAzure(r), | ||
), | ||
}, | ||
data.ImportStep(), | ||
}) | ||
} | ||
|
||
func TestAccKubernetesCluster_serviceCidrsDualStack(t *testing.T) { | ||
data := acceptance.BuildTestData(t, "azurerm_kubernetes_cluster", "test") | ||
r := KubernetesClusterResource{} | ||
|
||
data.ResourceTest(t, r, []acceptance.TestStep{ | ||
{ | ||
Config: r.serviceCidrsDualStack(data), | ||
Check: acceptance.ComposeTestCheckFunc( | ||
check.That(data.ResourceName).ExistsInAzure(r), | ||
), | ||
}, | ||
data.ImportStep(), | ||
}) | ||
} | ||
|
||
func TestAccKubernetesCluster_standardLoadBalancer(t *testing.T) { | ||
data := acceptance.BuildTestData(t, "azurerm_kubernetes_cluster", "test") | ||
r := KubernetesClusterResource{} | ||
|
@@ -1800,6 +1861,136 @@ resource "azurerm_kubernetes_cluster" "test" { | |
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger, enablePrivateCluster, data.RandomInteger) | ||
} | ||
|
||
func (KubernetesClusterResource) podCidrs(data acceptance.TestData) string { | ||
return fmt.Sprintf(` | ||
resource "azurerm_resource_group" "test" { | ||
name = "acctestRG-aks-%d" | ||
location = "%s" | ||
} | ||
|
||
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" | ||
|
||
default_node_pool { | ||
name = "default" | ||
node_count = 1 | ||
vm_size = "Standard_DS2_v2" | ||
} | ||
|
||
network_profile { | ||
network_plugin = "kubenet" | ||
pod_cidrs = ["10.1.1.0/24"] | ||
} | ||
|
||
identity { | ||
type = "SystemAssigned" | ||
} | ||
} | ||
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger) | ||
} | ||
|
||
func (KubernetesClusterResource) podCidrsDualStack(data acceptance.TestData) string { | ||
return fmt.Sprintf(` | ||
resource "azurerm_resource_group" "test" { | ||
name = "acctestRG-aks-%d" | ||
location = "%s" | ||
} | ||
|
||
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" | ||
|
||
default_node_pool { | ||
name = "default" | ||
node_count = 1 | ||
vm_size = "Standard_DS2_v2" | ||
} | ||
|
||
network_profile { | ||
network_plugin = "kubenet" | ||
pod_cidrs = ["10.1.1.0/24", "2002::1234:abcd:ffff:c0a8:101/120"] | ||
ip_versions = ["IPv4", "IPv6"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm assuming this needs to be set in order to be able to provide both an IPv4 and IPv6 address? In which case we should probably add some validation in the create method to inform users as well as a note in the docs? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! I've added that info in the doc. But I think maybe leave the complicated validation to the service side? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The service side error message isn't particularly descriptive. AKS is complex enough as it is, so it would be beneficial to the users if we returned a more informative message such as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry I misunderstood, it's not necessary to set There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure what you mean by order but the test There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got it, I'll test it and add this validation. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @stephybun , I just tried, it still works. resource "azurerm_kubernetes_cluster" "test" {
name = "henglu96"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
dns_prefix = "henglu96"
default_node_pool {
name = "default"
node_count = 1
vm_size = "Standard_DS2_v2"
}
network_profile {
network_plugin = "kubenet"
dns_service_ip = "10.1.1.10"
docker_bridge_cidr = "172.18.0.1/16"
service_cidrs = ["10.1.1.0/24", "2002::1234:abcd:ffff:c0a8:101/120"]
ip_versions = ["IPv6", "IPv4"] // Please notice here
}
identity {
type = "SystemAssigned"
}
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ms-henglu, the order of the arguments
It won't be accepted by the API
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got it, I'll add validation for this case. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @stephybun , I've added this check, thanks! |
||
} | ||
|
||
identity { | ||
type = "SystemAssigned" | ||
} | ||
} | ||
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger) | ||
} | ||
|
||
func (KubernetesClusterResource) serviceCidrs(data acceptance.TestData) string { | ||
return fmt.Sprintf(` | ||
resource "azurerm_resource_group" "test" { | ||
name = "acctestRG-aks-%d" | ||
location = "%s" | ||
} | ||
|
||
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" | ||
|
||
default_node_pool { | ||
name = "default" | ||
node_count = 1 | ||
vm_size = "Standard_DS2_v2" | ||
} | ||
|
||
network_profile { | ||
network_plugin = "kubenet" | ||
dns_service_ip = "10.1.1.10" | ||
docker_bridge_cidr = "172.18.0.1/16" | ||
service_cidrs = ["10.1.1.0/24"] | ||
} | ||
|
||
identity { | ||
type = "SystemAssigned" | ||
} | ||
} | ||
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger) | ||
} | ||
|
||
func (KubernetesClusterResource) serviceCidrsDualStack(data acceptance.TestData) string { | ||
return fmt.Sprintf(` | ||
resource "azurerm_resource_group" "test" { | ||
name = "acctestRG-aks-%d" | ||
location = "%s" | ||
} | ||
|
||
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" | ||
|
||
default_node_pool { | ||
name = "default" | ||
node_count = 1 | ||
vm_size = "Standard_DS2_v2" | ||
} | ||
|
||
network_profile { | ||
network_plugin = "kubenet" | ||
dns_service_ip = "10.1.1.10" | ||
docker_bridge_cidr = "172.18.0.1/16" | ||
service_cidrs = ["10.1.1.0/24", "2002::1234:abcd:ffff:c0a8:101/120"] | ||
ip_versions = ["IPv4", "IPv6"] | ||
} | ||
|
||
identity { | ||
type = "SystemAssigned" | ||
} | ||
} | ||
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger) | ||
} | ||
|
||
func (KubernetesClusterResource) standardLoadBalancerConfig(data acceptance.TestData) string { | ||
return fmt.Sprintf(` | ||
provider "azurerm" { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we also add a test case where we're providing both an IPv4 and IPv6 address?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure