From f49fb20ee6fe4363fbb17715bd733fc5a69fa0d6 Mon Sep 17 00:00:00 2001 From: NickrenREN Date: Thu, 27 Apr 2017 16:58:29 +0800 Subject: [PATCH] Add cinder volume examples I can not find cinder examples,add in packages examples/volume and examples/persistent-volume-provisioning --- .../cinder/cinder-storage-class.yaml | 8 ++++++ .../cinder/example-pod.yaml | 23 ++++++++++++++++ examples/volumes/cinder/README.md | 27 +++++++++++++++++++ examples/volumes/cinder/cinder-web.yaml | 21 +++++++++++++++ 4 files changed, 79 insertions(+) create mode 100644 examples/persistent-volume-provisioning/cinder/cinder-storage-class.yaml create mode 100644 examples/persistent-volume-provisioning/cinder/example-pod.yaml create mode 100644 examples/volumes/cinder/README.md create mode 100644 examples/volumes/cinder/cinder-web.yaml diff --git a/examples/persistent-volume-provisioning/cinder/cinder-storage-class.yaml b/examples/persistent-volume-provisioning/cinder/cinder-storage-class.yaml new file mode 100644 index 0000000000..3dc066cd5a --- /dev/null +++ b/examples/persistent-volume-provisioning/cinder/cinder-storage-class.yaml @@ -0,0 +1,8 @@ +kind: StorageClass +apiVersion: storage.k8s.io/v1 +metadata: + name: gold +provisioner: kubernetes.io/cinder +parameters: + type: fast + availability: nova diff --git a/examples/persistent-volume-provisioning/cinder/example-pod.yaml b/examples/persistent-volume-provisioning/cinder/example-pod.yaml new file mode 100644 index 0000000000..bc14b12054 --- /dev/null +++ b/examples/persistent-volume-provisioning/cinder/example-pod.yaml @@ -0,0 +1,23 @@ +apiVersion: v1 +kind: ReplicationController +metadata: + name: server +spec: + replicas: 1 + selector: + role: server + template: + metadata: + labels: + role: server + spec: + containers: + - name: server + image: nginx + volumeMounts: + - mountPath: /var/lib/www/html + name: cinderpvc + volumes: + - name: cinderpvc + persistentVolumeClaim: + claimName: claim1 diff --git a/examples/volumes/cinder/README.md b/examples/volumes/cinder/README.md new file mode 100644 index 0000000000..bbb3c470e8 --- /dev/null +++ b/examples/volumes/cinder/README.md @@ -0,0 +1,27 @@ +This is a simple web server pod which serves HTML from an Cinder volume. + +Create a volume in the same tenant and zone as your node. + +Add your volume information in the pod description file cinder-web.yaml then create the pod: + +```shell + $ kubectl create -f examples/volumes/cinder/cinder-web.yaml +``` + +Add some data to the volume if is empty: + +```sh + $ echo "Hello World" >& /var/lib/kubelet/plugins/kubernetes.io/cinder/mounts/{Volume ID}/index.html +``` + +You should now be able to query your web server: + +```sh + $ curl + $ Hello World +``` + + + +[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/examples/volumes/cinder/README.md?pixel)]() + diff --git a/examples/volumes/cinder/cinder-web.yaml b/examples/volumes/cinder/cinder-web.yaml new file mode 100644 index 0000000000..4692ac868a --- /dev/null +++ b/examples/volumes/cinder/cinder-web.yaml @@ -0,0 +1,21 @@ +apiVersion: v1 +kind: Pod +metadata: + name: cinder-web +spec: + containers: + - name: web + image: nginx + ports: + - name: web + containerPort: 80 + protocol: tcp + volumeMounts: + - name: html-volume + mountPath: "/usr/share/nginx/html" + volumes: + - name: html-volume + cinder: + # Enter the volume ID below + volumeID: volume_ID + fsType: ext4