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

Update documentation for VolumeSubpathEnvExpansion #11843

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 5 additions & 4 deletions content/en/docs/concepts/storage/volumes.md
Original file line number Diff line number Diff line change
Expand Up @@ -1071,13 +1071,14 @@ spec:

### Using subPath with expanded environment variables

{{< feature-state for_k8s_version="v1.11" state="alpha" >}}
{{< feature-state for_k8s_version="v1.14" state="alpha" >}}


`subPath` directory names can also be constructed from Downward API environment variables.
`subPath` directory names can also be constructed from Downward API environment variables by using the `subPathExpr` field.
Before you use this feature, you must enable the `VolumeSubpathEnvExpansion` feature gate.
Copy link
Contributor

Choose a reason for hiding this comment

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

I could use a bit more clarification on why & how to use the subPathExpr:

  • In the example, you show the value of subPathExpr equal to an environment variable. Is this always the case?
  • What is the relationship between constructing subPath directory names from Downward API environment variables (which fields or variables?) and using volumeMounts.subPathExpr?
  • Is it downward API or Downward API?
  • Why is the feature flag VolumeSubpathEnvExpansion using lowercase p?

Copy link
Contributor Author

@kevtaylor kevtaylor Dec 21, 2018

Choose a reason for hiding this comment

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

  • It can be any combination of values, but has been designed primarily to give environment variables which are dynamic and available from the Downward API - so it can be $(POD_NAME)/kev
  • You can use any fields from the Downward API - any environment variables that are currently expanded in the container args can be used
  • It is referred to in the documentation as Downward https://kubernetes.io/docs/tasks/inject-data-application/downward-api-volume-expose-pod-information/#the-downward-api
  • The feature gate follows the same naming convention as VolumeSubpath in pkg/features/kube_features.go

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Incidentally, this feature gate and all the documentation with it has already been approved at 1.11 - this is to switch the code structure to a new api field to differentiate it from the subPath which was the original alpha implementation

Copy link
Contributor

Choose a reason for hiding this comment

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

thanks for clarifying, @kevtaylor. Looks good. I think re-using the sub header, Using subPath with expanded environment variables was confusing.
nit, possible change first sentence:
Use the subPathExpr field to construct subPath directory names from Downward API environment variables.
nit, possible change: The subPath and subPathExpr properties are mutually exclusive.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed - I think those suggestions sound better. Pushed change

`subPath` and `subPathExpr` are mutually exclusive.

In this example, a Pod uses `subPath` to create a directory `pod1` within the hostPath volume `/var/log/pods`, using the pod name from the Downward API. The host directory `/var/log/pods/pod1` is mounted at `/logs` in the container.
In this example, a Pod uses `subPathExpr` to create a directory `pod1` within the hostPath volume `/var/log/pods`, using the pod name from the Downward API. The host directory `/var/log/pods/pod1` is mounted at `/logs` in the container.

```yaml
apiVersion: v1
Expand All @@ -1098,7 +1099,7 @@ spec:
volumeMounts:
- name: workdir1
mountPath: /logs
subPath: $(POD_NAME)
subPathExpr: $(POD_NAME)
restartPolicy: Never
volumes:
- name: workdir1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ different Kubernetes components.
| `VolumeScheduling` | `false` | Alpha | 1.9 | 1.9 |
| `VolumeScheduling` | `true` | Beta | 1.10 | 1.12 |
| `VolumeScheduling` | `true` | GA | 1.13 | |
| `VolumeSubpathEnvExpansion` | `false` | Alpha | 1.11 | |
| `VolumeSubpathEnvExpansion` | `false` | Alpha | 1.14 | |
| `VolumeSnapshotDataSource` | `false` | Alpha | 1.12 | - |
| `ScheduleDaemonSetPods` | `false` | Alpha | 1.11 | 1.11 |
| `ScheduleDaemonSetPods` | `true` | Beta | 1.12 | |
Expand Down Expand Up @@ -298,5 +298,6 @@ Each feature gate is designed for enabling/disabling a specific feature:
enables the usage of [`local`](/docs/concepts/storage/volumes/#local) volume
type when used together with the `PersistentLocalVolumes` feature gate.
- `VolumeSnapshotDataSource`: Enable volume snapshot data source support.
- `VolumeSubpathEnvExpansion`: Enable `subPathExpr` field for expanding environment variables into a `subPath`.

{{% /capture %}}