kubespray / kubespray-cli

Easy to use command line tool for kubernetes deployment with kubespray
GNU General Public License v3.0
252 stars 62 forks source link

Kubespray in Openstack does not allocate floating IP #119

Open prateek2408 opened 6 years ago

prateek2408 commented 6 years ago

Even after giving "--floating_ip" in the "kubesrpay openstack" command the Virtual machines that are created in openstack Cloud does not get a floating IP.

Also there is no option to provide the name of external network from which the floating IP would be taken and associated to Virtual machines . Setting auto_ip to true does not provide floating IP to the VM's

snippet-

                       'flavor': self.options['%s_flavor' % role],
                       'key_name': self.options['sshkey'],
                       'region_name': self.options['os_region_name'],
                       'auto_ip': self.options['floating_ip'],
                       'security_groups': [os_security_group_name],
                       'nics': 'port-name={{ item }}',

'image': self.options['image']

============================================================

Openstack Version - Mitaka Kubespray Version - 2.3.0

prateek2408 commented 6 years ago

The solution to this problem is to use floatingip_pools and provide the name of external network provided by user either is CLI or kubesrpay yaml file.

Here are the proposed changes in the cloud.py-

=================================

    if self.options['floating_ip']:
        ip_type = 'public'
        auto_ans = 'yes'
        pool_name = 'external' 

Here external pool would be replaced with the name of external network that is present in the Openstack environment, can be taken as command line argument or from config

=================================

================================= self.pbook_content[0]['tasks'].append( {'name': 'Provision OS %s instances' % role, 'os_server': { 'auth': openstack_auth, 'name': '{{item}}', 'state': 'present', 'flavor': self.options['%s_flavor' % role], 'key_name': self.options['sshkey'], 'region_name': self.options['os_region_name'], #'auto_ip': auto_ans, 'floating_ip_pools': pool_name, 'security_groups': [os_security_groupname], 'nics': 'port-name={{ item }}', 'image': self.options['image']}, 'register': 'os%s' % role, 'with_items': os_instance_names}

============================================================