Skip to content
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

Add ipMode field #2557

Open
wants to merge 5 commits into
base: v3-major-release
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/2557.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
`resource/Kubernetes_Persistent_VolumeClaim_V1`: Add argument `spec.ip_mode`
```
1 change: 1 addition & 0 deletions docs/resources/ingress.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ Read-Only:
Read-Only:

- `hostname` (String)
- `ip_mode` (String)
- `ip` (String)


Expand Down
1 change: 1 addition & 0 deletions docs/resources/ingress_v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ Read-Only:
Read-Only:

- `hostname` (String)
- `ip_mode` (String)
- `ip` (String)


Expand Down
1 change: 1 addition & 0 deletions docs/resources/service.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ Read-Only:

- `hostname` (String)
- `ip` (String)
- `ip_mode` (String)



Expand Down
1 change: 1 addition & 0 deletions docs/resources/service_v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ Read-Only:

- `hostname` (String)
- `ip` (String)
- `ip_mode` (String)



Expand Down
6 changes: 6 additions & 0 deletions kubernetes/resource_kubernetes_service_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
70 changes: 70 additions & 0 deletions kubernetes/resource_kubernetes_service_v1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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" {
Expand Down
1 change: 1 addition & 0 deletions kubernetes/structure_service_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ func flattenLoadBalancerStatus(in v1.LoadBalancerStatus) []interface{} {

att["ip"] = ingress.IP
att["hostname"] = ingress.Hostname
att["ip_mode"] = ingress.IPMode
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we're missing the expander which is where we receive the resp that contains the ip_mode


out[i] = att
}
Expand Down
Loading