Skip to content

Commit

Permalink
Rearrange examples
Browse files Browse the repository at this point in the history
For all the examples, create pvc using `pvc.yaml` first.
  • Loading branch information
yasker committed Feb 26, 2019
1 parent 315d67f commit 5bc7f74
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 21 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
30 changes: 30 additions & 0 deletions examples/pod-with-subpath.yaml
Original file line number Diff line number Diff line change
@@ -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
File renamed without changes.
File renamed without changes.

0 comments on commit 5bc7f74

Please sign in to comment.