diff --git a/docs/data-sources/pod.md b/docs/data-sources/pod.md
index 96946e8752..5b1c5b4771 100644
--- a/docs/data-sources/pod.md
+++ b/docs/data-sources/pod.md
@@ -802,6 +802,7 @@ Read-Only:
- `name` (String)
- `read_only` (Boolean)
- `sub_path` (String)
+- `sub_path_expr` (String)
@@ -1321,6 +1322,7 @@ Read-Only:
- `name` (String)
- `read_only` (Boolean)
- `sub_path` (String)
+- `sub_path_expr` (String)
diff --git a/docs/data-sources/pod_v1.md b/docs/data-sources/pod_v1.md
index 93199eb308..79ce406607 100644
--- a/docs/data-sources/pod_v1.md
+++ b/docs/data-sources/pod_v1.md
@@ -802,6 +802,7 @@ Read-Only:
- `name` (String)
- `read_only` (Boolean)
- `sub_path` (String)
+- `sub_path_expr` (String)
@@ -1321,6 +1322,7 @@ Read-Only:
- `name` (String)
- `read_only` (Boolean)
- `sub_path` (String)
+- `sub_path_expr` (String)
diff --git a/docs/resources/cron_job.md b/docs/resources/cron_job.md
index c8042befb6..28c053d052 100644
--- a/docs/resources/cron_job.md
+++ b/docs/resources/cron_job.md
@@ -951,6 +951,7 @@ Optional:
- `mount_propagation` (String) Mount propagation mode. mount_propagation determines how mounts are propagated from the host to container and the other way around. Valid values are None (default), HostToContainer and Bidirectional.
- `read_only` (Boolean) Mounted read-only if true, read-write otherwise (false or unspecified). Defaults to false.
- `sub_path` (String) Path within the volume from which the container's volume should be mounted. Defaults to "" (volume's root).
+- `sub_path_expr` (String) Expanded path within the volume from which the container's volume should be mounted. Behaves similarly to SubPath but environment variable references $(VAR_NAME) are expanded using the container's environment. Defaults to "" (volume's root).
### Nested Schema for `spec.job_template.spec.template.spec.container.volume_device`
@@ -1512,6 +1513,7 @@ Optional:
- `mount_propagation` (String) Mount propagation mode. mount_propagation determines how mounts are propagated from the host to container and the other way around. Valid values are None (default), HostToContainer and Bidirectional.
- `read_only` (Boolean) Mounted read-only if true, read-write otherwise (false or unspecified). Defaults to false.
- `sub_path` (String) Path within the volume from which the container's volume should be mounted. Defaults to "" (volume's root).
+- `sub_path_expr` (String) Expanded path within the volume from which the container's volume should be mounted. Behaves similarly to SubPath but environment variable references $(VAR_NAME) are expanded using the container's environment. Defaults to "" (volume's root).
### Nested Schema for `spec.job_template.spec.template.spec.init_container.volume_device`
@@ -2389,4 +2391,4 @@ resource "kubernetes_cron_job" "demo" {
```
$ terraform import kubernetes_cron_job_v1/example default/example
-```
\ No newline at end of file
+```
diff --git a/docs/resources/cron_job_v1.md b/docs/resources/cron_job_v1.md
index c5c7ea1d54..b435350633 100644
--- a/docs/resources/cron_job_v1.md
+++ b/docs/resources/cron_job_v1.md
@@ -946,6 +946,7 @@ Optional:
- `mount_propagation` (String) Mount propagation mode. mount_propagation determines how mounts are propagated from the host to container and the other way around. Valid values are None (default), HostToContainer and Bidirectional.
- `read_only` (Boolean) Mounted read-only if true, read-write otherwise (false or unspecified). Defaults to false.
- `sub_path` (String) Path within the volume from which the container's volume should be mounted. Defaults to "" (volume's root).
+- `sub_path_expr` (String) Expanded path within the volume from which the container's volume should be mounted. Behaves similarly to SubPath but environment variable references $(VAR_NAME) are expanded using the container's environment. Defaults to "" (volume's root).
### Nested Schema for `spec.job_template.spec.template.spec.container.volume_device`
@@ -1507,6 +1508,7 @@ Optional:
- `mount_propagation` (String) Mount propagation mode. mount_propagation determines how mounts are propagated from the host to container and the other way around. Valid values are None (default), HostToContainer and Bidirectional.
- `read_only` (Boolean) Mounted read-only if true, read-write otherwise (false or unspecified). Defaults to false.
- `sub_path` (String) Path within the volume from which the container's volume should be mounted. Defaults to "" (volume's root).
+- `sub_path_expr` (String) Expanded path within the volume from which the container's volume should be mounted. Behaves similarly to SubPath but environment variable references $(VAR_NAME) are expanded using the container's environment. Defaults to "" (volume's root).
### Nested Schema for `spec.job_template.spec.template.spec.init_container.volume_device`
diff --git a/docs/resources/daemon_set_v1.md b/docs/resources/daemon_set_v1.md
index d798ee06aa..5df9255990 100644
--- a/docs/resources/daemon_set_v1.md
+++ b/docs/resources/daemon_set_v1.md
@@ -898,6 +898,7 @@ Optional:
- `mount_propagation` (String) Mount propagation mode. mount_propagation determines how mounts are propagated from the host to container and the other way around. Valid values are None (default), HostToContainer and Bidirectional.
- `read_only` (Boolean) Mounted read-only if true, read-write otherwise (false or unspecified). Defaults to false.
- `sub_path` (String) Path within the volume from which the container's volume should be mounted. Defaults to "" (volume's root).
+- `sub_path_expr` (String) Expanded path within the volume from which the container's volume should be mounted. Behaves similarly to SubPath but environment variable references $(VAR_NAME) are expanded using the container's environment. Defaults to "" (volume's root).
### Nested Schema for `spec.template.spec.container.volume_device`
@@ -1458,6 +1459,7 @@ Optional:
- `mount_propagation` (String) Mount propagation mode. mount_propagation determines how mounts are propagated from the host to container and the other way around. Valid values are None (default), HostToContainer and Bidirectional.
- `read_only` (Boolean) Mounted read-only if true, read-write otherwise (false or unspecified). Defaults to false.
- `sub_path` (String) Path within the volume from which the container's volume should be mounted. Defaults to "" (volume's root).
+- `sub_path_expr` (String) Expanded path within the volume from which the container's volume should be mounted. Behaves similarly to SubPath but environment variable references $(VAR_NAME) are expanded using the container's environment. Defaults to "" (volume's root).
### Nested Schema for `spec.template.spec.init_container.volume_device`
diff --git a/docs/resources/daemonset.md b/docs/resources/daemonset.md
index cbb110ba6a..49a34e6ba0 100644
--- a/docs/resources/daemonset.md
+++ b/docs/resources/daemonset.md
@@ -898,6 +898,7 @@ Optional:
- `mount_propagation` (String) Mount propagation mode. mount_propagation determines how mounts are propagated from the host to container and the other way around. Valid values are None (default), HostToContainer and Bidirectional.
- `read_only` (Boolean) Mounted read-only if true, read-write otherwise (false or unspecified). Defaults to false.
- `sub_path` (String) Path within the volume from which the container's volume should be mounted. Defaults to "" (volume's root).
+- `sub_path_expr` (String) Expanded path within the volume from which the container's volume should be mounted. Behaves similarly to SubPath but environment variable references $(VAR_NAME) are expanded using the container's environment. Defaults to "" (volume's root).
### Nested Schema for `spec.template.spec.container.volume_device`
@@ -1458,6 +1459,7 @@ Optional:
- `mount_propagation` (String) Mount propagation mode. mount_propagation determines how mounts are propagated from the host to container and the other way around. Valid values are None (default), HostToContainer and Bidirectional.
- `read_only` (Boolean) Mounted read-only if true, read-write otherwise (false or unspecified). Defaults to false.
- `sub_path` (String) Path within the volume from which the container's volume should be mounted. Defaults to "" (volume's root).
+- `sub_path_expr` (String) Expanded path within the volume from which the container's volume should be mounted. Behaves similarly to SubPath but environment variable references $(VAR_NAME) are expanded using the container's environment. Defaults to "" (volume's root).
### Nested Schema for `spec.template.spec.init_container.volume_device`
diff --git a/docs/resources/deployment.md b/docs/resources/deployment.md
index 1fa160f220..38062e9ab8 100644
--- a/docs/resources/deployment.md
+++ b/docs/resources/deployment.md
@@ -898,6 +898,7 @@ Optional:
- `mount_propagation` (String) Mount propagation mode. mount_propagation determines how mounts are propagated from the host to container and the other way around. Valid values are None (default), HostToContainer and Bidirectional.
- `read_only` (Boolean) Mounted read-only if true, read-write otherwise (false or unspecified). Defaults to false.
- `sub_path` (String) Path within the volume from which the container's volume should be mounted. Defaults to "" (volume's root).
+- `sub_path_expr` (String) Expanded path within the volume from which the container's volume should be mounted. Behaves similarly to SubPath but environment variable references $(VAR_NAME) are expanded using the container's environment. Defaults to "" (volume's root).
### Nested Schema for `spec.template.spec.container.volume_device`
@@ -1458,6 +1459,7 @@ Optional:
- `mount_propagation` (String) Mount propagation mode. mount_propagation determines how mounts are propagated from the host to container and the other way around. Valid values are None (default), HostToContainer and Bidirectional.
- `read_only` (Boolean) Mounted read-only if true, read-write otherwise (false or unspecified). Defaults to false.
- `sub_path` (String) Path within the volume from which the container's volume should be mounted. Defaults to "" (volume's root).
+- `sub_path_expr` (String) Expanded path within the volume from which the container's volume should be mounted. Behaves similarly to SubPath but environment variable references $(VAR_NAME) are expanded using the container's environment. Defaults to "" (volume's root).
### Nested Schema for `spec.template.spec.init_container.volume_device`
diff --git a/docs/resources/deployment_v1.md b/docs/resources/deployment_v1.md
index 049de98022..4801406631 100644
--- a/docs/resources/deployment_v1.md
+++ b/docs/resources/deployment_v1.md
@@ -906,6 +906,7 @@ Optional:
- `mount_propagation` (String) Mount propagation mode. mount_propagation determines how mounts are propagated from the host to container and the other way around. Valid values are None (default), HostToContainer and Bidirectional.
- `read_only` (Boolean) Mounted read-only if true, read-write otherwise (false or unspecified). Defaults to false.
- `sub_path` (String) Path within the volume from which the container's volume should be mounted. Defaults to "" (volume's root).
+- `sub_path_expr` (String) Expanded path within the volume from which the container's volume should be mounted. Behaves similarly to SubPath but environment variable references $(VAR_NAME) are expanded using the container's environment. Defaults to "" (volume's root).
### Nested Schema for `spec.template.spec.container.volume_device`
@@ -1466,6 +1467,7 @@ Optional:
- `mount_propagation` (String) Mount propagation mode. mount_propagation determines how mounts are propagated from the host to container and the other way around. Valid values are None (default), HostToContainer and Bidirectional.
- `read_only` (Boolean) Mounted read-only if true, read-write otherwise (false or unspecified). Defaults to false.
- `sub_path` (String) Path within the volume from which the container's volume should be mounted. Defaults to "" (volume's root).
+- `sub_path_expr` (String) Expanded path within the volume from which the container's volume should be mounted. Behaves similarly to SubPath but environment variable references $(VAR_NAME) are expanded using the container's environment. Defaults to "" (volume's root).
### Nested Schema for `spec.template.spec.init_container.volume_device`
diff --git a/docs/resources/job.md b/docs/resources/job.md
index 73dacd7813..bcaca5b3ba 100644
--- a/docs/resources/job.md
+++ b/docs/resources/job.md
@@ -906,6 +906,7 @@ Optional:
- `mount_propagation` (String) Mount propagation mode. mount_propagation determines how mounts are propagated from the host to container and the other way around. Valid values are None (default), HostToContainer and Bidirectional.
- `read_only` (Boolean) Mounted read-only if true, read-write otherwise (false or unspecified). Defaults to false.
- `sub_path` (String) Path within the volume from which the container's volume should be mounted. Defaults to "" (volume's root).
+- `sub_path_expr` (String) Expanded path within the volume from which the container's volume should be mounted. Behaves similarly to SubPath but environment variable references $(VAR_NAME) are expanded using the container's environment. Defaults to "" (volume's root).
### Nested Schema for `spec.template.spec.container.volume_device`
@@ -1466,6 +1467,7 @@ Optional:
- `mount_propagation` (String) Mount propagation mode. mount_propagation determines how mounts are propagated from the host to container and the other way around. Valid values are None (default), HostToContainer and Bidirectional.
- `read_only` (Boolean) Mounted read-only if true, read-write otherwise (false or unspecified). Defaults to false.
- `sub_path` (String) Path within the volume from which the container's volume should be mounted. Defaults to "" (volume's root).
+- `sub_path_expr` (String) Expanded path within the volume from which the container's volume should be mounted. Behaves similarly to SubPath but environment variable references $(VAR_NAME) are expanded using the container's environment. Defaults to "" (volume's root).
### Nested Schema for `spec.template.spec.init_container.volume_device`
diff --git a/docs/resources/job_v1.md b/docs/resources/job_v1.md
index 32296bb876..5e222cb5f3 100644
--- a/docs/resources/job_v1.md
+++ b/docs/resources/job_v1.md
@@ -904,6 +904,7 @@ Optional:
- `mount_propagation` (String) Mount propagation mode. mount_propagation determines how mounts are propagated from the host to container and the other way around. Valid values are None (default), HostToContainer and Bidirectional.
- `read_only` (Boolean) Mounted read-only if true, read-write otherwise (false or unspecified). Defaults to false.
- `sub_path` (String) Path within the volume from which the container's volume should be mounted. Defaults to "" (volume's root).
+- `sub_path_expr` (String) Expanded path within the volume from which the container's volume should be mounted. Behaves similarly to SubPath but environment variable references $(VAR_NAME) are expanded using the container's environment. Defaults to "" (volume's root).
### Nested Schema for `spec.template.spec.container.volume_device`
@@ -1464,6 +1465,7 @@ Optional:
- `mount_propagation` (String) Mount propagation mode. mount_propagation determines how mounts are propagated from the host to container and the other way around. Valid values are None (default), HostToContainer and Bidirectional.
- `read_only` (Boolean) Mounted read-only if true, read-write otherwise (false or unspecified). Defaults to false.
- `sub_path` (String) Path within the volume from which the container's volume should be mounted. Defaults to "" (volume's root).
+- `sub_path_expr` (String) Expanded path within the volume from which the container's volume should be mounted. Behaves similarly to SubPath but environment variable references $(VAR_NAME) are expanded using the container's environment. Defaults to "" (volume's root).
### Nested Schema for `spec.template.spec.init_container.volume_device`
diff --git a/docs/resources/pod.md b/docs/resources/pod.md
index 548a508040..9a806bd765 100644
--- a/docs/resources/pod.md
+++ b/docs/resources/pod.md
@@ -857,6 +857,7 @@ Optional:
- `mount_propagation` (String) Mount propagation mode. mount_propagation determines how mounts are propagated from the host to container and the other way around. Valid values are None (default), HostToContainer and Bidirectional.
- `read_only` (Boolean) Mounted read-only if true, read-write otherwise (false or unspecified). Defaults to false.
- `sub_path` (String) Path within the volume from which the container's volume should be mounted. Defaults to "" (volume's root).
+- `sub_path_expr` (String) Expanded path within the volume from which the container's volume should be mounted. Behaves similarly to SubPath but environment variable references $(VAR_NAME) are expanded using the container's environment. Defaults to "" (volume's root).
### Nested Schema for `spec.container.volume_device`
@@ -1418,6 +1419,7 @@ Optional:
- `mount_propagation` (String) Mount propagation mode. mount_propagation determines how mounts are propagated from the host to container and the other way around. Valid values are None (default), HostToContainer and Bidirectional.
- `read_only` (Boolean) Mounted read-only if true, read-write otherwise (false or unspecified). Defaults to false.
- `sub_path` (String) Path within the volume from which the container's volume should be mounted. Defaults to "" (volume's root).
+- `sub_path_expr` (String) Expanded path within the volume from which the container's volume should be mounted. Behaves similarly to SubPath but environment variable references $(VAR_NAME) are expanded using the container's environment. Defaults to "" (volume's root).
### Nested Schema for `spec.init_container.volume_device`
diff --git a/docs/resources/pod_v1.md b/docs/resources/pod_v1.md
index 957dd320da..7c7ac8846a 100644
--- a/docs/resources/pod_v1.md
+++ b/docs/resources/pod_v1.md
@@ -855,6 +855,7 @@ Optional:
- `mount_propagation` (String) Mount propagation mode. mount_propagation determines how mounts are propagated from the host to container and the other way around. Valid values are None (default), HostToContainer and Bidirectional.
- `read_only` (Boolean) Mounted read-only if true, read-write otherwise (false or unspecified). Defaults to false.
- `sub_path` (String) Path within the volume from which the container's volume should be mounted. Defaults to "" (volume's root).
+- `sub_path_expr` (String) Expanded path within the volume from which the container's volume should be mounted. Behaves similarly to SubPath but environment variable references $(VAR_NAME) are expanded using the container's environment. Defaults to "" (volume's root).
### Nested Schema for `spec.container.volume_device`
@@ -1416,6 +1417,7 @@ Optional:
- `mount_propagation` (String) Mount propagation mode. mount_propagation determines how mounts are propagated from the host to container and the other way around. Valid values are None (default), HostToContainer and Bidirectional.
- `read_only` (Boolean) Mounted read-only if true, read-write otherwise (false or unspecified). Defaults to false.
- `sub_path` (String) Path within the volume from which the container's volume should be mounted. Defaults to "" (volume's root).
+- `sub_path_expr` (String) Expanded path within the volume from which the container's volume should be mounted. Behaves similarly to SubPath but environment variable references $(VAR_NAME) are expanded using the container's environment. Defaults to "" (volume's root).
### Nested Schema for `spec.init_container.volume_device`
diff --git a/docs/resources/replication_controller_v1.md b/docs/resources/replication_controller_v1.md
index e83f7c6969..12af4452ae 100644
--- a/docs/resources/replication_controller_v1.md
+++ b/docs/resources/replication_controller_v1.md
@@ -893,6 +893,7 @@ Optional:
- `mount_propagation` (String) Mount propagation mode. mount_propagation determines how mounts are propagated from the host to container and the other way around. Valid values are None (default), HostToContainer and Bidirectional.
- `read_only` (Boolean) Mounted read-only if true, read-write otherwise (false or unspecified). Defaults to false.
- `sub_path` (String) Path within the volume from which the container's volume should be mounted. Defaults to "" (volume's root).
+- `sub_path_expr` (String) Expanded path within the volume from which the container's volume should be mounted. Behaves similarly to SubPath but environment variable references $(VAR_NAME) are expanded using the container's environment. Defaults to "" (volume's root).
### Nested Schema for `spec.template.spec.container.volume_device`
@@ -1453,6 +1454,7 @@ Optional:
- `mount_propagation` (String) Mount propagation mode. mount_propagation determines how mounts are propagated from the host to container and the other way around. Valid values are None (default), HostToContainer and Bidirectional.
- `read_only` (Boolean) Mounted read-only if true, read-write otherwise (false or unspecified). Defaults to false.
- `sub_path` (String) Path within the volume from which the container's volume should be mounted. Defaults to "" (volume's root).
+- `sub_path_expr` (String) Expanded path within the volume from which the container's volume should be mounted. Behaves similarly to SubPath but environment variable references $(VAR_NAME) are expanded using the container's environment. Defaults to "" (volume's root).
### Nested Schema for `spec.template.spec.init_container.volume_device`
diff --git a/docs/resources/stateful_set.md b/docs/resources/stateful_set.md
index dde06232ef..fa41a3ff34 100644
--- a/docs/resources/stateful_set.md
+++ b/docs/resources/stateful_set.md
@@ -925,6 +925,7 @@ Optional:
- `mount_propagation` (String) Mount propagation mode. mount_propagation determines how mounts are propagated from the host to container and the other way around. Valid values are None (default), HostToContainer and Bidirectional.
- `read_only` (Boolean) Mounted read-only if true, read-write otherwise (false or unspecified). Defaults to false.
- `sub_path` (String) Path within the volume from which the container's volume should be mounted. Defaults to "" (volume's root).
+- `sub_path_expr` (String) Expanded path within the volume from which the container's volume should be mounted. Behaves similarly to SubPath but environment variable references $(VAR_NAME) are expanded using the container's environment. Defaults to "" (volume's root).
### Nested Schema for `spec.template.spec.container.volume_device`
@@ -1485,6 +1486,7 @@ Optional:
- `mount_propagation` (String) Mount propagation mode. mount_propagation determines how mounts are propagated from the host to container and the other way around. Valid values are None (default), HostToContainer and Bidirectional.
- `read_only` (Boolean) Mounted read-only if true, read-write otherwise (false or unspecified). Defaults to false.
- `sub_path` (String) Path within the volume from which the container's volume should be mounted. Defaults to "" (volume's root).
+- `sub_path_expr` (String) Expanded path within the volume from which the container's volume should be mounted. Behaves similarly to SubPath but environment variable references $(VAR_NAME) are expanded using the container's environment. Defaults to "" (volume's root).
### Nested Schema for `spec.template.spec.init_container.volume_device`
diff --git a/kubernetes/resource_kubernetes_deployment_v1_test.go b/kubernetes/resource_kubernetes_deployment_v1_test.go
index 85872dec7e..342285bf51 100644
--- a/kubernetes/resource_kubernetes_deployment_v1_test.go
+++ b/kubernetes/resource_kubernetes_deployment_v1_test.go
@@ -649,6 +649,7 @@ func TestAccKubernetesDeploymentV1_with_volume_mount(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "spec.0.template.0.spec.0.container.0.volume_mount.0.name", "db"),
resource.TestCheckResourceAttr(resourceName, "spec.0.template.0.spec.0.container.0.volume_mount.0.read_only", "false"),
resource.TestCheckResourceAttr(resourceName, "spec.0.template.0.spec.0.container.0.volume_mount.0.sub_path", ""),
+ resource.TestCheckResourceAttr(resourceName, "spec.0.template.0.spec.0.container.0.volume_mount.0.sub_path_expr", ""),
),
},
{
diff --git a/kubernetes/resource_kubernetes_pod_v1_test.go b/kubernetes/resource_kubernetes_pod_v1_test.go
index d1970deb96..f92da13598 100644
--- a/kubernetes/resource_kubernetes_pod_v1_test.go
+++ b/kubernetes/resource_kubernetes_pod_v1_test.go
@@ -738,6 +738,7 @@ func TestAccKubernetesPodV1_with_volume_mount(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "spec.0.container.0.volume_mount.0.name", "db"),
resource.TestCheckResourceAttr(resourceName, "spec.0.container.0.volume_mount.0.read_only", "false"),
resource.TestCheckResourceAttr(resourceName, "spec.0.container.0.volume_mount.0.sub_path", ""),
+ resource.TestCheckResourceAttr(resourceName, "spec.0.container.0.volume_mount.0.sub_path_expr", ""),
resource.TestCheckResourceAttr(resourceName, "spec.0.container.0.volume_mount.0.mount_propagation", "HostToContainer"),
),
},
@@ -774,11 +775,13 @@ func TestAccKubernetesPodV1_with_cfg_map_volume_mount(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "spec.0.container.0.volume_mount.0.name", "cfg"),
resource.TestCheckResourceAttr(resourceName, "spec.0.container.0.volume_mount.0.read_only", "false"),
resource.TestCheckResourceAttr(resourceName, "spec.0.container.0.volume_mount.0.sub_path", ""),
+ resource.TestCheckResourceAttr(resourceName, "spec.0.container.0.volume_mount.0.sub_path_expr", ""),
resource.TestCheckResourceAttr(resourceName, "spec.0.container.0.volume_mount.0.mount_propagation", "None"),
resource.TestCheckResourceAttr(resourceName, "spec.0.container.0.volume_mount.1.mount_path", "/tmp/my_raw_path"),
resource.TestCheckResourceAttr(resourceName, "spec.0.container.0.volume_mount.1.name", "cfg-binary"),
resource.TestCheckResourceAttr(resourceName, "spec.0.container.0.volume_mount.1.read_only", "false"),
resource.TestCheckResourceAttr(resourceName, "spec.0.container.0.volume_mount.1.sub_path", ""),
+ resource.TestCheckResourceAttr(resourceName, "spec.0.container.0.volume_mount.1.sub_path_expr", ""),
resource.TestCheckResourceAttr(resourceName, "spec.0.volume.0.name", "cfg"),
resource.TestCheckResourceAttr(resourceName, "spec.0.volume.0.config_map.0.name", cfgMap),
resource.TestCheckResourceAttr(resourceName, "spec.0.volume.0.config_map.0.default_mode", "0777")),
@@ -1640,6 +1643,42 @@ func TestAccKubernetesPodV1_os(t *testing.T) {
})
}
+func TestAccKubernetesPodV1_with_volume_mount_sub_path_expr(t *testing.T) {
+ var conf api.Pod
+ podName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum))
+ secretName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum))
+ imageName := busyboxImage
+ resourceName := "kubernetes_pod_v1.test"
+
+ resource.ParallelTest(t, resource.TestCase{
+ PreCheck: func() { testAccPreCheck(t) },
+ ProviderFactories: testAccProviderFactories,
+ CheckDestroy: testAccCheckKubernetesPodV1Destroy,
+ Steps: []resource.TestStep{
+ {
+ Config: testAccKubernetesPodV1ConfigWithVolumeMountsSubPathExpr(secretName, podName, imageName),
+ Check: resource.ComposeAggregateTestCheckFunc(
+ testAccCheckKubernetesPodV1Exists(resourceName, &conf),
+ resource.TestCheckResourceAttr(resourceName, "spec.0.container.0.image", imageName),
+ resource.TestCheckResourceAttr(resourceName, "spec.0.container.0.volume_mount.#", "1"),
+ resource.TestCheckResourceAttr(resourceName, "spec.0.container.0.volume_mount.0.mount_path", "/tmp/my_path"),
+ resource.TestCheckResourceAttr(resourceName, "spec.0.container.0.volume_mount.0.name", "db"),
+ resource.TestCheckResourceAttr(resourceName, "spec.0.container.0.volume_mount.0.read_only", "false"),
+ resource.TestCheckResourceAttr(resourceName, "spec.0.container.0.volume_mount.0.sub_path", ""),
+ resource.TestCheckResourceAttr(resourceName, "spec.0.container.0.volume_mount.0.sub_path_expr", "$(POD_NAME)"),
+ resource.TestCheckResourceAttr(resourceName, "spec.0.container.0.volume_mount.0.mount_propagation", "HostToContainer"),
+ ),
+ },
+ {
+ ResourceName: resourceName,
+ ImportState: true,
+ ImportStateVerify: true,
+ ImportStateVerifyIgnore: []string{"metadata.0.resource_version"},
+ },
+ },
+ })
+}
+
func testAccCheckCSIDriverExists(csiDriverName string) error {
conn, err := testAccProvider.Meta().(KubeClientsets).MainClientset()
if err != nil {
@@ -3551,3 +3590,50 @@ func testAccKubernetesPodV1ConfigOS(name, imageName string) string {
}
`, name, imageName)
}
+
+func testAccKubernetesPodV1ConfigWithVolumeMountsSubPathExpr(secretName, podName, imageName string) string {
+ return fmt.Sprintf(`resource "kubernetes_secret_v1" "test" {
+ metadata {
+ name = "%s"
+ }
+ data = {
+ one = "first"
+ }
+}
+
+resource "kubernetes_pod_v1" "test" {
+ metadata {
+ labels = {
+ app = "pod_label"
+ }
+ name = "%s"
+ }
+ spec {
+ container {
+ image = "%s"
+ name = "containername"
+ env {
+ name = "POD_NAME"
+ value_from {
+ field_ref {
+ field_path = "metadata.name"
+ }
+ }
+ }
+ volume_mount {
+ mount_path = "/tmp/my_path"
+ name = "db"
+ mount_propagation = "HostToContainer"
+ sub_path_expr = "$(POD_NAME)"
+ }
+ }
+ volume {
+ name = "db"
+ secret {
+ secret_name = kubernetes_secret_v1.test.metadata[0].name
+ }
+ }
+ }
+}
+`, secretName, podName, imageName)
+}
diff --git a/kubernetes/resource_kubernetes_replication_controller_v1_test.go b/kubernetes/resource_kubernetes_replication_controller_v1_test.go
index f6cd0444cf..ffffebe998 100644
--- a/kubernetes/resource_kubernetes_replication_controller_v1_test.go
+++ b/kubernetes/resource_kubernetes_replication_controller_v1_test.go
@@ -421,6 +421,7 @@ func TestAccKubernetesReplicationControllerV1_with_volume_mount(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "spec.0.template.0.spec.0.container.0.volume_mount.0.name", "db"),
resource.TestCheckResourceAttr(resourceName, "spec.0.template.0.spec.0.container.0.volume_mount.0.read_only", "false"),
resource.TestCheckResourceAttr(resourceName, "spec.0.template.0.spec.0.container.0.volume_mount.0.sub_path", ""),
+ resource.TestCheckResourceAttr(resourceName, "spec.0.template.0.spec.0.container.0.volume_mount.0.sub_path_expr", ""),
),
},
},
diff --git a/kubernetes/schema_container.go b/kubernetes/schema_container.go
index 499ea0236a..73f81e6de8 100644
--- a/kubernetes/schema_container.go
+++ b/kubernetes/schema_container.go
@@ -243,6 +243,11 @@ func volumeMountFields() map[string]*schema.Schema {
Optional: true,
Description: `Path within the volume from which the container's volume should be mounted. Defaults to "" (volume's root).`,
},
+ "sub_path_expr": {
+ Type: schema.TypeString,
+ Optional: true,
+ Description: `Dynamic path within the volume from which the container's volume should be mounted. Defaults to "" (volume's root).`,
+ },
"mount_propagation": {
Type: schema.TypeString,
Description: "Mount propagation mode. mount_propagation determines how mounts are propagated from the host to container and the other way around. Valid values are None (default), HostToContainer and Bidirectional.",
diff --git a/kubernetes/structures_container.go b/kubernetes/structures_container.go
index e116825050..e6077729e4 100644
--- a/kubernetes/structures_container.go
+++ b/kubernetes/structures_container.go
@@ -298,6 +298,9 @@ func flattenContainerVolumeMounts(in []v1.VolumeMount) []interface{} {
if v.SubPath != "" {
m["sub_path"] = v.SubPath
}
+ if v.SubPathExpr != "" {
+ m["sub_path_expr"] = v.SubPathExpr
+ }
m["mount_propagation"] = string(v1.MountPropagationNone)
if v.MountPropagation != nil {
@@ -820,6 +823,9 @@ func expandContainerVolumeMounts(in []interface{}) []v1.VolumeMount {
if subPath, ok := p["sub_path"]; ok {
vmp[i].SubPath = subPath.(string)
}
+ if subPathExpr, ok := p["sub_path_expr"]; ok {
+ vmp[i].SubPathExpr = subPathExpr.(string)
+ }
if mountPropagation, ok := p["mount_propagation"]; ok {
mp := v1.MountPropagationMode(mountPropagation.(string))
vmp[i].MountPropagation = &mp