diff --git a/.changelog/2557.txt b/.changelog/2557.txt new file mode 100644 index 0000000000..18715867b4 --- /dev/null +++ b/.changelog/2557.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +`resource/Kubernetes_Persistent_VolumeClaim_V1`: Add argument `spec.ip_mode` +``` \ No newline at end of file diff --git a/docs/resources/ingress.md b/docs/resources/ingress.md index ac17eaedc8..66702bd920 100644 --- a/docs/resources/ingress.md +++ b/docs/resources/ingress.md @@ -138,6 +138,7 @@ Read-Only: Read-Only: - `hostname` (String) +- `ip_mode` (String) - `ip` (String) diff --git a/docs/resources/ingress_v1.md b/docs/resources/ingress_v1.md index 537761cf9b..380ae75bd2 100644 --- a/docs/resources/ingress_v1.md +++ b/docs/resources/ingress_v1.md @@ -212,6 +212,7 @@ Read-Only: Read-Only: - `hostname` (String) +- `ip_mode` (String) - `ip` (String) diff --git a/docs/resources/service.md b/docs/resources/service.md index b35b2ba51a..c551ea56da 100644 --- a/docs/resources/service.md +++ b/docs/resources/service.md @@ -132,6 +132,7 @@ Read-Only: - `hostname` (String) - `ip` (String) +- `ip_mode` (String) diff --git a/docs/resources/service_v1.md b/docs/resources/service_v1.md index 006428ce48..cdf26e9068 100644 --- a/docs/resources/service_v1.md +++ b/docs/resources/service_v1.md @@ -132,6 +132,7 @@ Read-Only: - `hostname` (String) - `ip` (String) +- `ip_mode` (String) diff --git a/kubernetes/resource_kubernetes_service_v1.go b/kubernetes/resource_kubernetes_service_v1.go index 934f038082..4a6df3bcce 100644 --- a/kubernetes/resource_kubernetes_service_v1.go +++ b/kubernetes/resource_kubernetes_service_v1.go @@ -316,6 +316,12 @@ func resourceKubernetesServiceSchemaV1() map[string]*schema.Schema { Type: schema.TypeString, Computed: true, }, + "ip_mode": { + Type: schema.TypeString, + Optional: true, + Default: "VIP", + ValidateFunc: validation.StringInSlice([]string{"VIP", "Proxy"}, false), + }, "hostname": { Type: schema.TypeString, Computed: true, diff --git a/kubernetes/resource_kubernetes_service_v1_test.go b/kubernetes/resource_kubernetes_service_v1_test.go index 0cbf4b4b56..f4f032c0df 100644 --- a/kubernetes/resource_kubernetes_service_v1_test.go +++ b/kubernetes/resource_kubernetes_service_v1_test.go @@ -337,6 +337,43 @@ func TestAccKubernetesServiceV1_loadBalancer_healthcheck(t *testing.T) { }) } +func TestAccKubernetesServiceV1_loadBalancer_ipMode(t *testing.T) { + var conf corev1.Service + name := acctest.RandomWithPrefix("tf-acc-test") + resourceName := "kubernetes_service_v1.test" + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t); skipIfNoLoadBalancersAvailable(t) }, + IDRefreshIgnore: []string{"metadata.0.resource_version"}, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesServiceV1Destroy, + Steps: []resource.TestStep{ + { + Config: testAccKubernetesConfig_ignoreAnnotations() + + testAccKubernetesServiceV1Config_loadBalancer_defaultIPMode(name), + Check: resource.ComposeAggregateTestCheckFunc( + testAccCheckKubernetesServiceV1Exists(resourceName, &conf), + resource.TestCheckResourceAttr(resourceName, "metadata.0.name", name), + resource.TestCheckResourceAttr(resourceName, "spec.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.type", "LoadBalancer"), + resource.TestCheckResourceAttr(resourceName, "status.0.load_balancer.0.ingress.0.ip_mode", "VIP"), + ), + }, + { + Config: testAccKubernetesConfig_ignoreAnnotations() + + testAccKubernetesServiceV1Config_loadBalancer_ipMode(name, "Proxy"), + Check: resource.ComposeAggregateTestCheckFunc( + testAccCheckKubernetesServiceV1Exists(resourceName, &conf), + resource.TestCheckResourceAttr(resourceName, "metadata.0.name", name), + resource.TestCheckResourceAttr(resourceName, "spec.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.type", "LoadBalancer"), + resource.TestCheckResourceAttr(resourceName, "status.0.load_balancer.0.ingress.0.ip_mode", "Proxy"), + ), + }, + }, + }) +} + func TestAccKubernetesServiceV1_headless(t *testing.T) { var conf corev1.Service name := acctest.RandomWithPrefix("tf-acc-test") @@ -1104,6 +1141,39 @@ func testAccKubernetesServiceV1Config_loadBalancer_annotations_aws_modified(name } `, name) } +func testAccKubernetesServiceV1Config_loadBalancer_defaultIPMode(name string) string { + return fmt.Sprintf(` +resource "kubernetes_service_v1" "test" { + metadata { + name = "%s" + } + spec { + type = "LoadBalancer" + port { + port = 80 + target_port = 8080 + } + } +} +`, name) +} +func testAccKubernetesServiceV1Config_loadBalancer_ipMode(name, ipMode string) string { + return fmt.Sprintf(` +resource "kubernetes_service_v1" "test" { + metadata { + name = "%s" + } + spec { + type = "LoadBalancer" + port { + port = 80 + target_port = 8080 + } + ip_mode = "%s" + } +} +`, name, ipMode) +} func testAccKubernetesServiceV1Config_headless(name string) string { return fmt.Sprintf(`resource "kubernetes_service_v1" "test" { diff --git a/kubernetes/structure_service_spec.go b/kubernetes/structure_service_spec.go index ab0b869616..cc81468b41 100644 --- a/kubernetes/structure_service_spec.go +++ b/kubernetes/structure_service_spec.go @@ -129,6 +129,7 @@ func flattenLoadBalancerStatus(in v1.LoadBalancerStatus) []interface{} { att["ip"] = ingress.IP att["hostname"] = ingress.Hostname + att["ip_mode"] = ingress.IPMode out[i] = att }