Creating generic ephemeral volumes
To create ephemeral volumes that are automatically provisioned and deleted with pod lifecycle, define a volumeClaimTemplate in your pod spec specifying storage class, size, and access modes.
Procedure
-
Create the
podobject definition and save it to a file. -
Include the generic ephemeral volume information in the file.
my-example-pod-with-generic-vols.yamlkind: Pod apiVersion: v1 metadata: name: my-app spec: containers: - name: my-frontend image: busybox:1.28 volumeMounts: - mountPath: "/mnt/storage" name: data command: [ "sleep", "1000000" ] volumes: - name: data ephemeral: volumeClaimTemplate: metadata: labels: type: my-app-ephvol spec: accessModes: [ "ReadWriteOnce" ] storageClassName: "gp2-csi" resources: requests: storage: 1GiWhere
spec.volumes.nameis the name of the generic ephemeral volume.