If you are using a released version of Kubernetes, you should refer to the docs that go with that version.
The latest release of this document can be found [here](http://releases.k8s.io/release-1.1/examples/iscsi/README.md).Documentation for other releases can be found at releases.k8s.io.
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
then edit /etc/iscsi/iscsid.conf to match your iSCSI target configuration.
I mostly followed these instructions to setup iSCSI target. and these instructions to setup iSCSI initiator.
Setup B. On Unbuntu 12.04 and Debian 7 nodes on Google Compute Engine (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. My Kubernetes cluster on GCE was running Debian 7 images, so I followed these instructions to set up the iSCSI initiator.
Once you have installed iSCSI initiator and new Kubernetes, you can create a pod based on the 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. No initiator information is required.
If you want to use an iSCSI offload card or other open-iscsi transports besides tcp, setup an iSCSI interface and provide iscsiInterface in the pod JSON. The default name for an iscsi iface (open-iscsi parameter iface.iscsi_ifacename) is in the format transport_name.hwaddress when generated by iscsiadm. See open-iscsi or openstack for detailed configuration information.
Note: If you have followed the instructions in the links above you may have partitioned the device, the iSCSI volume plugin does not currently support partitions so format the device as one partition. Make sure you have the correct device name then run the following as root to format it:
mkfs.ext4 /dev/<name of device>
Once your pod is created, run it on the Kubernetes master:
kubectl create -f ./your_new_pod.json
Here is my command and output:
# kubectl create -f examples/iscsi/iscsi.json
# kubectl get pods
NAME READY STATUS RESTARTS AGE
iscsipd 2/2 RUNNING 0 2m
On the Kubernetes node, verify the mount output
# mount |grep kub
/dev/sdb on /var/lib/kubelet/plugins/kubernetes.io/iscsi/10.0.2.15:3260-iqn.2001-04.com.example:storage.kube.sys1.xyz-lun-0 type ext4 (ro,relatime,data=ordered)
/dev/sdb on /var/lib/kubelet/pods/f527ca5b-6d87-11e5-aa7e-080027ff6387/volumes/kubernetes.io~iscsi/iscsipd-ro type ext4 (ro,relatime,data=ordered)
/dev/sdc on /var/lib/kubelet/plugins/kubernetes.io/iscsi/10.0.2.15:3260-iqn.2001-04.com.example:storage.kube.sys1.xyz-lun-1 type ext4 (rw,relatime,data=ordered)
/dev/sdc on /var/lib/kubelet/pods/f527ca5b-6d87-11e5-aa7e-080027ff6387/volumes/kubernetes.io~iscsi/iscsipd-rw type ext4 (rw,relatime,data=ordered)
If you ssh to that machine, you can run docker ps
to see the actual pod.
# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f855336407f4 kubernetes/pause "/pause" 6 minutes ago Up 6 minutes k8s_iscsipd-ro.d130ec3e_iscsipd_default_f527ca5b-6d87-11e5-aa7e-080027ff6387_5409a4cb
3b8a772515d2 kubernetes/pause "/pause" 6 minutes ago Up 6 minutes k8s_iscsipd-rw.ed58ec4e_iscsipd_default_f527ca5b-6d87-11e5-aa7e-080027ff6387_d25592c5
Run docker inspect and verify the container mounted the host directory into the their /mnt/iscsipd directory.
# docker inspect --format '{{ range .Mounts }}{{ if eq .Destination "/mnt/iscsipd" }}{{ .Source }}{{ end }}{{ end }}' f855336407f4
/var/lib/kubelet/pods/f527ca5b-6d87-11e5-aa7e-080027ff6387/volumes/kubernetes.io~iscsi/iscsipd-ro
# docker inspect --format '{{ range .Mounts }}{{ if eq .Destination "/mnt/iscsipd" }}{{ .Source }}{{ end }}{{ end }}' 3b8a772515d2
/var/lib/kubelet/pods/f527ca5b-6d87-11e5-aa7e-080027ff6387/volumes/kubernetes.io~iscsi/iscsipd-rw