Skip to content

Commit

Permalink
Add kubernetes_ingress_v1 timeouts (#1936)
Browse files Browse the repository at this point in the history
* Add kubernetes_ingress_v1 timeouts
  • Loading branch information
Tensho authored Jan 4, 2023
1 parent 1615a36 commit 08b70ef
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .changelog/1936.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
`resource/kubernetes_ingress_v1`: add create and delete timeouts
```
2 changes: 1 addition & 1 deletion kubernetes/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ func skipIfNotRunningInGke(t *testing.T) {
t.Skip("The Kubernetes endpoint must come from GKE for this test to run - skipping")
}
for _, ev := range []string{"GOOGLE_PROJECT", "GOOGLE_REGION", "GOOGLE_ZONE"} {
if os.Getenv("ev") == "" {
if os.Getenv(ev) == "" {
t.Skipf("%s must be set for GoogleCloud tests", ev)
}
}
Expand Down
5 changes: 5 additions & 0 deletions kubernetes/resource_kubernetes_ingress_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"log"
"time"

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
networking "k8s.io/api/networking/v1"
Expand All @@ -25,6 +26,10 @@ func resourceKubernetesIngressV1() *schema.Resource {
StateContext: schema.ImportStatePassthroughContext,
},
Schema: resourceKubernetesIngressV1Schema(),
Timeouts: &schema.ResourceTimeout{
Create: schema.DefaultTimeout(20 * time.Minute),
Delete: schema.DefaultTimeout(20 * time.Minute),
},
}
}

Expand Down
17 changes: 15 additions & 2 deletions kubernetes/resource_kubernetes_ingress_v1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,9 @@ func testAccKubernetesIngressV1Config_serviceBackend(name string) string {
}
}
}
timeouts {
create = "45m"
}
}`, name)
}

Expand Down Expand Up @@ -586,10 +589,16 @@ func testAccKubernetesIngressV1Config_waitForLoadBalancer(name string) string {
}
port {
port = 8000
target_port = 80
target_port = 8080
protocol = "TCP"
}
}
lifecycle {
ignore_changes = [
metadata[0].annotations["cloud.google.com/neg"],
metadata[0].annotations["cloud.google.com/neg-status"],
]
}
}
resource "kubernetes_deployment" "test" {
Expand All @@ -612,9 +621,10 @@ resource "kubernetes_deployment" "test" {
container {
name = "test"
image = "gcr.io/google-samples/hello-app:2.0"
env {
name = "PORT"
value = "80"
value = "8080"
}
}
}
Expand All @@ -641,6 +651,9 @@ resource "kubernetes_ingress_v1" "test" {
}
}
wait_for_load_balancer = true
timeouts {
create = "45m"
}
}`, name, name, name, name, name, name, name)
}

Expand Down
7 changes: 6 additions & 1 deletion website/docs/r/ingress_v1.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ description: |-

Ingress is a collection of rules that allow inbound connections to reach the endpoints defined by a backend. An Ingress can be configured to give services externally-reachable urls, load balance traffic, terminate SSL, offer name based virtual hosting etc.


## Example Usage

```hcl
Expand Down Expand Up @@ -306,6 +305,12 @@ The following arguments are supported:
* `ip` - IP is set for load-balancer ingress points that are IP based (typically GCE or OpenStack load-balancers).
* `hostname` - Hostname is set for load-balancer ingress points that are DNS based (typically AWS load-balancers).

## Timeouts

The following [Timeout](https://developer.hashicorp.com/terraform/language/resources/syntax#operation-timeouts) configuration options are available for the `kubernetes_ingress_v1` resource:

* `create` - ingress load balancer creation timeout (default `20 minutes`).
* `delete` - ingress load balancer deletion timeout (default `20 minutes`).

## Import

Expand Down

0 comments on commit 08b70ef

Please sign in to comment.