Hi all
We are configuring a new cloud infrastructure and we have enabled kerberos authentication in our hypervisors. The good thing is that libvirtd also supports kerberos auth through tcp sasl
.
That means that we can connect and migrate VMs using virsh
and kerberos authentication to increase our internal security. The point is that kerberos requires a valid ticket, if your system is already configured is quite easy to generate one, you only need to execute in the hyp as oneadmin:
kinit -k -l 2h -t /etc/libvirt/krb5.tab
to generate a ticket valid for 2 hours, enough to migrate any VM to another hyp. The question is, how we can do this automatically from OpenNebula before the live migration process starts? (we only need it for VM live migrations).
It seems that you can set your own VMM drivers and set oned.conf to use them like this to be used for migrate action (please correct me if I’m wrong):
VM_MAD = [
name = “kvm”,
executable = “one_vmm_exec”,
arguments = “-t 15 -r 0 -l migrate=migrate_krb5 kvm”,
default = “vmm_exec/vmm_exec_kvm.conf”,
type = “kvm” ]
So we have modified /var/lib/one/remotes/vmm/kvm/kvmrc
to include a new variable to set our keytab for libvirtd:
export LANG=C
export LIBVIRT_KEYTAB=/etc/libvirt/krb5.tab
export LIBVIRT_URI=qemu:///system
export QEMU_PROTOCOL=qemu+tcp
export SHUTDOWN_TIMEOUT=300
and our adhoc migrate script in /var/lib/one/remotes/vmm/kvm/migrate_krb5
looks like:
source $(dirname $0)/kvmrc
source $(dirname $0)/…/…/scripts_common.sh
deploy_id=$1
dest_host=$2
klist
exit=$?
if [ -n $LIBVIRT_KEYTAB ] && [ $exit -eq 1 ]
then
kinit -k -l 1h -t $LIBVIRT_KEYTAB libvirt/$(hostname -f)
fi
exec_and_log “virsh --connect $LIBVIRT_URI migrate --live $MIGRATE_OPTIONS $deploy_id $QEMU_PROTOCOL://$dest_host/system”
“Could not migrate $deploy_id to $dest_host”
The migrate
script was modified to detect if is still available a valid ticket, if not is created a new one…
The problem is that this script is executed locally in the ONE server not in hypA to migrate a VM to hypB, the other option is to change directly the migrate script provided by OpenNebula, but it will be overwritten in the nex upgrade and we don’t want that.
Do you know which options do we have and which is the best? It will be great to have the possibility to execute a external script before any official VMM script but in the hypervisors not only locally, any suggestion? (I don’t know if this option is already implemented…)
Thanks in advance!
Alvaro