Create a Volume
Create an Empty Volume
- UI
- API
- Terraform
Header Section
- Set the Volume
Name
. - (Optional) Provide a
Description
for the Volume.
Basics Tab
- Choose
New
inSource
. - Select an existing
StorageClass
. - Configure the
Size
of the volume.
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
annotations:
volume.beta.kubernetes.io/storage-provisioner: driver.longhorn.io
volume.kubernetes.io/storage-provisioner: driver.longhorn.io
name: my-vol
namespace: default
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 10Gi
volumeMode: Block
volumeName: pvc-my-vol
To create an empty volume on Harvester with Terraform using the Harvester Terraform Provider, define a harvester_volume
resource block:
resource "harvester_volume" "empty-volume" {
name = "empty-volume"
namespace = "default"
size = "10Gi"
}
Create an Image Volume
- UI
- API
- Terraform
Header Section
- Set the Volume
Name
. - (Optional) Provide a
Description
for the Volume.
Basics Tab
- Choose
VM Image
inSource
. - Select an existing
Image
. - Configure the
Size
of the volume.
Create a volume, initialized with the contents of the image image-8rb2z
from the namespace default
:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
annotations:
harvesterhci.io/imageId: default/image-8rb2z
volume.beta.kubernetes.io/storage-provisioner: driver.longhorn.io
volume.kubernetes.io/storage-provisioner: driver.longhorn.io
name: foobar
namespace: default
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 5Gi
storageClassName: longhorn-image-8rb2z
volumeMode: Block
volumeName: pvc-foobar
To create a volume on Harvester using Terraform and initialize it with the contents of an
image, define a harvester_volume
resource block and set the image
property:
resource "harvester_volume" "opensuse154-image-disk" {
name = "opensuse154-image-disk"
namespace = "default"
size = "10Gi"
image = harvester_image.opensuse154.id
}