Is there any way to have a Flex Volume inside a Persistent Volume Claim?
Any type of PV can back a PVC. You need to create the PV by hand and then specify the name in .spec.volumeName
of the PVC (or use .spec.selector
with labels). Like so:
kind: PersistentVolumeClaimapiVersion: v1metadata: name: task-pv-claimspec: volumeName: task-pv-volume storageClassName: manual accessModes: - ReadWriteOnce resources: requests: storage: 3Gi
As a reference I used this PV (but the type of the PV does not matter):
kind: PersistentVolumeapiVersion: v1metadata: name: task-pv-volumespec: storageClassName: manual capacity: storage: 10Gi accessModes: - ReadWriteOnce hostPath: path: "/tmp/data"
(Alternatively, automatic provisioning with your own storageclass is also possible, but I guess this is not your use case.)
Yes.
apiVersion: v1kind: PersistentVolumemetadata: name: pv0001 spec: capacity: storage: 1Gi accessModes: - ReadWriteOnce flexVolume: driver: openshift.com/foo fsType: "ext4" secretRef: foo-secret readOnly: true options: fooServer: 192.168.0.1:1234 fooVolumeName: bar