From 9d5ab52885df5d1d57594cdd3794ef6389ef204a Mon Sep 17 00:00:00 2001 From: Chao Xu Date: Mon, 11 May 2015 17:48:17 -0700 Subject: [PATCH 1/2] update example/iscsi to v1beta3; add more instructions on how to setup iscsi target/initiator on GCE --- examples/examples_test.go | 5 +-- examples/iscsi/README.md | 50 +++++++++++---------- examples/iscsi/{v1beta3 => }/iscsi.json | 3 +- examples/iscsi/v1beta1/iscsi.json | 59 ------------------------- 4 files changed, 28 insertions(+), 89 deletions(-) rename examples/iscsi/{v1beta3 => }/iscsi.json (97%) delete mode 100644 examples/iscsi/v1beta1/iscsi.json diff --git a/examples/examples_test.go b/examples/examples_test.go index e2dfae9154a..ad3c53261b6 100644 --- a/examples/examples_test.go +++ b/examples/examples_test.go @@ -165,10 +165,7 @@ func TestExampleObjectSchemas(t *testing.T) { "claim-02": &api.PersistentVolumeClaim{}, "claim-03": &api.PersistentVolumeClaim{}, }, - "../examples/iscsi/v1beta1": { - "iscsi": &api.Pod{}, - }, - "../examples/iscsi/v1beta3": { + "../examples/iscsi": { "iscsi": &api.Pod{}, }, "../examples/glusterfs/v1beta3": { diff --git a/examples/iscsi/README.md b/examples/iscsi/README.md index 74293450bc4..0d032293716 100644 --- a/examples/iscsi/README.md +++ b/examples/iscsi/README.md @@ -1,15 +1,16 @@ -# How to Use it? -Here is my setup to setup Kubernetes with iSCSI persistent storage. I use Fedora 21 on Kubernetes node. - -Install iSCSI initiator on the node: +## Step 1. Setting up iSCSI target and iSCSI initiator +I use Fedora 21 on Kubernetes node. First install iSCSI initiator on the node: # yum -y install iscsi-initiator-utils then edit */etc/iscsi/initiatorname.iscsi* and */etc/iscsi/iscsid.conf* to match your iSCSI target configuration. -I mostly follow these [instructions](http://www.server-world.info/en/note?os=Fedora_21&p=iscsi&f=2) to setup iSCSI initiator and these [instructions](http://www.server-world.info/en/note?os=Fedora_21&p=iscsi) to setup iSCSI target. +I mostly followed these [instructions](http://www.server-world.info/en/note?os=Fedora_21&p=iscsi&f=2) to setup iSCSI initiator and these [instructions](http://www.server-world.info/en/note?os=Fedora_21&p=iscsi) to setup iSCSI target. +[Here](https://github.com/caesarxuchao/iscsiOnGCE) is an alternative setup on GCE. + +##Step 2. Creating the pod with iSCSI persistent storage Once you have installed iSCSI initiator and new Kubernetes, you can create a pod based on my example *iscsi.json*. In the pod JSON, you need to provide *targetPortal* (the iSCSI target's **IP** address and *port* if not the default port 3260), target's *iqn*, *lun*, and the type of the filesystem that has been created on the lun, and *readOnly* boolean. Once your pod is created, run it on the Kubernetes master: @@ -19,33 +20,34 @@ Once your pod is created, run it on the Kubernetes master: Here is my command and output: ```console - # cluster/kubectl.sh create -f examples/iscsi/v1beta3/iscsi.json - # cluster/kubectl.sh get pods - POD IP CONTAINER(S) IMAGE(S) HOST LABELS STATUS CREATED -iscsi 172.17.0.5 iscsipd-ro kubernetes/pause fed-minion/10.16.154.75 Running About a minute - iscsipd-rw kubernetes/pause +# cluster/kubectl.sh create -f examples/iscsi/iscsi.json +# cluster/kubectl.sh get pods +POD IP CONTAINER(S) IMAGE(S) HOST LABELS STATUS CREATED MESSAGE +iscsipd 10.244.3.14 kubernetes-minion-bz1p/104.154.61.231 Running About an hour + iscsipd-rw kubernetes/pause Running About an hour + iscsipd-ro kubernetes/pause Running About an hour ``` On the Kubernetes node, I got these in mount output ```console - #mount |grep kub - /dev/sdb on /var/lib/kubelet/plugins/kubernetes.io/iscsi/iscsi/10.16.154.81:3260/iqn.2014-12.world.server:storage.target1/lun/0 type ext4 (ro,relatime,stripe=1024,data=ordered) - /dev/sdb on /var/lib/kubelet/pods/4ab78fdc-b927-11e4-ade6-d4bed9b39058/volumes/kubernetes.io~iscsi/iscsipd-ro type ext4 (ro,relatime,stripe=1024,data=ordered) - /dev/sdc on /var/lib/kubelet/plugins/kubernetes.io/iscsi/iscsi/10.16.154.81:3260/iqn.2014-12.world.server:storage.target1/lun/1 type xfs (rw,relatime,attr2,inode64,noquota) - /dev/sdc on /var/lib/kubelet/pods/4ab78fdc-b927-11e4-ade6-d4bed9b39058/volumes/kubernetes.io~iscsi/iscsipd-rw type xfs (rw,relatime,attr2,inode64,noquota) +# mount |grep kub +/dev/sdb on /var/lib/kubelet/plugins/kubernetes.io/iscsi/iscsi/10.240.205.13:3260-iqn-iqn.2014-12.world.server:storage.target1-lun-0 type ext4 (ro,relatime,data=ordered) +/dev/sdb on /var/lib/kubelet/pods/e36158ce-f8d8-11e4-9ae7-42010af01964/volumes/kubernetes.io~iscsi/iscsipd-ro type ext4 (ro,relatime,data=ordered) +/dev/sdc on /var/lib/kubelet/plugins/kubernetes.io/iscsi/iscsi/10.240.205.13:3260-iqn-iqn.2014-12.world.server:storage.target1-lun-1 type xfs (rw,relatime,attr2,inode64,noquota) +/dev/sdc on /var/lib/kubelet/pods/e36158ce-f8d8-11e4-9ae7-42010af01964/volumes/kubernetes.io~iscsi/iscsipd-rw type xfs (rw,relatime,attr2,inode64,noquota) ``` - If you ssh to that machine, you can run `docker ps` to see the actual pod. - - ```console - # docker ps - CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES - cc9bd22d9e9d kubernetes/pause:latest "/pause" 3 minutes ago Up 3 minutes k8s_iscsipd-rw.12d8f0c5_iscsipd.default.etcd_4ab78fdc-b927-11e4-ade6-d4bed9b39058_e3f49dcc +If you ssh to that machine, you can run `docker ps` to see the actual pod. +```console +# docker ps +CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES +cc051196e7af kubernetes/pause:latest "/pause" About an hour ago Up About an hour k8s_iscsipd-rw.ff2d2e9f_iscsipd_default_e36158ce-f8d8-11e4-9ae7-42010af01964_26f3a457 +8aa981443cf4 kubernetes/pause:latest "/pause" About an hour ago Up About an hour k8s_iscsipd-ro.d7752e8f_iscsipd_default_e36158ce-f8d8-11e4-9ae7-42010af01964_4939633d ``` Run *docker inspect* and I found the Containers mounted the host directory into the their */mnt/iscsipd* directory. ```console - #docker inspect --format "\{\{\.Volumes\}\}" cc9bd22d9e9d - map[/mnt/iscsipd:/var/lib/kubelet/pods/4ab78fdc-b927-11e4-ade6-d4bed9b39058/volumes/kubernetes.io~iscsi/iscsipd-rw /dev/termination-log:/var/lib/kubelet/pods/4ab78fdc-b927-11e4-ade6-d4bed9b39058/containers/iscsipd-rw/cc9bd22d9e9db3c88a150cadfdccd86e36c463629035b48bdcfc8ec534be8615] -``` \ No newline at end of file +# docker inspect --format '{{index .Volumes "/mnt/iscsipd"}}' cc051196e7af +/var/lib/kubelet/pods/75e0af2b-f8e8-11e4-9ae7-42010af01964/volumes/kubernetes.io~iscsi/iscsipd-rw +``` diff --git a/examples/iscsi/v1beta3/iscsi.json b/examples/iscsi/iscsi.json similarity index 97% rename from examples/iscsi/v1beta3/iscsi.json rename to examples/iscsi/iscsi.json index 2be37f1efa7..439832b8049 100644 --- a/examples/iscsi/v1beta3/iscsi.json +++ b/examples/iscsi/iscsi.json @@ -1,9 +1,8 @@ { "apiVersion": "v1beta3", - "id": "iscsipd", "kind": "Pod", "metadata": { - "name": "iscsi" + "name": "iscsipd" }, "spec": { "containers": [ diff --git a/examples/iscsi/v1beta1/iscsi.json b/examples/iscsi/v1beta1/iscsi.json deleted file mode 100644 index ac588aeced5..00000000000 --- a/examples/iscsi/v1beta1/iscsi.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "id": "iscsipd", - "kind": "Pod", - "apiVersion": "v1beta1", - "desiredState": { - "manifest": { - "version": "v1beta1", - "id": "iscsipd", - "containers": [ - { - "name": "iscsipd-ro", - "image": "kubernetes/pause", - "volumeMounts": [ - { - "mountPath": "/mnt/iscsipd", - "name": "iscsipd-ro" - } - ] - }, - { - "name": "iscsipd-rw", - "image": "kubernetes/pause", - "volumeMounts": [ - { - "mountPath": "/mnt/iscsipd", - "name": "iscsipd-rw" - } - ] - } - ], - "volumes": [ - { - "name": "iscsipd-ro", - "source": { - "iscsi": { - "targetPortal": "10.16.154.81:3260", - "iqn": "iqn.2014-12.world.server:storage.target01", - "lun": 0, - "fsType": "ext4", - "readOnly": true - } - } - }, - { - "name": "iscsipd-rw", - "source": { - "iscsi": { - "targetPortal": "10.16.154.81:3260", - "iqn": "iqn.2014-12.world.server:storage.target01", - "lun": 1, - "fsType": "xfs", - "readOnly": false - } - } - } - ] - } - } -} \ No newline at end of file From 889647ac7b68acb934b6ba134335c3be3de6e17e Mon Sep 17 00:00:00 2001 From: Chao Xu Date: Wed, 13 May 2015 10:36:06 -0700 Subject: [PATCH 2/2] fix --- examples/iscsi/README.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/examples/iscsi/README.md b/examples/iscsi/README.md index 0d032293716..892dca56a64 100644 --- a/examples/iscsi/README.md +++ b/examples/iscsi/README.md @@ -1,5 +1,7 @@ ## Step 1. Setting up iSCSI target and iSCSI initiator -I use Fedora 21 on Kubernetes node. First install iSCSI initiator on the node: +**Setup A.** On Fedora 21 nodes + +If you use Fedora 21 on Kubernetes node, then first install iSCSI initiator on the node: # yum -y install iscsi-initiator-utils @@ -8,7 +10,9 @@ then edit */etc/iscsi/initiatorname.iscsi* and */etc/iscsi/iscsid.conf* to match I mostly followed these [instructions](http://www.server-world.info/en/note?os=Fedora_21&p=iscsi&f=2) to setup iSCSI initiator and these [instructions](http://www.server-world.info/en/note?os=Fedora_21&p=iscsi) to setup iSCSI target. -[Here](https://github.com/caesarxuchao/iscsiOnGCE) is an alternative setup on GCE. +**Setup B.** On Unbuntu 12.04 and Debian 7 nodes on GCE + +GCE does not provide preconfigured Fedora 21 image, so I set up the iSCSI target on a preconfigured Ubuntu 12.04 image, mostly following these [instructions](http://www.server-world.info/en/note?os=Ubuntu_12.04&p=iscsi). My Kubernetes cluster on GCE was running Debian 7 images, so I followed these [instructions](http://www.server-world.info/en/note?os=Debian_7.0&p=iscsi&f=2) to set up the iSCSI initiator. ##Step 2. Creating the pod with iSCSI persistent storage Once you have installed iSCSI initiator and new Kubernetes, you can create a pod based on my example *iscsi.json*. In the pod JSON, you need to provide *targetPortal* (the iSCSI target's **IP** address and *port* if not the default port 3260), target's *iqn*, *lun*, and the type of the filesystem that has been created on the lun, and *readOnly* boolean.