[coreos] Allow k8s cluster without floating ip

This patch allows k8s coreos cluster to be created
without Floating IP resources.

Depends-on: I51feb6ccdc0fab91a591568866e6801f2bbb319b
Change-Id: Ifc8b6bde5a9bc3dd8c7e965e0450e2aa0d243263
Partially-Implements: blueprint bay-with-no-floating-ips
Closes-Bug: #1630189
Partial-Bug: #1490334
This commit is contained in:
yatin 2016-10-05 10:51:40 +05:30
parent 556084ebad
commit 40c1e2de6f
6 changed files with 37 additions and 14 deletions

View File

@ -4,7 +4,7 @@ resource_registry:
"Magnum::FloatingIPAddressSwitcher": "../fragments/floating_ip_address_switcher_private.yaml"
# with_master_lb.yaml
"Magnum::Optional::Neutron::Pool::FloatingIP": "OS::Heat::None"
"Magnum::Optional::Neutron::FloatingIP": "OS::Heat::None"
# kubemaster.yaml
"Magnum::Optional::KubeMaster::Neutron::FloatingIP": "OS::Heat::None"

View File

@ -37,10 +37,21 @@ class CoreOSK8sTemplateDefinition(k8s_template_def.K8sTemplateDefinition):
cluster_attr='master_addresses')
def get_env_files(self, cluster_template):
env_files = []
if cluster_template.master_lb_enabled:
return [template_def.COMMON_ENV_PATH + 'with_master_lb.yaml']
env_files.append(
template_def.COMMON_ENV_PATH + 'with_master_lb.yaml')
else:
return [template_def.COMMON_ENV_PATH + 'no_master_lb.yaml']
env_files.append(
template_def.COMMON_ENV_PATH + 'no_master_lb.yaml')
if cluster_template.floating_ip_enabled:
env_files.append(
template_def.COMMON_ENV_PATH + 'enable_floating_ip.yaml')
else:
env_files.append(
template_def.COMMON_ENV_PATH + 'disable_floating_ip.yaml')
return env_files
@property
def driver_module_path(self):

View File

@ -308,7 +308,7 @@ resources:
# LBaaS pool depending on whether LBaaS is enabled for the cluster.
#
api_address_switch:
api_address_lb_switch:
type: Magnum::ApiGatewaySwitcher
properties:
pool_public_ip: {get_attr: [api_pool_floating, floating_ip_address]}
@ -316,12 +316,24 @@ resources:
master_public_ip: {get_attr: [kube_masters, resource.0.kube_master_external_ip]}
master_private_ip: {get_attr: [kube_masters, resource.0.kube_master_ip]}
etcd_address_switch:
etcd_address_lb_switch:
type: Magnum::ApiGatewaySwitcher
properties:
pool_private_ip: {get_attr: [etcd_loadbalancer, vip_address]}
master_private_ip: {get_attr: [kube_masters, resource.0.kube_master_ip]}
######################################################################
#
# resources that expose the IPs of either floating ip or a given
# fixed ip depending on whether FloatingIP is enabled for the cluster.
#
api_address_floating_switch:
type: Magnum::FloatingIPAddressSwitcher
properties:
public_ip: {get_attr: [api_address_lb_switch, public_ip]}
private_ip: {get_attr: [api_address_lb_switch, private_ip]}
######################################################################
#
# kubernetes masters. This is a resource group that will create
@ -391,7 +403,7 @@ resources:
fixed_network: {get_resource: fixed_network}
fixed_subnet: {get_resource: fixed_subnet}
flannel_network_cidr: {get_param: flannel_network_cidr}
kube_master_ip: {get_attr: [api_address_switch, private_ip]}
kube_master_ip: {get_attr: [api_address_lb_switch, private_ip]}
external_network: {get_param: external_network}
kube_allow_priv: {get_param: kube_allow_priv}
network_driver: {get_param: network_driver}
@ -401,7 +413,7 @@ resources:
https_proxy: {get_param: https_proxy}
no_proxy: {get_param: no_proxy}
kube_version: {get_param: kube_version}
etcd_server_ip: {get_attr: [etcd_address_switch, private_ip]}
etcd_server_ip: {get_attr: [etcd_address_lb_switch, private_ip]}
wait_condition_timeout: {get_param: wait_condition_timeout}
cluster_uuid: {get_param: cluster_uuid}
magnum_url: {get_param: magnum_url}
@ -417,7 +429,7 @@ outputs:
str_replace:
template: api_ip_address
params:
api_ip_address: {get_attr: [api_address_switch, public_ip]}
api_ip_address: {get_attr: [api_address_floating_switch, ip_address]}
description: >
This is the API endpoint of the Kubernetes cluster. Use this to access
the Kubernetes API.

View File

@ -246,8 +246,6 @@ resources:
"$TRUSTEE_PASSWORD": {get_param: trustee_password}
"$TRUST_ID": {get_param: trust_id}
"$AUTH_URL": {get_param: auth_url}
"$KUBE_API_PUBLIC_ADDRESS": {get_attr: [kube_master_floating, floating_ip_address]}
"$KUBE_API_PRIVATE_ADDRESS": {get_attr: [kube_master_eth0, fixed_ips, 0, ip_address]}
configure_etcd:
type: OS::Heat::SoftwareConfig
@ -422,7 +420,7 @@ resources:
replacement_policy: AUTO
kube_master_floating:
type: OS::Neutron::FloatingIP
type: Magnum::Optional::KubeMaster::Neutron::FloatingIP
properties:
floating_network: {get_param: external_network}
port_id: {get_resource: kube_master_eth0}

View File

@ -287,7 +287,7 @@ resources:
replacement_policy: AUTO
kube_minion_floating:
type: OS::Neutron::FloatingIP
type: Magnum::Optional::KubeMinion::Neutron::FloatingIP
properties:
floating_network: {get_param: external_network}
port_id: {get_resource: kube_minion_eth0}

View File

@ -317,7 +317,8 @@ class TestClusterConductorWithK8s(base.TestCase):
}
self.assertEqual(expected, definition)
self.assertEqual(
['../../common/templates/environments/no_master_lb.yaml'],
['../../common/templates/environments/no_master_lb.yaml',
'../../common/templates/environments/disable_floating_ip.yaml'],
env_files)
@patch('requests.get')
@ -374,7 +375,8 @@ class TestClusterConductorWithK8s(base.TestCase):
}
self.assertEqual(expected, definition)
self.assertEqual(
['../../common/templates/environments/no_master_lb.yaml'],
['../../common/templates/environments/no_master_lb.yaml',
'../../common/templates/environments/disable_floating_ip.yaml'],
env_files)
@patch('requests.get')