Skip to content

Commit

Permalink
add a test and add mapping for kube_proxy_mode assignement
Browse files Browse the repository at this point in the history
  • Loading branch information
tehcyx authored Aug 25, 2023
1 parent 32792a9 commit 8ee10c1
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
31 changes: 31 additions & 0 deletions kind/resource_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,20 @@ func TestAccClusterConfigBase(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "kind_config.0.networking.0.api_server_port", "6443"),
),
},
{
Config: testAccClusterConfigAndExtraWithNetworkValuesKubeProxyDisabled(clusterName),
Check: resource.ComposeTestCheckFunc(
testAccCheckClusterCreate(resourceName),
resource.TestCheckResourceAttr(resourceName, "name", clusterName),
resource.TestCheckNoResourceAttr(resourceName, "node_image"),
resource.TestCheckResourceAttr(resourceName, "wait_for_ready", "false"),
resource.TestCheckResourceAttr(resourceName, "kind_config.#", "1"),
resource.TestCheckResourceAttr(resourceName, "kind_config.0.kind", "Cluster"),
resource.TestCheckResourceAttr(resourceName, "kind_config.0.api_version", "kind.x-k8s.io/v1alpha4"),
resource.TestCheckResourceAttr(resourceName, "kind_config.0.networking.#", "1"),
resource.TestCheckResourceAttr(resourceName, "kind_config.0.networking.0.kube_proxy_mode", "none"),
),
},
{
Config: testAccClusterConfigAndRuntimeConfig(clusterName),
Check: resource.ComposeTestCheckFunc(
Expand Down Expand Up @@ -755,6 +769,23 @@ resource "kind_cluster" "test" {
`, name)
}

func testAccClusterConfigAndExtraWithNetworkValuesKubeProxyDisabled(name string) string {
return fmt.Sprintf(`
resource "kind_cluster" "test" {
name = "%s"
wait_for_ready = false
kind_config {
kind = "Cluster"
api_version = "kind.x-k8s.io/v1alpha4"
networking {
kube_proxy_mode = "none"
}
}
}
`, name)
}

func testAccClusterConfigAndRuntimeConfig(name string) string {
return fmt.Sprintf(`
resource "kind_cluster" "test" {
Expand Down
3 changes: 3 additions & 0 deletions kind/structure_kind_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,10 @@ func flattenKindConfigNetworking(d map[string]interface{}) v1alpha4.Networking {
obj.KubeProxyMode = v1alpha4.IPTablesProxyMode
case string(v1alpha4.IPVSProxyMode):
obj.KubeProxyMode = v1alpha4.IPVSProxyMode
case "none":
obj.KubeProxyMode = "none"
}

}

podSubnet := mapKeyIfExists(d, "pod_subnet")
Expand Down

0 comments on commit 8ee10c1

Please sign in to comment.