From 5bc7f74514917d79460ccd7678ac3416074314ca Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Mon, 25 Feb 2019 17:48:03 -0800 Subject: [PATCH] Rearrange examples For all the examples, create pvc using `pvc.yaml` first. --- README.md | 12 ++++---- .../pod-with-node-affinity.yaml | 12 ++++++++ .../pod-with-security-context.yaml | 16 +--------- examples/pod-with-subpath.yaml | 30 +++++++++++++++++++ {example => examples}/pod.yaml | 0 {example => examples}/pvc.yaml | 0 6 files changed, 49 insertions(+), 21 deletions(-) rename example/example-pod-with-node-affinity.yaml => examples/pod-with-node-affinity.yaml (75%) rename example/security-context.yaml => examples/pod-with-security-context.yaml (76%) create mode 100644 examples/pod-with-subpath.yaml rename {example => examples}/pod.yaml (100%) rename {example => examples}/pvc.yaml (100%) diff --git a/README.md b/README.md index 904c1e570..dee2591e2 100644 --- a/README.md +++ b/README.md @@ -45,8 +45,8 @@ $ kubectl -n local-path-storage logs -f local-path-provisioner-d744ccf98-xfcbk Create a `hostPath` backed Persistent Volume and a pod uses it: ``` -kubectl create -f https://raw.githubusercontent.com/rancher/local-path-provisioner/master/example/pvc.yaml -kubectl create -f https://raw.githubusercontent.com/rancher/local-path-provisioner/master/example/pod.yaml +kubectl create -f https://raw.githubusercontent.com/rancher/local-path-provisioner/master/examples/pvc.yaml +kubectl create -f https://raw.githubusercontent.com/rancher/local-path-provisioner/master/examples/pod.yaml ``` You should see the PV has been created: @@ -77,12 +77,12 @@ kubectl exec volume-test -- sh -c "echo local-path-test > /data/test" Now delete the pod using ``` -kubectl delete -f https://raw.githubusercontent.com/rancher/local-path-provisioner/master/example/pod.yaml +kubectl delete -f https://raw.githubusercontent.com/rancher/local-path-provisioner/master/examples/pod.yaml ``` After confirm that the pod is gone, recreated the pod using ``` -kubectl create -f https://raw.githubusercontent.com/rancher/local-path-provisioner/master/example/pod.yaml +kubectl create -f https://raw.githubusercontent.com/rancher/local-path-provisioner/master/examples/pod.yaml ``` Check the volume content: @@ -93,8 +93,8 @@ local-path-test Delete the pod and pvc ``` -kubectl delete -f https://raw.githubusercontent.com/rancher/local-path-provisioner/master/example/pod.yaml -kubectl delete -f https://raw.githubusercontent.com/rancher/local-path-provisioner/master/example/pvc.yaml +kubectl delete -f https://raw.githubusercontent.com/rancher/local-path-provisioner/master/examples/pod.yaml +kubectl delete -f https://raw.githubusercontent.com/rancher/local-path-provisioner/master/examples/pvc.yaml ``` The volume content stored on the node will be automatically cleaned up. You can check the log of `local-path-provisioner-xxx` for details. diff --git a/example/example-pod-with-node-affinity.yaml b/examples/pod-with-node-affinity.yaml similarity index 75% rename from example/example-pod-with-node-affinity.yaml rename to examples/pod-with-node-affinity.yaml index ebe89654f..84a924f78 100644 --- a/example/example-pod-with-node-affinity.yaml +++ b/examples/pod-with-node-affinity.yaml @@ -1,4 +1,16 @@ apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: local-path-pvc +spec: + accessModes: + - ReadWriteOnce + storageClassName: local-path + resources: + requests: + storage: 2Gi +--- +apiVersion: v1 kind: Pod metadata: name: volume-test diff --git a/example/security-context.yaml b/examples/pod-with-security-context.yaml similarity index 76% rename from example/security-context.yaml rename to examples/pod-with-security-context.yaml index 989629202..c7cfaae36 100644 --- a/example/security-context.yaml +++ b/examples/pod-with-security-context.yaml @@ -24,26 +24,12 @@ spec: volumes: - name: test persistentVolumeClaim: - claimName: local-path-test + claimName: local-path-pvc - name: config configMap: name: local-path-test defaultMode: 0555 --- -kind: PersistentVolumeClaim -apiVersion: v1 -metadata: - name: local-path-test - labels: - app.kubernetes.io/name: local-path-test -spec: - accessModes: - - ReadWriteOnce - resources: - requests: - storage: "1Gi" - storageClassName: local-path ---- apiVersion: v1 kind: ConfigMap metadata: diff --git a/examples/pod-with-subpath.yaml b/examples/pod-with-subpath.yaml new file mode 100644 index 000000000..3b0a3e36a --- /dev/null +++ b/examples/pod-with-subpath.yaml @@ -0,0 +1,30 @@ +apiVersion: v1 +kind: Pod +metadata: + name: volume-test + namespace: default +spec: + containers: + - name: volume-test + image: nginx:stable-alpine + imagePullPolicy: IfNotPresent + volumeMounts: + - name: volv + mountPath: /nginx + subPath: nginx + ports: + - containerPort: 80 + - name: volume-test-2 + image: busybox + imagePullPolicy: IfNotPresent + command: + - sleep + - "1000000" + volumeMounts: + - name: volv + mountPath: /busybox + subPath: busybox + volumes: + - name: volv + persistentVolumeClaim: + claimName: local-path-pvc diff --git a/example/pod.yaml b/examples/pod.yaml similarity index 100% rename from example/pod.yaml rename to examples/pod.yaml diff --git a/example/pvc.yaml b/examples/pvc.yaml similarity index 100% rename from example/pvc.yaml rename to examples/pvc.yaml