From 5b8a2ad86f7815b7eca3b47f27dae9fc86faa2de Mon Sep 17 00:00:00 2001 From: Sebastian Gomez Date: Sun, 4 Oct 2020 13:17:16 -0300 Subject: [PATCH] Added an extra PersistentVolumeClaim folder and fixed suggestions from Ian --- PersistentVolume/README.md | 15 ------------ PersistentVolumeClaim/README.md | 23 +++++++++++++++++++ .../pvc.yaml | 2 +- .../pod-pvc.yaml | 10 ++++---- 4 files changed, 29 insertions(+), 21 deletions(-) create mode 100644 PersistentVolumeClaim/README.md rename {PersistentVolume => PersistentVolumeClaim}/pvc.yaml (87%) diff --git a/PersistentVolume/README.md b/PersistentVolume/README.md index 3eb624b..4dd5933 100644 --- a/PersistentVolume/README.md +++ b/PersistentVolume/README.md @@ -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` - diff --git a/PersistentVolumeClaim/README.md b/PersistentVolumeClaim/README.md new file mode 100644 index 0000000..8f4389e --- /dev/null +++ b/PersistentVolumeClaim/README.md @@ -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 +``` \ No newline at end of file diff --git a/PersistentVolume/pvc.yaml b/PersistentVolumeClaim/pvc.yaml similarity index 87% rename from PersistentVolume/pvc.yaml rename to PersistentVolumeClaim/pvc.yaml index 9dc1d20..40bb945 100644 --- a/PersistentVolume/pvc.yaml +++ b/PersistentVolumeClaim/pvc.yaml @@ -2,7 +2,7 @@ apiVersion: v1 kind: PersistentVolumeClaim metadata: - name: my-pvclaim + name: persitent-volume-claim spec: accessModes: - ReadWriteOnce diff --git a/Pod/spec.volumes.persistentVolumeClaim/pod-pvc.yaml b/Pod/spec.volumes.persistentVolumeClaim/pod-pvc.yaml index 9deb161..1f0f7d8 100644 --- a/Pod/spec.volumes.persistentVolumeClaim/pod-pvc.yaml +++ b/Pod/spec.volumes.persistentVolumeClaim/pod-pvc.yaml @@ -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