Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add iscsi volume plugin #5506

Merged
merged 1 commit into from
Apr 6, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions api/swagger-spec/v1beta1.json
Original file line number Diff line number Diff line change
Expand Up @@ -6683,6 +6683,32 @@
}
}
},
"v1beta1.ISCSIVolumeSource": {
"id": "v1beta1.ISCSIVolumeSource",
"properties": {
"fsType": {
"type": "string",
"description": "file system type to mount, such as ext4, xfs, ntfs"
},
"iqn": {
"type": "string",
"description": "iSCSI Qualified Name"
},
"lun": {
"type": "integer",
"format": "int32",
"description": "iscsi target lun number"
},
"readOnly": {
"type": "boolean",
"description": "read-only if true, read-write otherwise (false or unspecified)"
},
"targetPortal": {
"type": "string",
"description": "iSCSI target portal"
}
}
},
"v1beta1.HTTPGetAction": {
"id": "v1beta1.HTTPGetAction",
"properties": {
Expand Down Expand Up @@ -8607,6 +8633,7 @@
"persistentDisk",
"gitRepo",
"secret",
"iscsi",
"nfs"
],
"properties": {
Expand All @@ -8630,6 +8657,10 @@
"$ref": "v1beta1.GCEPersistentDiskVolumeSource",
"description": "GCE disk resource attached to the host machine on demand"
},
"iscsi": {
"$ref": "v1beta1.ISCSIVolumeSource",
"description": "iSCSI disk attached to host machine on demand"
},
"secret": {
"$ref": "v1beta1.SecretVolumeSource",
"description": "secret to populate volume with"
Expand Down
31 changes: 31 additions & 0 deletions api/swagger-spec/v1beta2.json
Original file line number Diff line number Diff line change
Expand Up @@ -6679,6 +6679,32 @@
}
}
},
"v1beta2.ISCSIVolumeSource": {
"id": "v1beta2.ISCSIVolumeSource",
"properties": {
"fsType": {
"type": "string",
"description": "file system type to mount, such as ext4, xfs, ntfs"
},
"iqn": {
"type": "string",
"description": "iSCSI Qualified Name"
},
"lun": {
"type": "integer",
"format": "int32",
"description": "iscsi target lun number"
},
"readOnly": {
"type": "boolean",
"description": "read-only if true, read-write otherwise (false or unspecified)"
},
"targetPortal": {
"type": "string",
"description": "iSCSI target portal"
}
}
},
"v1beta2.HTTPGetAction": {
"id": "v1beta2.HTTPGetAction",
"properties": {
Expand Down Expand Up @@ -8588,6 +8614,7 @@
"persistentDisk",
"gitRepo",
"secret",
"iscsi",
"nfs"
],
"properties": {
Expand All @@ -8611,6 +8638,10 @@
"$ref": "v1beta2.GCEPersistentDiskVolumeSource",
"description": "GCE disk resource attached to the host machine on demand"
},
"iscsi": {
"$ref": "v1beta2.ISCSIVolumeSource",
"description": "iSCSI disk attached to host machine on demand"
},
"secret": {
"$ref": "v1beta2.SecretVolumeSource",
"description": "secret to populate volume"
Expand Down
31 changes: 31 additions & 0 deletions api/swagger-spec/v1beta3.json
Original file line number Diff line number Diff line change
Expand Up @@ -7016,6 +7016,32 @@
}
}
},
"v1beta3.ISCSIVolumeSource": {
"id": "v1beta3.ISCSIVolumeSource",
"properties": {
"fsType": {
"type": "string",
"description": "file system type to mount, such as ext4, xfs, ntfs"
},
"iqn": {
"type": "string",
"description": "iSCSI Qualified Name"
},
"lun": {
"type": "integer",
"format": "int32",
"description": "iscsi target lun number"
},
"readOnly": {
"type": "boolean",
"description": "read-only if true, read-write otherwise (false or unspecified)"
},
"targetPortal": {
"type": "string",
"description": "iSCSI target portal"
}
}
},
"v1beta3.HTTPGetAction": {
"id": "v1beta3.HTTPGetAction",
"properties": {
Expand Down Expand Up @@ -8660,6 +8686,7 @@
"secret",
"nfs",
"hostPath",
"iscsi",
"emptyDir"
],
"properties": {
Expand Down Expand Up @@ -8687,6 +8714,10 @@
"$ref": "v1beta3.NFSVolumeSource",
"description": "NFS volume that will be mounted in the host machine"
},
"iscsi": {
"$ref": "v1beta3.ISCSIVolumeSource",
"description": "iSCSI disk attached to host machine on demand"
},
"secret": {
"$ref": "v1beta3.SecretVolumeSource",
"description": "secret to populate volume"
Expand Down
3 changes: 2 additions & 1 deletion cmd/kubelet/app/plugins.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/volume/gce_pd"
"github.com/GoogleCloudPlatform/kubernetes/pkg/volume/git_repo"
"github.com/GoogleCloudPlatform/kubernetes/pkg/volume/host_path"
"github.com/GoogleCloudPlatform/kubernetes/pkg/volume/iscsi"
"github.com/GoogleCloudPlatform/kubernetes/pkg/volume/nfs"
"github.com/GoogleCloudPlatform/kubernetes/pkg/volume/secret"
//Cloud providers
Expand All @@ -53,7 +54,7 @@ func ProbeVolumePlugins() []volume.VolumePlugin {
allPlugins = append(allPlugins, host_path.ProbeVolumePlugins()...)
allPlugins = append(allPlugins, nfs.ProbeVolumePlugins()...)
allPlugins = append(allPlugins, secret.ProbeVolumePlugins()...)

allPlugins = append(allPlugins, iscsi.ProbeVolumePlugins()...)
return allPlugins
}

Expand Down
9 changes: 8 additions & 1 deletion examples/examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,20 @@ func TestExampleObjectSchemas(t *testing.T) {
"claim-02": &api.PersistentVolumeClaim{},
"claim-03": &api.PersistentVolumeClaim{},
},
"../examples/iscsi/v1beta1": {
"iscsi": &api.Pod{},
},
"../examples/iscsi/v1beta3": {
"iscsi": &api.Pod{},
},
}

for path, expected := range cases {
tested := 0
err := walkJSONFiles(path, func(name, path string, data []byte) {
expectedType, found := expected[name]
if !found {
t.Errorf("%s does not have a test case defined", path)
t.Errorf("%s: %s does not have a test case defined", path, name)
return
}
tested += 1
Expand Down Expand Up @@ -210,6 +216,7 @@ func TestReadme(t *testing.T) {
paths := []string{
"../README.md",
"../examples/walkthrough/README.md",
"../examples/iscsi/README.md",
}

for _, path := range paths {
Expand Down
51 changes: 51 additions & 0 deletions examples/iscsi/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# 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:

# 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.

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:

#cluster/kubectl.sh create -f your_new_pod.json

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 <none> Running About a minute
iscsipd-rw kubernetes/pause
```

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)
```

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
```

Run *docker inspect* and I found the Containers mounted the host directory into the their */mnt/iscsipd* directory.
```console
#docker inspect --format "\{\{\.Volumes\}\}" cc9bd22d9e9d
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Can you split this into a separate shell output to improve readability?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rootfs: Ping

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vishh pong, yes :)

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]
```
59 changes: 59 additions & 0 deletions examples/iscsi/v1beta1/iscsi.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"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
}
}
}
]
}
}
}
54 changes: 54 additions & 0 deletions examples/iscsi/v1beta3/iscsi.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"apiVersion": "v1beta3",
"id": "iscsipd",
"kind": "Pod",
"metadata": {
"name": "iscsi"
},
"spec": {
"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",
"iscsi": {
"targetPortal": "10.16.154.81:3260",
"iqn": "iqn.2014-12.world.server:storage.target01",
"lun": 0,
"fsType": "ext4",
"readOnly": true
}
},
{
"name": "iscsipd-rw",
"iscsi": {
"targetPortal": "10.16.154.81:3260",
"iqn": "iqn.2014-12.world.server:storage.target01",
"lun": 1,
"fsType": "xfs",
"readOnly": false
}
}
]
}
}
2 changes: 1 addition & 1 deletion pkg/api/testing/fuzzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func FuzzerFor(t *testing.T, version string, src rand.Source) *fuzz.Fuzzer {
func(vs *api.VolumeSource, c fuzz.Continue) {
// Exactly one of the fields should be set.
//FIXME: the fuzz can still end up nil. What if fuzz allowed me to say that?
fuzzOneOf(c, &vs.HostPath, &vs.EmptyDir, &vs.GCEPersistentDisk, &vs.GitRepo, &vs.Secret, &vs.NFS)
fuzzOneOf(c, &vs.HostPath, &vs.EmptyDir, &vs.GCEPersistentDisk, &vs.GitRepo, &vs.Secret, &vs.NFS, &vs.ISCSI)
},
func(d *api.DNSPolicy, c fuzz.Continue) {
policies := []api.DNSPolicy{api.DNSClusterFirst, api.DNSDefault}
Expand Down
Loading