From 9b10456a5805e0fd6d4ea4108c77a8cebbc4d768 Mon Sep 17 00:00:00 2001 From: yatin Date: Mon, 17 Oct 2016 16:28:59 +0530 Subject: [PATCH] [suse] Allow k8s cluster without floating ip With this patch k8s opensuse cluster can be created without floating ip. Change-Id: Id0da2057bcf6b1ad518fed3aadb7141caddc4955 --- contrib/drivers/k8s_opensuse_v1/template_def.py | 15 +++++++++++++-- .../k8s_opensuse_v1/templates/kubecluster.yaml | 14 +++++++++++++- .../k8s_opensuse_v1/templates/kubemaster.yaml | 16 +--------------- .../k8s_opensuse_v1/templates/kubeminion.yaml | 2 +- 4 files changed, 28 insertions(+), 19 deletions(-) diff --git a/contrib/drivers/k8s_opensuse_v1/template_def.py b/contrib/drivers/k8s_opensuse_v1/template_def.py index d2c18b2cd3..79ffd3508f 100644 --- a/contrib/drivers/k8s_opensuse_v1/template_def.py +++ b/contrib/drivers/k8s_opensuse_v1/template_def.py @@ -51,10 +51,21 @@ class JeOSK8sTemplateDefinition(k8s_template_def.K8sTemplateDefinition): **kwargs) 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 template_path(self): diff --git a/contrib/drivers/k8s_opensuse_v1/templates/kubecluster.yaml b/contrib/drivers/k8s_opensuse_v1/templates/kubecluster.yaml index 5215467a9b..377b0bcc1e 100644 --- a/contrib/drivers/k8s_opensuse_v1/templates/kubecluster.yaml +++ b/contrib/drivers/k8s_opensuse_v1/templates/kubecluster.yaml @@ -438,6 +438,18 @@ resources: 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 @@ -542,7 +554,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 server. Use this to access the Kubernetes API from outside the cluster. diff --git a/contrib/drivers/k8s_opensuse_v1/templates/kubemaster.yaml b/contrib/drivers/k8s_opensuse_v1/templates/kubemaster.yaml index d2688b2ed4..b8316fb1f9 100644 --- a/contrib/drivers/k8s_opensuse_v1/templates/kubemaster.yaml +++ b/contrib/drivers/k8s_opensuse_v1/templates/kubemaster.yaml @@ -158,20 +158,6 @@ resources: handle: {get_resource: master_wait_handle} timeout: {get_param: wait_condition_timeout} - ###################################################################### - # - # resource that exposes the IPs of either the kube master or the API - # LBaaS pool depending on whether LBaaS is enabled for the bay. - # - - api_address_switch: - type: Magnum::ApiGatewaySwitcher - properties: - pool_public_ip: {get_param: api_public_address} - pool_private_ip: {get_param: api_private_address} - master_public_ip: {get_attr: [kube_master_floating, floating_ip_address]} - master_private_ip: {get_attr: [kube_master_eth0, fixed_ips, 0, ip_address]} - ###################################################################### # # software configs. these are components that are combined into @@ -292,7 +278,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} diff --git a/contrib/drivers/k8s_opensuse_v1/templates/kubeminion.yaml b/contrib/drivers/k8s_opensuse_v1/templates/kubeminion.yaml index 88d8bd612e..e1f8ee77c4 100644 --- a/contrib/drivers/k8s_opensuse_v1/templates/kubeminion.yaml +++ b/contrib/drivers/k8s_opensuse_v1/templates/kubeminion.yaml @@ -301,7 +301,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}