Allow multimaster lb with no floating ip option

Currently the option of selecting no floating IP will not apply to
a multimaster configuration and loadbalancers will be expected to use
floating IPs. This patch allows the floating IP resources to be
disabled among the load balancers.

Task: 22121
Story: 2002557
Change-Id: I8f96fba8aa41319ac209baedd9d3a927aad0eb91
(cherry picked from commit 393e70f0b0)
This commit is contained in:
Jim Bach 2018-06-11 18:13:04 -04:00 committed by Hieu LE
parent ad8b87e6fd
commit 8b9b6b64d8
9 changed files with 72 additions and 10 deletions

3
.gitignore vendored
View File

@ -21,7 +21,8 @@ lib64
pip-log.txt
# Unit test / coverage reports
.coverage
!.coveragerc
.coverage*
cover
cover-master
.tox

View File

@ -0,0 +1,4 @@
# disables the use of floating ip on the load balancer
resource_registry:
"Magnum::Optional::Neutron::LBaaS::FloatingIP": "OS::Heat::None"

View File

@ -0,0 +1,4 @@
# enables the use of floating ip on the load balancer
resource_registry:
"Magnum::Optional::Neutron::LBaaS::FloatingIP": "OS::Neutron::FloatingIP"

View File

@ -8,7 +8,6 @@ resource_registry:
"Magnum::Optional::Neutron::LBaaS::Listener": "OS::Neutron::LBaaS::Listener"
"Magnum::Optional::Neutron::LBaaS::Pool": "OS::Neutron::LBaaS::Pool"
"Magnum::Optional::Neutron::LBaaS::HealthMonitor": "OS::Neutron::LBaaS::HealthMonitor"
"Magnum::Optional::Neutron::LBaaS::FloatingIP": "OS::Neutron::FloatingIP"
# Master node template
"Magnum::Optional::Neutron::LBaaS::PoolMember": "OS::Neutron::LBaaS::PoolMember"

View File

@ -8,7 +8,6 @@ resource_registry:
"Magnum::Optional::Neutron::LBaaS::Listener": "OS::Octavia::Listener"
"Magnum::Optional::Neutron::LBaaS::Pool": "OS::Octavia::Pool"
"Magnum::Optional::Neutron::LBaaS::HealthMonitor": "OS::Octavia::HealthMonitor"
"Magnum::Optional::Neutron::LBaaS::FloatingIP": "OS::Neutron::FloatingIP"
# Master node template
"Magnum::Optional::Neutron::LBaaS::PoolMember": "OS::Octavia::PoolMember"

View File

