Notice
This document is for a development version of Ceph.
Configuring the iSCSI Target using the Command Line Interface
Warning
The iSCSI gateway is deprecated. It is no longer maintained or supported,
and it may be removed from Ceph in a future release. New deployments should
not use it. Existing deployments should migrate to direct RBD access from
clients (librbd, QEMU, Kubernetes CSI and similar) or to the
NVMe-oF gateway.
The Ceph iSCSI gateway is both an iSCSI target and a Ceph client; think of it as a “translator” between Ceph’s RBD interface and the iSCSI standard. The Ceph iSCSI gateway can run on a standalone node or be colocated with other daemons, for example on a node that runs Ceph OSD daemons. When co-locating, ensure that sufficient CPU and memory are available to share. The following steps install and configure the Ceph iSCSI gateway for basic operation.
Requirements:
A running Ceph Luminous or later storage cluster
Linux kernel v4.16 (or newer), or Enterprise Linux (EL) 7.5 (or newer), in which the required iSCSI support is backported
The following packages must be installed from your Linux distribution’s software repository:
targetcli-2.1.fb47or newer packagepython-rtslib-2.1.fb68or newer packagetcmu-runner-1.4.0or newer packageceph-iscsi-3.2or newer package
Important
If previous versions of these packages exist, then they must be removed first before installing the newer versions.
On EL 9, the distribution’s own repositories have neither
tcmu-runnernorceph-iscsi.
Do the following steps on the Ceph iSCSI gateway node before proceeding to the Installing section:
If the Ceph iSCSI gateway is not colocated on an OSD node, then copy the Ceph configuration files, located in
/etc/ceph/, from a running Ceph node in the storage cluster to the iSCSI Gateway node. The Ceph configuration files must exist on the iSCSI gateway node under/etc/ceph/.Install and configure the Ceph command-line interface
If needed, open TCP ports 3260 and 5000 on the firewall.
Note
Access to port 5000 should be restricted to a trusted internal network or only the individual hosts where
gwcliis used orceph-mgrdaemons are running.Create a new or use an existing RADOS Block Device (RBD).
Installing:
If you are using the upstream ceph-iscsi package follow the manual install instructions.
For rpm based instructions execute the following commands:
As
root, on all iSCSI gateway nodes, install theceph-iscsipackage:yum install ceph-iscsiAs
root, on all iSCSI gateway nodes, install thetcmu-runnerpackage:yum install tcmu-runner
Setup:
gwcli stores its configuration in a RADOS object named
gateway.confin the pool that thepoolsetting iniscsi-gateway.cfgnames (defaultrbd). To check if this pool has been created run:ceph osd lspoolsIf it does not exist instructions for creating pools can be found on the RADOS pool operations page.
As
root, on a node that has the admin keyring, create a CephX user for the gateways, with the capabilities that cephadm gives its gateways, and make its keyring readable only byroot:ceph auth get-or-create client.iscsi-gw mon 'profile rbd, allow command "osd blocklist", allow command "config-key get" with "key" prefix "iscsi/"' mgr 'allow command "service status"' osd 'allow rwx' -o /etc/ceph/ceph.client.iscsi-gw.keyring chmod 600 /etc/ceph/ceph.client.iscsi-gw.keyring
Copy this keyring to
/etc/ceph/on every iSCSI gateway node, keeping it readable only byroot.As
root, on a iSCSI gateway node, create a file namediscsi-gateway.cfgin the/etc/ceph/directory, readable only byroot, because it holds the API password:touch /etc/ceph/iscsi-gateway.cfg chmod 600 /etc/ceph/iscsi-gateway.cfg
Edit the
iscsi-gateway.cfgfile and add the following lines, replacing the values in angle brackets:[config] # Name of the Ceph storage cluster. A suitable Ceph configuration file allowing # access to the Ceph storage cluster from the gateway node is required, if not # colocated on an OSD node. cluster_name = ceph # CephX user that the gateway connects as. Its keyring, # /etc/ceph/ceph.client.iscsi-gw.keyring, must be on each gateway. cluster_client_name = client.iscsi-gw # Pool that holds the gateway.conf configuration object. pool = rbd # API settings. # The API supports a number of options that allow you to tailor it to your # local environment. If you want to run the API under https, you will need to # create cert/key files that are compatible for each iSCSI gateway node, that is # not locked to a specific node. SSL cert and key files *must* be called # 'iscsi-gateway.crt' and 'iscsi-gateway.key' and placed in the '/etc/ceph/' directory # on *each* gateway node. With the SSL files in place, you can use 'api_secure = true' # to switch to https mode. With api_secure = false, the API password # and the CHAP secrets cross the network unencrypted. # To support the API, the bare minimum settings are: api_secure = false # Replace the default API user name and password, admin and admin. api_user = <api-user> api_password = <api-password> # Additional API configuration options are as follows, defaults shown. # api_port = 5000 # trusted_ip_list = 192.168.0.10,192.168.0.11
Note
trusted_ip_list is a list of IP addresses on each iSCSI gateway that will be used for management operations like target creation, LUN exporting, etc. The IP can be the same that will be used for iSCSI data, like READ/WRITE commands to/from the RBD image, but using separate IPs is recommended.
Important
The
iscsi-gateway.cfgfile must be identical on all iSCSI gateway nodes.As
root, copy theiscsi-gateway.cfgfile to all iSCSI gateway nodes, keeping it readable only byroot.
As
root, on all iSCSI gateway nodes, enable and start the API service:systemctl daemon-reload systemctl enable rbd-target-gw systemctl start rbd-target-gw systemctl enable rbd-target-api systemctl start rbd-target-api
Configuring:
gwcli will create and configure the iSCSI target and RBD images and copy the configuration across the gateways setup in the last section. Lower level tools including targetcli and rbd can be used to query the local configuration, but should not be used to modify it. This next section will demonstrate how to create a iSCSI target and export a RBD image as LUN 0.
As
root, on a iSCSI gateway node, start the iSCSI gateway command-line interface:gwcliGo to iscsi-targets and create a target with the name iqn.2003-01.com.redhat.iscsi-gw:iscsi-igw:
> /> cd /iscsi-targets > /iscsi-targets> create iqn.2003-01.com.redhat.iscsi-gw:iscsi-igw
Create the iSCSI gateways. The IPs used below are the ones that will be used for iSCSI data like READ and WRITE commands. They can be the same IPs used for management operations listed in trusted_ip_list, but it is recommended that different IPs are used.
> /iscsi-targets> cd iqn.2003-01.com.redhat.iscsi-gw:iscsi-igw/gateways > /iscsi-target...-igw/gateways> create ceph-gw-1 10.172.19.21 > /iscsi-target...-igw/gateways> create ceph-gw-2 10.172.19.22
Use
skipchecks=trueonly if creating a gateway fails withfailed package validation checks - OS is unsupportedon a distribution that your ceph-iscsi build does not recognize, for example Rocky Linux with ceph-iscsi 3.9 or earlier. It also skips the checks that the gateway name resolves, that the IP addresses are on that gateway, and thatiscsi-gateway.cfgis the same on every gateway, so check these yourself first:> /iscsi-targets> cd iqn.2003-01.com.redhat.iscsi-gw:iscsi-igw/gateways > /iscsi-target...-igw/gateways> create ceph-gw-1 10.172.19.21 skipchecks=true > /iscsi-target...-igw/gateways> create ceph-gw-2 10.172.19.22 skipchecks=true
Add a RBD image with the name disk_1 in the pool rbd:
> /iscsi-target...-igw/gateways> cd /disks > /disks> create pool=rbd image=disk_1 size=90G
Create a client with the initiator name iqn.1994-05.com.redhat:rh7-client:
> /disks> cd /iscsi-targets/iqn.2003-01.com.redhat.iscsi-gw:iscsi-igw/hosts > /iscsi-target...eph-igw/hosts> create iqn.1994-05.com.redhat:rh7-client
Set the initiator CHAP username and password which the target would use when authenticating the initiator:
> /iscsi-target...at:rh7-client> auth username=<initiator-user> password=<initiator-secret>Replace the values in angle brackets with your own: user names of 8 to 64 characters and secrets of 12 to 16 characters, from the characters listed below. gwcli rejects the placeholders as shown.
Warning
Set CHAP credentials for every client of the target. If some clients have CHAP and others do not, the clients without CHAP cannot log in. If no client has CHAP (
auth nochap), the gateway checks only the initiator name, which any host can claim.To use mutual (bidirectional) authentication, also set the target CHAP username and password which the initiator would use when authenticating the target:
> /iscsi-target...at:rh7-client> auth username=<initiator-user> password=<initiator-secret> mutual_username=<target-user> mutual_password=<target-secret>Note
CHAP usernames must be between 8 and 64 characters long. Valid characters:
0to9,atoz,AtoZ,@,_,-,.,:.Note
CHAP passwords must be between 12 and 16 characters long. Valid characters:
0to9,atoz,AtoZ,@,_,-,/.Note
For mutual CHAP, initiator and target usernames and passwords must not be the same.
Add the disk to the client:
> /iscsi-target...at:rh7-client> disk add rbd/disk_1
The next step is to configure the iSCSI initiators.
Brought to you by the Ceph Foundation
The Ceph Documentation is a community resource funded and hosted by the non-profit Ceph Foundation. If you would like to support this and our other efforts, please consider joining now.