You can create a PVC (Persistent Volume Claim) like this:
apiVersion: v1 kind: PersistentVolumeClaim metadata: name: myclaim # Name of the claim namespace: my-test-namespace # Namespace in which the claim should be accessible/created spec: accessModes: - ReadWriteOnce # Or ReadWriteMany if you want to allow multiple containers to use the same volume. With ReadWriteOnce you need to set volumeMode: Filesystem resources: requests: storage: 128M # Or something like 1G, ... storageClassName: longhorn # Do not change, unless you are using a different storage driver.
Now once it has been created you can use the volume in your deployment, daemon set, ... as follows:
# Please note, information that has nothing to do with the volumes has been omitted from this example! metadata: name: some-deployment namespace: my-test-namespace spec: replicas: 1 template: spec: volumes: - name: myclaim-pvc # A random name given to mention it in this config persistentVolumeClaim: claimName: myclaim # The name of the claim you have given in the previous step containers: - volumeMounts: - name: myclaim-pvc mountPath: /some/path # Only set if you are using ReadWriteOnce. If you don't set this, your containers will fail to start! strategy: type: Recreate