@ -16,6 +16,7 @@
. /etc/sysconfig/heat-params
set -x
set -o errexit
set -o nounset
set -o pipefail
@ -30,28 +31,36 @@ else
VERIFY_CA="-k"
fi
if [[ -z "${KUBE_NODE_PUBLIC_IP}" ]]; then
KUBE_NODE_PUBLIC_IP=$(curl -s http://169.254.169.254/latest/meta-data/public-ipv4)
fi
if [[ -z "${KUBE_NODE_IP}" ]]; then
if [ -z "${KUBE_NODE_IP}" ]; then
KUBE_NODE_IP=$(curl -s http://169.254.169.254/latest/meta-data/local-ipv4)
fi
sans="IP:${KUBE_NODE_PUBLIC_IP},IP:${KUBE_NODE_IP}"
sans="IP:${KUBE_NODE_IP}"
if [ -z "${KUBE_NODE_PUBLIC_IP}" ]; then
KUBE_NODE_PUBLIC_IP=$(curl -s http://169.254.169.254/latest/meta-data/public-ipv4)
fi
if [ -n "${KUBE_NODE_PUBLIC_IP}" ]; then
sans="${sans},IP:${KUBE_NODE_PUBLIC_IP}"
fi
if [ "${KUBE_NODE_PUBLIC_IP}" != "${KUBE_API_PUBLIC_ADDRESS}" ] \
&& [ -n "${KUBE_API_PUBLIC_ADDRESS}" ]; then
sans="${sans},IP:${KUBE_API_PUBLIC_ADDRESS}"
fi
if [ "${KUBE_NODE_IP}" != "${KUBE_API_PRIVATE_ADDRESS}" ] \
&& [ -n "${KUBE_API_PRIVATE_ADDRESS}" ]; then
sans="${sans},IP:${KUBE_API_PRIVATE_ADDRESS}"
fi
MASTER_HOSTNAME=${MASTER_HOSTNAME:-}
if [[ -n "${MASTER_HOSTNAME}" ]]; then
if [ -n "${MASTER_HOSTNAME}" ]; then
sans="${sans},DNS:${MASTER_HOSTNAME}"
fi
if [[ -n "${ETCD_LB_VIP}" ]]; then
if [ -n "${ETCD_LB_VIP}" ]; then
sans="${sans},IP:${ETCD_LB_VIP}"
fi
@ -63,6 +72,7 @@ sans="${sans},IP:${KUBE_SERVICE_IP}"
sans="${sans},DNS:kubernetes,DNS:kubernetes.default,DNS:kubernetes.default.svc,DNS:kubernetes.default.svc.cluster.local"
echo "sans is ${sans}"
cert_dir=/etc/kubernetes/certs
mkdir -p "$cert_dir"
CA_CERT=$cert_dir/ca.crt

View File

@ -354,8 +354,12 @@ def add_etcd_volume_env_file(env_files, cluster_template):
def add_fip_env_file(env_files, cluster_template):
if cluster_template.floating_ip_enabled:
env_files.append(COMMON_ENV_PATH + 'enable_floating_ip.yaml')
if cluster_template.master_lb_enabled:
env_files.append(COMMON_ENV_PATH + 'enable_lb_floating_ip.yaml')
else:
env_files.append(COMMON_ENV_PATH + 'disable_floating_ip.yaml')
if cluster_template.master_lb_enabled:
env_files.append(COMMON_ENV_PATH + 'disable_lb_floating_ip.yaml')
def add_priv_net_env_file(env_files, cluster_template):

View File

@ -170,6 +170,42 @@ class TemplateDefinitionTestCase(base.TestCase):
self.assertIn(mock_mapping_type.return_value,
definition.output_mappings)
def test_add_fip_env_lb_disabled_with_fp(self):
mock_cluster_template = mock.MagicMock(floating_ip_enabled=True,
master_lb_enabled=False)
env_files = []
cmn_tdef.add_fip_env_file(env_files, mock_cluster_template)
self.assertEqual([cmn_tdef.COMMON_ENV_PATH +
'enable_floating_ip.yaml'], env_files)
def test_add_fip_env_lb_enabled_with_fp(self):
mock_cluster_template = mock.MagicMock(floating_ip_enabled=True,
master_lb_enabled=True)
env_files = []
cmn_tdef.add_fip_env_file(env_files, mock_cluster_template)
self.assertEqual([cmn_tdef.COMMON_ENV_PATH +
'enable_floating_ip.yaml',
cmn_tdef.COMMON_ENV_PATH +
'enable_lb_floating_ip.yaml'], env_files)
def test_add_fip_env_lb_disabled_without_fp(self):
mock_cluster_template = mock.MagicMock(floating_ip_enabled=False,
master_lb_enabled=False)
env_files = []
cmn_tdef.add_fip_env_file(env_files, mock_cluster_template)
self.assertEqual([cmn_tdef.COMMON_ENV_PATH +
'disable_floating_ip.yaml'], env_files)
def test_add_fip_env_lb_enabled_without_fp(self):
mock_cluster_template = mock.MagicMock(floating_ip_enabled=False,
master_lb_enabled=True)
env_files = []
cmn_tdef.add_fip_env_file(env_files, mock_cluster_template)
self.assertEqual([cmn_tdef.COMMON_ENV_PATH +
'disable_floating_ip.yaml',
cmn_tdef.COMMON_ENV_PATH +
'disable_lb_floating_ip.yaml'], env_files)
@six.add_metaclass(abc.ABCMeta)
class BaseTemplateDefinitionTestCase(base.TestCase):

View File

@ -0,0 +1,5 @@
---
features:
- |
This is allowing no floating IP to be usable with a multimaster
configuration in terms of load balancers.