Kubernetes persistentVolume and hostPath: Difference between revisions
Jump to navigation
Jump to search
(Created page with "=Internal= * Kubernetes Storage Concepts") |
|||
Line 1: | Line 1: | ||
=Internal= | =Internal= | ||
* [[Kubernetes_Storage_Concepts#persistentVolumeClaim_and_hostPath|Kubernetes Storage Concepts]] | * [[Kubernetes_Storage_Concepts#persistentVolumeClaim_and_hostPath|Kubernetes Storage Concepts]] | ||
=Example= | |||
<syntaxhighlight lang='yaml'> | |||
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 | |||
</syntaxhighlight> |
Latest revision as of 02:11, 4 November 2020
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