diff --git a/docs/resources/pod.md b/docs/resources/pod.md
index 9a806bd765..1e011ea1cb 100644
--- a/docs/resources/pod.md
+++ b/docs/resources/pod.md
@@ -492,6 +492,7 @@ Optional:
- `exec` (Block List, Max: 1) exec specifies the action to take. (see [below for nested schema](#nestedblock--spec--container--lifecycle--post_start--exec))
- `http_get` (Block List, Max: 1) Specifies the http request to perform. (see [below for nested schema](#nestedblock--spec--container--lifecycle--post_start--http_get))
+- `sleep` (Block List, Max: 1) Sleep represents a duration that the container should sleep (see [below for nested schema](#nestedblock--spec--container--lifecycle--post_start--sleep))
- `tcp_socket` (Block List) TCPSocket specifies an action involving a TCP port. TCP hooks not yet supported (see [below for nested schema](#nestedblock--spec--container--lifecycle--post_start--tcp_socket))
@@ -523,6 +524,14 @@ Optional:
+
+### Nested Schema for `spec.container.lifecycle.post_start.sleep`
+
+Required:
+
+- `seconds` (Number) Number of seconds to sleep.
+
+
### Nested Schema for `spec.container.lifecycle.post_start.tcp_socket`
@@ -539,6 +548,7 @@ Optional:
- `exec` (Block List, Max: 1) exec specifies the action to take. (see [below for nested schema](#nestedblock--spec--container--lifecycle--pre_stop--exec))
- `http_get` (Block List, Max: 1) Specifies the http request to perform. (see [below for nested schema](#nestedblock--spec--container--lifecycle--pre_stop--http_get))
+- `sleep` (Block List, Max: 1) Sleep represents a duration that the container should sleep (see [below for nested schema](#nestedblock--spec--container--lifecycle--pre_stop--sleep))
- `tcp_socket` (Block List) TCPSocket specifies an action involving a TCP port. TCP hooks not yet supported (see [below for nested schema](#nestedblock--spec--container--lifecycle--pre_stop--tcp_socket))
@@ -570,6 +580,14 @@ Optional:
+
+### Nested Schema for `spec.container.lifecycle.pre_stop.sleep`
+
+Required:
+
+- `seconds` (Number) Number of seconds to sleep.
+
+
### Nested Schema for `spec.container.lifecycle.pre_stop.tcp_socket`
@@ -1054,6 +1072,7 @@ Optional:
- `exec` (Block List, Max: 1) exec specifies the action to take. (see [below for nested schema](#nestedblock--spec--init_container--lifecycle--post_start--exec))
- `http_get` (Block List, Max: 1) Specifies the http request to perform. (see [below for nested schema](#nestedblock--spec--init_container--lifecycle--post_start--http_get))
+- `sleep` (Block List, Max: 1) Sleep represents a duration that the container should sleep (see [below for nested schema](#nestedblock--spec--init_container--lifecycle--post_start--sleep))
- `tcp_socket` (Block List) TCPSocket specifies an action involving a TCP port. TCP hooks not yet supported (see [below for nested schema](#nestedblock--spec--init_container--lifecycle--post_start--tcp_socket))
@@ -1085,6 +1104,14 @@ Optional:
+
+### Nested Schema for `spec.init_container.lifecycle.post_start.sleep`
+
+Required:
+
+- `seconds` (Number) Number of seconds to sleep.
+
+
### Nested Schema for `spec.init_container.lifecycle.post_start.tcp_socket`
@@ -1101,6 +1128,7 @@ Optional:
- `exec` (Block List, Max: 1) exec specifies the action to take. (see [below for nested schema](#nestedblock--spec--init_container--lifecycle--pre_stop--exec))
- `http_get` (Block List, Max: 1) Specifies the http request to perform. (see [below for nested schema](#nestedblock--spec--init_container--lifecycle--pre_stop--http_get))
+- `sleep` (Block List, Max: 1) Sleep represents a duration that the container should sleep (see [below for nested schema](#nestedblock--spec--init_container--lifecycle--pre_stop--sleep))
- `tcp_socket` (Block List) TCPSocket specifies an action involving a TCP port. TCP hooks not yet supported (see [below for nested schema](#nestedblock--spec--init_container--lifecycle--pre_stop--tcp_socket))
@@ -1132,6 +1160,14 @@ Optional:
+
+### Nested Schema for `spec.init_container.lifecycle.pre_stop.sleep`
+
+Required:
+
+- `seconds` (Number) Number of seconds to sleep.
+
+
### Nested Schema for `spec.init_container.lifecycle.pre_stop.tcp_socket`
diff --git a/docs/resources/pod_v1.md b/docs/resources/pod_v1.md
index c40bac1146..a19b86f269 100644
--- a/docs/resources/pod_v1.md
+++ b/docs/resources/pod_v1.md
@@ -491,6 +491,7 @@ Optional:
- `exec` (Block List, Max: 1) exec specifies the action to take. (see [below for nested schema](#nestedblock--spec--container--lifecycle--post_start--exec))
- `http_get` (Block List, Max: 1) Specifies the http request to perform. (see [below for nested schema](#nestedblock--spec--container--lifecycle--post_start--http_get))
+- `sleep` (Block List, Max: 1) Sleep represents a duration that the container should sleep (see [below for nested schema](#nestedblock--spec--container--lifecycle--post_start--sleep))
- `tcp_socket` (Block List) TCPSocket specifies an action involving a TCP port. TCP hooks not yet supported (see [below for nested schema](#nestedblock--spec--container--lifecycle--post_start--tcp_socket))
@@ -522,6 +523,14 @@ Optional:
+
+### Nested Schema for `spec.container.lifecycle.post_start.sleep`
+
+Required:
+
+- `seconds` (Number) Number of seconds to sleep.
+
+
### Nested Schema for `spec.container.lifecycle.post_start.tcp_socket`
@@ -538,6 +547,7 @@ Optional:
- `exec` (Block List, Max: 1) exec specifies the action to take. (see [below for nested schema](#nestedblock--spec--container--lifecycle--pre_stop--exec))
- `http_get` (Block List, Max: 1) Specifies the http request to perform. (see [below for nested schema](#nestedblock--spec--container--lifecycle--pre_stop--http_get))
+- `sleep` (Block List, Max: 1) Sleep represents a duration that the container should sleep (see [below for nested schema](#nestedblock--spec--container--lifecycle--pre_stop--sleep))
- `tcp_socket` (Block List) TCPSocket specifies an action involving a TCP port. TCP hooks not yet supported (see [below for nested schema](#nestedblock--spec--container--lifecycle--pre_stop--tcp_socket))
@@ -569,6 +579,14 @@ Optional:
+
+### Nested Schema for `spec.container.lifecycle.pre_stop.sleep`
+
+Required:
+
+- `seconds` (Number) Number of seconds to sleep.
+
+
### Nested Schema for `spec.container.lifecycle.pre_stop.tcp_socket`
@@ -1054,6 +1072,7 @@ Optional:
- `exec` (Block List, Max: 1) exec specifies the action to take. (see [below for nested schema](#nestedblock--spec--init_container--lifecycle--post_start--exec))
- `http_get` (Block List, Max: 1) Specifies the http request to perform. (see [below for nested schema](#nestedblock--spec--init_container--lifecycle--post_start--http_get))
+- `sleep` (Block List, Max: 1) Sleep represents a duration that the container should sleep (see [below for nested schema](#nestedblock--spec--init_container--lifecycle--post_start--sleep))
- `tcp_socket` (Block List) TCPSocket specifies an action involving a TCP port. TCP hooks not yet supported (see [below for nested schema](#nestedblock--spec--init_container--lifecycle--post_start--tcp_socket))
@@ -1085,6 +1104,14 @@ Optional:
+
+### Nested Schema for `spec.init_container.lifecycle.post_start.sleep`
+
+Required:
+
+- `seconds` (Number) Number of seconds to sleep.
+
+
### Nested Schema for `spec.init_container.lifecycle.post_start.tcp_socket`
@@ -1101,6 +1128,7 @@ Optional:
- `exec` (Block List, Max: 1) exec specifies the action to take. (see [below for nested schema](#nestedblock--spec--init_container--lifecycle--pre_stop--exec))
- `http_get` (Block List, Max: 1) Specifies the http request to perform. (see [below for nested schema](#nestedblock--spec--init_container--lifecycle--pre_stop--http_get))
+- `sleep` (Block List, Max: 1) Sleep represents a duration that the container should sleep (see [below for nested schema](#nestedblock--spec--init_container--lifecycle--pre_stop--sleep))
- `tcp_socket` (Block List) TCPSocket specifies an action involving a TCP port. TCP hooks not yet supported (see [below for nested schema](#nestedblock--spec--init_container--lifecycle--pre_stop--tcp_socket))
@@ -1132,6 +1160,14 @@ Optional:
+
+### Nested Schema for `spec.init_container.lifecycle.pre_stop.sleep`
+
+Required:
+
+- `seconds` (Number) Number of seconds to sleep.
+
+
### Nested Schema for `spec.init_container.lifecycle.pre_stop.tcp_socket`
@@ -1352,6 +1388,7 @@ Optional:
- `http_get` (Block List, Max: 1) Specifies the http request to perform. (see [below for nested schema](#nestedblock--spec--init_container--startup_probe--http_get))
- `initial_delay_seconds` (Number) Number of seconds after the container has started before liveness probes are initiated. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#container-probes
- `period_seconds` (Number) How often (in seconds) to perform the probe
+- `sleep` (Block List, Max: 1) Sleep represents a duration that the container should sleep (see [below for nested schema](#nestedblock--spec--init_container--startup_probe--sleep))
- `success_threshold` (Number) Minimum consecutive successes for the probe to be considered successful after having failed.
- `tcp_socket` (Block List) TCPSocket specifies an action involving a TCP port. TCP hooks not yet supported (see [below for nested schema](#nestedblock--spec--init_container--startup_probe--tcp_socket))
- `timeout_seconds` (Number) Number of seconds after which the probe times out. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#container-probes
@@ -1397,6 +1434,14 @@ Optional:
+
+### Nested Schema for `spec.init_container.startup_probe.sleep`
+
+Required:
+
+- `seconds` (Number) Number of seconds to sleep.
+
+
### Nested Schema for `spec.init_container.startup_probe.tcp_socket`
diff --git a/kubernetes/schema_container.go b/kubernetes/schema_container.go
index f35af8fb18..c9ddf4aa1e 100644
--- a/kubernetes/schema_container.go
+++ b/kubernetes/schema_container.go
@@ -98,6 +98,22 @@ func lifecycleHandlerFields() map[string]*schema.Schema {
},
},
},
+ "sleep": {
+ Type: schema.TypeList,
+ Optional: true,
+ MaxItems: 1,
+ Description: "Sleep represents a duration that the container should sleep",
+ Elem: &schema.Resource{
+ Schema: map[string]*schema.Schema{
+ "seconds": {
+ Type: schema.TypeInt,
+ Required: true,
+ ValidateFunc: validation.IntAtLeast(0),
+ Description: "Number of seconds to sleep.",
+ },
+ },
+ },
+ },
}
}
@@ -702,6 +718,7 @@ func containerFields(isUpdatable bool) map[string]*schema.Schema {
func probeSchema() *schema.Resource {
h := lifecycleHandlerFields()
+ delete(h, "sleep")
h["grpc"] = &schema.Schema{
Type: schema.TypeList,
Optional: true,
diff --git a/kubernetes/structures_container.go b/kubernetes/structures_container.go
index 8e1d0e08da..66afeb4392 100644
--- a/kubernetes/structures_container.go
+++ b/kubernetes/structures_container.go
@@ -80,10 +80,19 @@ func flattenLifecycleHandler(in *v1.LifecycleHandler) []interface{} {
if in.TCPSocket != nil {
att["tcp_socket"] = flattenTCPSocket(in.TCPSocket)
}
+ if in.Sleep != nil {
+ att["sleep"] = flattenSleep(in.Sleep)
+ }
return []interface{}{att}
}
+func flattenSleep(in *v1.SleepAction) []interface{} {
+ att := make(map[string]interface{})
+ att["seconds"] = in.Seconds
+ return []interface{}{att}
+}
+
func flattenHTTPHeader(in []v1.HTTPHeader) []interface{} {
att := make([]interface{}, len(in))
for i, v := range in {
@@ -686,6 +695,18 @@ func expandSecurityCapabilities(l []interface{}) *v1.Capabilities {
return &obj
}
+func expandSleep(l []interface{}) *v1.SleepAction {
+ if len(l) == 0 || l[0] == nil {
+ return &v1.SleepAction{}
+ }
+ in := l[0].(map[string]interface{})
+ obj := v1.SleepAction{}
+ if v, ok := in["seconds"].(int); ok && v >= 0 {
+ obj.Seconds = int64(v)
+ }
+ return &obj
+}
+
func expandTCPSocket(l []interface{}) *v1.TCPSocketAction {
if len(l) == 0 || l[0] == nil {
return &v1.TCPSocketAction{}
@@ -791,6 +812,9 @@ func expandLifecycleHandlers(l []interface{}) *v1.LifecycleHandler {
if v, ok := in["tcp_socket"].([]interface{}); ok && len(v) > 0 {
obj.TCPSocket = expandTCPSocket(v)
}
+ if v, ok := in["sleep"].([]interface{}); ok && len(v) > 0 {
+ obj.Sleep = expandSleep(v)
+ }
return &obj
}