diff --git a/contrib/drivers/k8s_opensuse_v1/template_def.py b/contrib/drivers/k8s_opensuse_v1/template_def.py index c828278a49..d2c18b2cd3 100644 --- a/contrib/drivers/k8s_opensuse_v1/template_def.py +++ b/contrib/drivers/k8s_opensuse_v1/template_def.py @@ -16,6 +16,7 @@ import os import magnum.conf from magnum.drivers.common import k8s_template_def +from magnum.drivers.common import template_def CONF = magnum.conf.CONF @@ -49,6 +50,12 @@ class JeOSK8sTemplateDefinition(k8s_template_def.K8sTemplateDefinition): extra_params=extra_params, **kwargs) + def get_env_files(self, cluster_template): + if cluster_template.master_lb_enabled: + return [template_def.COMMON_ENV_PATH + 'with_master_lb.yaml'] + else: + return [template_def.COMMON_ENV_PATH + 'no_master_lb.yaml'] + @property def template_path(self): return os.path.join(os.path.dirname(os.path.realpath(__file__)), diff --git a/contrib/drivers/k8s_opensuse_v1/templates/kubecluster.yaml b/contrib/drivers/k8s_opensuse_v1/templates/kubecluster.yaml index cd6c029449..5215467a9b 100644 --- a/contrib/drivers/k8s_opensuse_v1/templates/kubecluster.yaml +++ b/contrib/drivers/k8s_opensuse_v1/templates/kubecluster.yaml @@ -354,49 +354,89 @@ resources: # load balancers. # + api_loadbalancer: + type: Magnum::Optional::Neutron::LBaaS::LoadBalancer + properties: + vip_subnet: {get_resource: fixed_subnet} + + api_listener: + type: Magnum::Optional::Neutron::LBaaS::Listener + properties: + loadbalancer: {get_resource: api_loadbalancer} + protocol: {get_param: loadbalancing_protocol} + protocol_port: {get_param: kubernetes_port} + + api_pool: + type: Magnum::Optional::Neutron::LBaaS::Pool + properties: + lb_algorithm: ROUND_ROBIN + listener: {get_resource: api_listener} + protocol: {get_param: loadbalancing_protocol} + api_monitor: - type: OS::Neutron::HealthMonitor + type: Magnum::Optional::Neutron::LBaaS::HealthMonitor properties: type: TCP delay: 5 max_retries: 5 timeout: 5 - - api_pool: - type: OS::Neutron::Pool - properties: - protocol: {get_param: loadbalancing_protocol} - monitors: [{get_resource: api_monitor}] - subnet: {get_resource: fixed_subnet} - lb_method: ROUND_ROBIN - vip: - protocol_port: {get_param: kubernetes_port} + pool: { get_resource: api_pool } api_pool_floating: - type: OS::Neutron::FloatingIP + type: Magnum::Optional::Neutron::FloatingIP depends_on: - extrouter_inside properties: floating_network: {get_param: external_network} - port_id: {get_attr: [api_pool, vip, port_id]} + port_id: {get_attr: [api_loadbalancer, vip_port_id]} + + etcd_loadbalancer: + type: Magnum::Optional::Neutron::LBaaS::LoadBalancer + properties: + vip_subnet: {get_resource: fixed_subnet} + + etcd_listener: + type: Magnum::Optional::Neutron::LBaaS::Listener + properties: + loadbalancer: {get_resource: etcd_loadbalancer} + protocol: HTTP + protocol_port: 2379 + + etcd_pool: + type: Magnum::Optional::Neutron::LBaaS::Pool + properties: + lb_algorithm: ROUND_ROBIN + listener: {get_resource: etcd_listener} + protocol: HTTP etcd_monitor: - type: OS::Neutron::HealthMonitor + type: Magnum::Optional::Neutron::LBaaS::HealthMonitor properties: type: TCP delay: 5 max_retries: 5 timeout: 5 + pool: { get_resource: etcd_pool } - etcd_pool: - type: OS::Neutron::Pool + ###################################################################### + # + # resources that expose the IPs of either the kube master or a given + # LBaaS pool depending on whether LBaaS is enabled for the cluster. + # + + api_address_lb_switch: + type: Magnum::ApiGatewaySwitcher properties: - protocol: HTTP - monitors: [{get_resource: etcd_monitor}] - subnet: {get_resource: fixed_subnet} - lb_method: ROUND_ROBIN - vip: - protocol_port: 2379 + pool_public_ip: {get_attr: [api_pool_floating, floating_ip_address]} + pool_private_ip: {get_attr: [api_loadbalancer, vip_address]} + 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_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]} ###################################################################### # @@ -414,7 +454,7 @@ resources: type: kubemaster.yaml properties: api_public_address: {get_attr: [api_pool_floating, floating_ip_address]} - api_private_address: {get_attr: [api_pool, vip, address]} + api_private_address: {get_attr: [api_loadbalancer, vip_address]} ssh_key_name: {get_param: ssh_key_name} server_image: {get_param: server_image} master_flavor: {get_param: master_flavor} @@ -468,8 +508,8 @@ resources: fixed_network: {get_resource: fixed_network} fixed_subnet: {get_resource: fixed_subnet} network_driver: {get_param: network_driver} - kube_master_ip: {get_attr: [api_pool, vip, address]} - etcd_server_ip: {get_attr: [etcd_pool, vip, address]} + kube_master_ip: {get_attr: [api_address_lb_switch, private_ip]} + etcd_server_ip: {get_attr: [etcd_address_lb_switch, private_ip]} external_network: {get_param: external_network} kube_allow_priv: {get_param: kube_allow_priv} docker_volume_size: {get_param: docker_volume_size} @@ -502,7 +542,7 @@ outputs: str_replace: template: api_ip_address params: - api_ip_address: {get_attr: [api_pool_floating, floating_ip_address]} + api_ip_address: {get_attr: [api_address_switch, public_ip]} 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 2da69d30ce..d2688b2ed4 100644 --- a/contrib/drivers/k8s_opensuse_v1/templates/kubemaster.yaml +++ b/contrib/drivers/k8s_opensuse_v1/templates/kubemaster.yaml @@ -85,10 +85,12 @@ parameters: api_public_address: type: string description: Public IP address of the Kubernetes master server. + default: "" api_private_address: type: string description: Private IP address of the Kubernetes master server. + default: "" http_proxy: type: string @@ -156,6 +158,20 @@ 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 @@ -282,17 +298,19 @@ resources: port_id: {get_resource: kube_master_eth0} api_pool_member: - type: OS::Neutron::PoolMember + type: Magnum::Optional::Neutron::LBaaS::PoolMember properties: - pool_id: {get_param: api_pool_id} + pool: {get_param: api_pool_id} address: {get_attr: [kube_master_eth0, fixed_ips, 0, ip_address]} + subnet: { get_param: fixed_subnet } protocol_port: {get_param: kubernetes_port} etcd_pool_member: - type: OS::Neutron::PoolMember + type: Magnum::Optional::Neutron::LBaaS::PoolMember properties: - pool_id: {get_param: etcd_pool_id} + pool: {get_param: etcd_pool_id} address: {get_attr: [kube_master_eth0, fixed_ips, 0, ip_address]} + subnet: { get_param: fixed_subnet } protocol_port: 2379 outputs: