Skip to content

Commit b955024

Browse files
committed
Add document for Cross namespace data sources
1 parent b5aafaa commit b955024

File tree

2 files changed

+65
-1
lines changed

2 files changed

+65
-1
lines changed

content/en/docs/concepts/storage/persistent-volumes.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -952,6 +952,18 @@ or to a VolumeSnapshot, the `dataSourceRef` field can contain a reference to any
952952
same namespace, except for core objects other than PVCs. For clusters that have the feature
953953
gate enabled, use of the `dataSourceRef` is preferred over `dataSource`.
954954

955+
## Cross namespace data sources
956+
{{< feature-state for_k8s_version="v1.26" state="alpha" >}}
957+
958+
Kubernetes supports cross namespace volume data source.
959+
To use cross namespace volume datasource, you must enable the `AnyVolumeDataSource` and `CrossNamespaceVolumeDataSource`
960+
[feature gate](/docs/reference/command-line-tools-reference/feature-gates/) for
961+
the kube-apiserver, kube-controller-manager.
962+
Also, you must enable the `CrossNamespaceVolumeDataSource` feature gate for csi-provisioner.
963+
964+
Enabling the `CrossNamespaceVolumeDataSource` feature gate allow you to specify a namespace in the dataSourceRef field.
965+
{{< note >}} When a namespace is specified, a gateway.networking.k8s.io/ReferenceGrant object is required in the referent namespace to allow that namespace's owner to accept the reference. See the [ReferenceGrant documentation](https://gateway-api.sigs.k8s.io/api-types/referencegrant/) for details.
966+
955967
## Data source references
956968

957969
The `dataSourceRef` field behaves almost the same as the `dataSource` field. If either one is
@@ -969,6 +981,11 @@ users should be aware of:
969981
* The `dataSourceRef` field may contain different types of objects, while the `dataSource` field
970982
only allows PVCs and VolumeSnapshots.
971983

984+
When the `CrossNamespaceVolumeDataSource` feature is enabled, there are additional differences:
985+
986+
* The `dataSource` field only allows local objects, while the `dataSourceRef` field allows objects in any namespaces.
987+
* When namespace is specified, dataSource and dataSourceRef are not synced.
988+
972989
Users should always use `dataSourceRef` on clusters that have the feature gate enabled, and
973990
fall back to `dataSource` on clusters that do not. It is not necessary to look at both fields
974991
under any circumstance. The duplicated values with slightly different semantics exist only for
@@ -1009,6 +1026,50 @@ is registered to handle that kind of data source. When a suitable populator is i
10091026
responsibility of that populator controller to report Events that relate to volume creation and issues during
10101027
the process.
10111028

1029+
### Using Cross Namespace Volume Data Source
1030+
{{< feature-state for_k8s_version="v1.26" state="alpha" >}}
1031+
1032+
Create a gateway.networking.k8s.io/ReferenceGrant to allow the namespace owner to accept the reference.
1033+
Users create a populated volume by referring cross namespace volume data source using the `dataSourceRef` field:
1034+
1035+
```yaml
1036+
apiVersion: gateway.networking.k8s.io/v1beta1
1037+
kind: ReferenceGrant
1038+
metadata:
1039+
name: allow-ns1-pvcg
1040+
namespace: default
1041+
spec:
1042+
from:
1043+
- group: ""
1044+
kind: PersistentVolumeClaim
1045+
namespace: ns1
1046+
to:
1047+
- group: snapshot.storage.k8s.io
1048+
kind: VolumeSnapshot
1049+
name: new-snapshot-demo
1050+
```
1051+
1052+
```yaml
1053+
apiVersion: v1
1054+
kind: PersistentVolumeClaim
1055+
metadata:
1056+
name: foo-pvc
1057+
namespace: ns1
1058+
spec:
1059+
storageClassName: example
1060+
accessModes:
1061+
- ReadWriteOnce
1062+
resources:
1063+
requests:
1064+
storage: 1Gi
1065+
dataSourceRef:
1066+
apiGroup: snapshot.storage.k8s.io
1067+
kind: VolumeSnapshot
1068+
name: new-snapshot-demo
1069+
namespace: default
1070+
volumeMode: Filesystem
1071+
```
1072+
10121073
## Writing Portable Configuration
10131074

10141075
If you're writing configuration templates or examples that run on a wide range of clusters

content/en/docs/reference/command-line-tools-reference/feature-gates.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ For a reference to old feature gates that are removed, please refer to
7272
| `CPUManagerPolicyBetaOptions` | `true` | Beta | 1.23 | |
7373
| `CPUManagerPolicyOptions` | `false` | Alpha | 1.22 | 1.22 |
7474
| `CPUManagerPolicyOptions` | `true` | Beta | 1.23 | |
75+
| `CrossNamespaceVolumeDataSource` | `false` | Alpha| 1.26 | |
7576
| `CSIMigrationPortworx` | `false` | Alpha | 1.23 | 1.24 |
7677
| `CSIMigrationPortworx` | `false` | Beta | 1.25 | |
7778
| `CSIMigrationRBD` | `false` | Alpha | 1.23 | |
@@ -410,6 +411,8 @@ Each feature gate is designed for enabling/disabling a specific feature:
410411
This feature gate guards *a group* of CPUManager options whose quality level is beta.
411412
This feature gate will never graduate to stable.
412413
- `CPUManagerPolicyOptions`: Allow fine-tuning of CPUManager policies.
414+
- `CrossNamespaceVolumeDataSource`: Enable provisioning a {{< glossary_tooltip text="PersistentVolumeClaim" term_id="persistent-volume-claim" >}}
415+
(PVC) that is based on VolumeSnapshot in a different namespace from the PVC.
413416
- `CSIInlineVolume`: Enable CSI Inline volumes support for pods.
414417
- `CSIMigration`: Enables shims and translation logic to route volume
415418
operations from in-tree plugins to corresponding pre-installed CSI plugins
@@ -747,4 +750,4 @@ Each feature gate is designed for enabling/disabling a specific feature:
747750
feature, you will also need to enable any associated API resources.
748751
For example, to enable a particular resource like
749752
`storage.k8s.io/v1beta1/csistoragecapacities`, set `--runtime-config=storage.k8s.io/v1beta1/csistoragecapacities`.
750-
See [API Versioning](/docs/reference/using-api/#api-versioning) for more details on the command line flags.
753+
See [API Versioning](/docs/reference/using-api/#api-versioning) for more details on the command line flags.

0 commit comments

Comments
 (0)