Skip to content

Commit

Permalink
Added an extra PersistentVolumeClaim folder and fixed suggestions fro…
Browse files Browse the repository at this point in the history
…m Ian
  • Loading branch information
sebagomez committed Oct 4, 2020
1 parent f232011 commit 5b8a2ad
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 21 deletions.
15 changes: 0 additions & 15 deletions PersistentVolume/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,3 @@ Persistent volumes are not covered here as they require third party dependencies

https://kubernetes.io/docs/concepts/storage/persistent-volumes/
https://kubernetes.io/docs/concepts/storage/volume-snapshots/

You can test a local `PersistentVolume` and a `PersistentVolumeClaim` with the following files. (this was tested on a docker-desktop kubernetes cluster)

1 - Create a `PersistentVolume` on your host monted on a local directory (add an `index.html` file in that directory with a hello world message)
> `kubectl apply -f ./PersistentVolume/spec.local/local.yaml`
2 - Create the `PersitentVolumeClaim`
> `kubectl apply -f ./PersistentVolume/pvc.yaml`
3 - Spin up a `Pod` with nginx poiting where its default root directory points to your host's directory
> `kubectl apply -f ./Pod/spec.volumes.persistentVolumeClaim/pod-pvc.yaml`
4 - Port forward your `Pod` and access it with your browser. You should be able to see the `index.html` file from your local directory.
> `kubectl port-forward mypod :80`
23 changes: 23 additions & 0 deletions PersistentVolumeClaim/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
See: https://kubernetes.io/docs/concepts/storage/persistent-volumes/#persistentvolumeclaims

You can test a local `PersistentVolume` and a `PersistentVolumeClaim` with the following files. (this example was tested on a docker-desktop kubernetes cluster)

1 - Create a `PersistentVolume` on your host monted on a local directory (add an `index.html` file in that directory with a hello world message)
`kubectl apply -f ./PersistentVolume/spec.local/local.yaml`

2 - Create the `PersitentVolumeClaim`
`kubectl apply -f ./PersistentVolumeClaim/pvc.yaml`

3 - Spin up a `Pod` with nginx poiting where its default root directory points to your host's directory
`kubectl apply -f ./Pod/spec.volumes.persistentVolumeClaim/pod-pvc.yaml`

4 - Port forward your `Pod` and access it with your browser. You should be able to see the `index.html` file from your local directory.
`kubectl port-forward volume-pvc :80`


Clean up
```
kubectl delete -f ./Pod/spec.volumes.persistentVolumeClaim/pod-pvc.yaml
kubectl delete -f ./PersistentVolumeClaim/pvc.yaml
kubectl delete -f ./PersistentVolume/spec.local/local.yaml
```
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: my-pvclaim
name: persitent-volume-claim
spec:
accessModes:
- ReadWriteOnce
Expand Down
10 changes: 5 additions & 5 deletions Pod/spec.volumes.persistentVolumeClaim/pod-pvc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
apiVersion: v1
kind: Pod
metadata:
name: mypod
name: volume-pvc
spec:
containers:
- name: myfrontend
- name: frontend
image: nginx
volumeMounts:
- mountPath: /usr/share/nginx/html
name: mypd
name: volume-pvc
volumes:
- name: mypd
- name: volume-pvc
persistentVolumeClaim:
claimName: my-pvclaim
claimName: persitent-volume-claim

0 comments on commit 5b8a2ad

Please sign in to comment.