Kubernetes persistentVolume and hostPath

From NovaOrdis Knowledge Base
Revision as of 02:11, 4 November 2020 by Ovidiu (talk | contribs) (→‎Internal)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Internal

Example

kind: PersistentVolume
apiVersion: v1
metadata:
  name: local-1
spec:
  accessModes:
  - ReadWriteOnce
  capacity:
    storage: 1Gi
  storageClassName: manual
  hostPath:
    path: /tmp/local-1
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: local-1
spec:
  accessModes:
    - ReadWriteOnce
  storageClassName: manual
  volumeName: local-1
  resources:
    requests:
      storage: 1Gi
---
apiVersion: v1
kind: Pod
metadata:
  name: 'example'
spec:
  containers:
  - name: 'example'
    image: docker.io/ovidiufeodorov/httpd:latest
    volumeMounts:
      - name: 'example-volume'
        mountPath: '/example'
  volumes:
    - name: 'example-volume'
      persistentVolumeClaim:
        claimName: local-1