mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-08 11:38:15 +00:00
iscsi: use dbus from the host
When running iscsi test, use dbus socket from the host. targetcli uses the socket for synchronization. Recent Fedoras can run dbus only via systemd, which is cumbersome here.
This commit is contained in:
parent
18d05b646d
commit
75cf25c0e7
@ -347,6 +347,8 @@ func newISCSIServer(ctx context.Context, cs clientset.Interface, namespace strin
|
|||||||
"/sys/kernel": "/sys/kernel",
|
"/sys/kernel": "/sys/kernel",
|
||||||
// iSCSI source "block devices" must be available on the host
|
// iSCSI source "block devices" must be available on the host
|
||||||
"/srv/iscsi": "/srv/iscsi",
|
"/srv/iscsi": "/srv/iscsi",
|
||||||
|
// targetcli uses dbus
|
||||||
|
"/run/dbus": "/run/dbus",
|
||||||
},
|
},
|
||||||
ServerReadyMessage: "iscsi target started",
|
ServerReadyMessage: "iscsi target started",
|
||||||
ServerHostNetwork: true,
|
ServerHostNetwork: true,
|
||||||
|
@ -1 +1 @@
|
|||||||
2.5
|
2.6
|
||||||
|
@ -21,20 +21,12 @@
|
|||||||
# Kubernetes must provide unique name.
|
# Kubernetes must provide unique name.
|
||||||
IQN=$1
|
IQN=$1
|
||||||
|
|
||||||
# targetcli synchronizes over dbus, however it does not work in
|
|
||||||
# containers. Use flock instead
|
|
||||||
LOCK=/srv/iscsi/targetcli.lock
|
|
||||||
|
|
||||||
function start()
|
function start()
|
||||||
{
|
{
|
||||||
# targetcli need dbus. It may not run on the host, so start a private one
|
|
||||||
mkdir /run/dbus
|
|
||||||
dbus-daemon --system
|
|
||||||
|
|
||||||
# Create new IQN (iSCSI Qualified Name)
|
# Create new IQN (iSCSI Qualified Name)
|
||||||
flock $LOCK targetcli /iscsi create "$IQN"
|
targetcli /iscsi create "$IQN"
|
||||||
# Run it in demo mode, i.e. no authentication
|
# Run it in demo mode, i.e. no authentication
|
||||||
flock $LOCK targetcli /iscsi/"$IQN"/tpg1 set attribute authentication=0 demo_mode_write_protect=0 generate_node_acls=1 cache_dynamic_acls=1
|
targetcli /iscsi/"$IQN"/tpg1 set attribute authentication=0 demo_mode_write_protect=0 generate_node_acls=1 cache_dynamic_acls=1
|
||||||
|
|
||||||
# Create unique "block volume" (i.e. flat file) on the *host*.
|
# Create unique "block volume" (i.e. flat file) on the *host*.
|
||||||
# Having it in the container confuses kernel from some reason
|
# Having it in the container confuses kernel from some reason
|
||||||
@ -44,8 +36,8 @@ function start()
|
|||||||
cp /block /srv/iscsi/"$IQN"
|
cp /block /srv/iscsi/"$IQN"
|
||||||
|
|
||||||
# Make the block volume available through our IQN as LUN 0
|
# Make the block volume available through our IQN as LUN 0
|
||||||
flock $LOCK targetcli /backstores/fileio create block-"$IQN" /srv/iscsi/"$IQN"
|
targetcli /backstores/fileio create block-"$IQN" /srv/iscsi/"$IQN"
|
||||||
flock $LOCK targetcli /iscsi/"$IQN"/tpg1/luns create /backstores/fileio/block-"$IQN"
|
targetcli /iscsi/"$IQN"/tpg1/luns create /backstores/fileio/block-"$IQN"
|
||||||
|
|
||||||
echo "iscsi target started"
|
echo "iscsi target started"
|
||||||
}
|
}
|
||||||
@ -54,10 +46,10 @@ function stop()
|
|||||||
{
|
{
|
||||||
echo "stopping iscsi target"
|
echo "stopping iscsi target"
|
||||||
# Remove IQN
|
# Remove IQN
|
||||||
flock $LOCK targetcli /iscsi/"$IQN"/tpg1/luns/ delete 0
|
targetcli /iscsi/"$IQN"/tpg1/luns/ delete 0
|
||||||
flock $LOCK targetcli /iscsi delete "$IQN"
|
targetcli /iscsi delete "$IQN"
|
||||||
# Remove block device mapping
|
# Remove block device mapping
|
||||||
flock $LOCK targetcli /backstores/fileio delete block-"$IQN"
|
targetcli /backstores/fileio delete block-"$IQN"
|
||||||
/bin/rm -f /srv/iscsi/"$IQN"
|
/bin/rm -f /srv/iscsi/"$IQN"
|
||||||
echo "iscsi target stopped"
|
echo "iscsi target stopped"
|
||||||
exit 0
|
exit 0
|
||||||
|
Loading…
Reference in New Issue
Block a user