What do I mean by saying I need a customized KVM?
1. A way to get the external DHCP IP address to the KVM
2. A qcow2 image modified maybe?
3. Multiple network nics with specific needs, ie over vlan, host only etc.
4. Use specific nic cards ie for DPDK reasons
etc etc.
The above are some of my reasons I moved out from Vagrant etc.
I have a Vagrant file which can pretty much use a yaml file to create a set of KVM's with some option to nics. But as usual more than that is required.
Here in I will state (for my own good) steps to do what exactly I want -
Network
I want two nics, one external bridged so that others on the LAN can access my VM directly via an IP (assuming the general LAN has a DHCP server with free IP addresses and is freely giving those IP addresses, if your administrators have mac binded the dhcp ip addresses, then the only way you can get this functionality is the SNAT way)
Disable Network Manager. How?
Create a manual Bridge via brctl and link with a physical network -
1. A way to get the external DHCP IP address to the KVM
2. A qcow2 image modified maybe?
3. Multiple network nics with specific needs, ie over vlan, host only etc.
4. Use specific nic cards ie for DPDK reasons
etc etc.
The above are some of my reasons I moved out from Vagrant etc.
I have a Vagrant file which can pretty much use a yaml file to create a set of KVM's with some option to nics. But as usual more than that is required.
Here in I will state (for my own good) steps to do what exactly I want -
Network
I want two nics, one external bridged so that others on the LAN can access my VM directly via an IP (assuming the general LAN has a DHCP server with free IP addresses and is freely giving those IP addresses, if your administrators have mac binded the dhcp ip addresses, then the only way you can get this functionality is the SNAT way)
brctl addbr <bridge_name>OR via ifcfg-
brctl addif <bridge_name> <phys_net -- connected to the local lan of the DHCP server>
ip link set <phys_net> up
ip link set <bridge_name> up
ifup <bridge_name> (we will call this brex, for further use)
#> cat /etc/sysconfig/network-scripts/ifcfg-br0
DEVICE=br0
TYPE=Bridge
DELAY=0
BOOTPROTO=dhcp
ONBOOT=yes
NM_CONTROLLED=no
PERSISTENT_DHCLIENT=yes
DHCLIENT_IGNORE_GATEWAY=no
GATEWAY=10.2.0.254
DNS1=10.2.0.26
DNS2=10.3.0.26
#> cat /etc/sysconfig/network-scripts/ifcfg-eno1
DEVICE="eno1"
ONBOOT=yes
UUID="f423eb24-2c1d-49d1-acdf-9a63ea867ff4"
IPV6INIT=no
BOOTPROTO=none
TYPE=Ethernet
NAME="eno1"
BRIDGE=br0
net.bridge.bridge-nf-call-arptables = 0
net.bridge.bridge-nf-call-ip6tables = 0
net.bridge.bridge-nf-call-iptables = 0
(without DHCP)
cat > /tmp/hostonly.xml <<EOF
<network>
<name>hostonly</name>
<ip address="192.168.17.254" netmask="255.255.255.0"/>
</network>
EOF
virsh net-define /tmp/hostonly.xml
virsh net-autostart hostonly
virsh net-start hostonly
virt-install pass the bridge for network - Below will set two nics inside your VM, 1st one should be the hostonly nic, can be used for provisioning openstack clusters. 2nd one is the external access nic.virt-install <blah.. blah..> --network network:virbr0 --network network:brex (A complete virt-install is given below)
VM Setup
yum install libvirt qemu-kvm virt-manager virt-install libguestfs-tools xorg-x11-apps xauth virt-viewer libguestfs-xfs -y
mkdir -p /vmimages/{qcow2-arch,qcow2-kvm}
cd /vmimages/qcow2-kvm/ (lets stay here and use all the commands from here)
wget -c 'http://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud.qcow2'
mv CentOS-7-x86_64-GenericCloud.qcow2 /vmimages/qcow2-arch/
virt-filesystems --long -h --all -a ../qcow2-arch/CentOS-7-x86_64-GenericCloud.qcow2
Name Type VFS Label MBR Size Parent
/dev/sda1 filesystem xfs - - 8.0G -
/dev/sda1 partition - - 83 8.0G /dev/sda
/dev/sda device - - - 8.0G -
qemu-img create -f qcow2 centos7.2-kvm1.qcow2 40G
virt-resize --expand /dev/sda1 ../qcow2-arch/CentOS-7-x86_64-GenericCloud.qcow2 centos7.2-kvm1.qcow2
virt-filesystems --long -h --all -a centos7.2-kvm1.qcow2
Name Type VFS Label MBR Size Parent
/dev/sda1 filesystem xfs - - 40G -
/dev/sda1 partition - - 83 40G /dev/sda
/dev/sda device - - - 40G -
qemu-img create -f qcow2 -b centos7.2-kvm1.qcow2 packstack-node1.qcow2 <-- choose a name of the backup file intutively so that it reflects the node you would be running.
Here we are removing cloud-init from the qcow2 image (its a nuisance, unless this image is being spawned in the cloud)
virt-customize -a packstack-node1.qcow2 --run-command 'yum remove cloud-init* -y'Here we are setting a very complex password!
virt-customize -a packstack-node1.qcow2 --root-password password:Cent05
Finally! Create VM and start
virt-install --ram 8096 --vcpus 4 --os-variant centos7.0 --disk path=/vmimages/qcow2-kvm/packstack-node1.qcow2,device=disk,bus=virtio,format=qcow2 --import --noautoconsole --vnc --network bridge:virbr1,model=e1000 --network bridge:br0,model=e1000 --cpu SandyBridge,+vmx --dry-run --print-xml --name packstacknode1 > packstacknode1.xml
virsh define packstacknode1.xml
virsh start packstacknode1
virsh console packstacknode1
cat << EOF > /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=static
NM_CONTROLLED=no
IPADDR=192.168.17.101
NETMASK=255.255.255.0
EOF
cat << EOF > /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
ONBOOT=yes
BOOTPROTO=dhcp
NM_CONTROLLED=no
DEFROUTE=yes
EOF
hostnamectl set-hostname --static packstacknode1.redhat.localYay! you have a shiny new packstack node with e1000 ethernet nics, which supports ovs-dpdk
check 'ip a l' you should be able to connect to VM from your laptop on both the IP addresses.
From outside your laptop, you should be able to access the VM over LAN
No comments:
Post a Comment