{"id":37022,"date":"2017-03-27T12:10:02","date_gmt":"2017-03-27T09:10:02","guid":{"rendered":"https:\/\/cloudbase.it\/?p=37022"},"modified":"2017-03-27T12:36:02","modified_gmt":"2017-03-27T09:36:02","slug":"openstack-kolla-hyper-v","status":"publish","type":"post","link":"https:\/\/cloudbase.it\/openstack-kolla-hyper-v\/","title":{"rendered":"Deploying OpenStack using Docker containers with Hyper-V and Kolla"},"content":{"rendered":"
OpenStack is a great technology, but it can be a bit cumbersome to deploy and manage without the proper tools. One easy solution\u00a0to address this issue is to deploy OpenStack services using pre-built Docker containers.<\/p>\n
Kolla is a set of deployment tools for\u00a0OpenStack, consisting in the Kolla<\/a> project itself, for generating OpenStack Docker images, and “deliverables” projects, to deploy the Docker containers and thus OpenStack. The most mature deliverable is kolla-ansible<\/a>, which, as the name implies, uses\u00a0Ansible playbooks to automate\u00a0the deployment. The project documentation can be found here<\/a>.<\/p>\n <\/p>\n On the Windows host, we need a VM to host the Linux OpenStack controller. For this purpose I created\u00a0an Ubuntu 16.04 VM with\u00a08GB of RAM, 4 virtual cores and 20GB of disk. All the controller\u00a0services run here and are deployed with Kolla in Docker containers. Last but not least, the same Hyper-V also serves as a compute host for the OpenStack deployment. This is achieved by installing our\u00a0Cloudbase OpenStack components<\/a>. Additional Hyper-V compute nodes can be added later as needed.<\/p>\n <\/p>\n On the Hyper-V host, I am going to need 2 virtual switches\u00a0that are going to be connected\u00a0to the OpenStack controller VM. ext-net<\/strong>\u00a0is\u00a0the external\u00a0network, it is bridged to the Windows physical external interface. I will use this network also for the management of the VM. data-net<\/strong>\u00a0is the\u00a0data network, which can be a simple private virtual switch for now (an external one is needed only when adding more compute nodes).<\/p>\n On\u00a0the OpenStack Controller VM there are 3 interfaces. The first two, eth0<\/strong> and eth1<\/strong> are connected to the external\u00a0network. The former is used for management (SSH, etc) and the latter is used by OpenStack for external traffic, managed by Open vSwitch. Finally, eth2<\/strong> is the data\/overlay network. It is used for tenant traffic between the instances and the Neutron components in the controller.<\/p>\n <\/p>\n eth1<\/strong> and eth2<\/strong> do not have an IP and are\u00a0set as “manual” in \/etc\/network\/interfaces. The reason for this is that they are managed\u00a0by OpenvSwitch.\u00a0Also on these interfaces I need to enable MAC address spoofing (“Advanced Features” tab on the adapter).<\/p>\n The scripts that I will be using configures the Linux network interfaces automatically so I don’t need to bother with that now. The only interface I have already configured is eth0<\/strong> so I can SSH\u00a0into the machine.<\/p>\n <\/p>\n I am going to clone a repository that contains the scripts for the Kolla Openstack deployment, which can be found here<\/a>. At the end of the deployment it will also create some common flavors, a Cirros VHDX Cinder image, a Neutron virtual router and 2 networks, one external (flat) and one private for tenants (VLAN based).<\/p>\n To begin with, we are going to configure the management and external network details by setting\u00a0some variables in\u00a0deploy_openstack.sh<\/em>:<\/p>\n As you can see, I am using the same subnet for management and external floating IPs.<\/p>\n Now I can run the deployment script. I am using the Linux “time” command to see how long the deployment will take:<\/p>\n The first thing this script will do is to pull the Docker images for each OpenStack service. The great thing with Kolla is that you just need to create the images once, sparing significant time during deployment. This reduces significantly potential errors due to updated dependencies as the container images already contain all the required components. The images that I am going to use during the deployment are available\u00a0here<\/a>. Feel free to create your own, just follow the documentation<\/a>.<\/p>\n After the deployment is finished, I have a fully functional OpenStack controller. It took around 13 minutes to deploy, that’s quite fast if you ask me.<\/p>\n <\/p>\n By running\u00a0“sudo\u00a0docker ps”<\/em>\u00a0I can see all the containers running.<\/p>\n Admin credentials can be sourced now:<\/p>\n The only thing left to do is to deploy the OpenStack\u00a0Hyper-V components.<\/p>\n <\/p>\n First, I’m going to edit the Ansible inventory to add my\u00a0Hyper-V host (simply named “hyperv-host” in this post) as well as the credentials needed to access it:<\/p>\n An HTTPS WinRM listener needs to be configured on the Hyper-V host, which\u00a0can be easily created with this PowerShell script<\/a>.<\/p>\n Now, I’m going to run the scripts that will fully deploy and configure Nova compute on Hyper-V. The first\u00a0parameter\u00a0is the data bridge that I configured earlier, data-net<\/strong>. The third and fourth parameters are are the Hyper-V credentials that FreeRDP will need to use in order to access the Hyper-V host when connecting to a Nova instance console.<\/p>\n Next, I need to set trunk mode for my OpenStack controller. There are two reasons for this: first, I have a tenant network with type VLAN, and second, the controller is\u00a0a VM in Hyper-V, so the hypervisor needs to allow VLAN tagged packets on\u00a0the controller VM data interface. Start an elevated PowerShell and run:<\/p>\n “openstack-controller” is the name of the controller VM in Hyper-V.<\/p>\n <\/p>\n Now I have everything in place to start playing around. I will boot a VM and test its connectivity to the Internet.<\/p>\n Taking a look in Horizon:<\/p>\n <\/p>\n The FreeRDP\u00a0console access from Horizon works as well. I can also access the\u00a0VM directly from Hyper-v if needed.<\/p>\nHyper-V setup<\/h2>\n
Networking setup<\/h3>\n
<\/a><\/p>\n
<\/a><\/p>\nOpenStack controller deployment<\/strong><\/h2>\n
git clone https:\/\/github.com\/cloudbase\/kolla-resources.git\r\ncd kolla-resources<\/pre>\n
vim deploy_openstack.sh<\/pre>\n
# deploy_openstack.sh\r\nMGMT_IP=192.168.0.60\r\nMGMT_NETMASK=255.255.255.0\r\nMGMT_GATEWAY=192.168.0.1\r\nMGMT_DNS=\"8.8.8.8\"\r\n\r\n# neutron external network information\r\nFIP_START=192.168.0.80\r\nFIP_END=192.168.0.90\r\nFIP_GATEWAY=192.168.0.1\r\nFIP_CIDR=192.168.0.0\/24\r\nTENANT_NET_DNS=\"8.8.8.8\"\r\n\r\n# used for HAProxy\r\nKOLLA_INTERNAL_VIP_ADDRESS=192.168.0.91<\/pre>\n
time sudo .\/deploy_openstack.sh<\/pre>\n
real\t12m28.716s\r\nuser\t3m7.296s\r\nsys 1m4.428s<\/pre>\n
<\/a><\/p>\nsource \/etc\/kolla\/admin-openrc.sh<\/pre>\n
Nova Hyper-V compute node deployment<\/h2>\n
vim hyperv_inventory<\/pre>\n
[hyperv]\r\nhyperv-host\r\n\r\n[hyperv:vars]\r\nansible_ssh_host=192.168.0.120\r\nansible_user=Administrator\r\nansible_password=Passw0rd\r\nansible_port=5986\r\nansible_connection=winrm\r\nansible_winrm_server_cert_validation=ignore<\/pre>\n
sudo .\/deploy_hyperv_compute_playbook.sh data-net Administrator Passw0rd<\/pre>\n
Set-VMNetworkAdapterVlan -Trunk -AllowedVlanIdList 500-2000 -NativeVlanId 0 openstack-controller<\/pre>\n
Spawning a VM<\/h2>\n
NETID=`neutron net-show private-net | awk '{if (NR == 5) {print $4}}'`\r\nnova boot --flavor m1.nano \\\r\n--nic net-id=$NETID \\\r\n--image cirros-gen1-vhdx hyperv-vm1<\/pre>\n
<\/a><\/p>\n