Factor out common k8s definitions and mappings
Factor Out common kubernetes template definitions and address mapping from Fedora Atomic, CoreOS and Suse drivers. Partially-Implements: bp bay-drivers Change-Id: Ib172c19acc1303041f7d8d9249df2d9ca1e4ff6f
This commit is contained in:
parent
5476354e65
commit
917bf4e2dd
@ -14,112 +14,13 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from magnum.drivers.common import template_def
|
from magnum.drivers.common import k8s_template_def
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
|
|
||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
KUBE_SECURE_PORT = '6443'
|
|
||||||
KUBE_INSECURE_PORT = '8080'
|
|
||||||
|
|
||||||
|
|
||||||
class K8sApiAddressOutputMapping(template_def.OutputMapping):
|
class JeOSK8sTemplateDefinition(k8s_template_def.K8sTemplateDefinition):
|
||||||
|
|
||||||
def set_output(self, stack, cluster_template, bay):
|
|
||||||
if self.bay_attr is None:
|
|
||||||
return
|
|
||||||
|
|
||||||
output_value = self.get_output_value(stack)
|
|
||||||
if output_value is not None:
|
|
||||||
# TODO(yuanying): port number is hardcoded, this will be fix
|
|
||||||
protocol = 'https'
|
|
||||||
port = KUBE_SECURE_PORT
|
|
||||||
if cluster_template.tls_disabled:
|
|
||||||
protocol = 'http'
|
|
||||||
port = KUBE_INSECURE_PORT
|
|
||||||
|
|
||||||
params = {
|
|
||||||
'protocol': protocol,
|
|
||||||
'address': output_value,
|
|
||||||
'port': port,
|
|
||||||
}
|
|
||||||
value = "%(protocol)s://%(address)s:%(port)s" % params
|
|
||||||
setattr(bay, self.bay_attr, value)
|
|
||||||
|
|
||||||
|
|
||||||
class K8sTemplateDefinition(template_def.BaseTemplateDefinition):
|
|
||||||
"""Base Kubernetes template."""
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
super(K8sTemplateDefinition, self).__init__()
|
|
||||||
self.add_parameter('master_flavor',
|
|
||||||
baymodel_attr='master_flavor_id')
|
|
||||||
self.add_parameter('minion_flavor',
|
|
||||||
baymodel_attr='flavor_id')
|
|
||||||
self.add_parameter('number_of_minions',
|
|
||||||
bay_attr='node_count')
|
|
||||||
self.add_parameter('external_network',
|
|
||||||
baymodel_attr='external_network_id',
|
|
||||||
required=True)
|
|
||||||
self.add_parameter('network_driver',
|
|
||||||
baymodel_attr='network_driver')
|
|
||||||
self.add_parameter('volume_driver',
|
|
||||||
baymodel_attr='volume_driver')
|
|
||||||
self.add_parameter('tls_disabled',
|
|
||||||
baymodel_attr='tls_disabled',
|
|
||||||
required=True)
|
|
||||||
self.add_parameter('registry_enabled',
|
|
||||||
baymodel_attr='registry_enabled')
|
|
||||||
self.add_parameter('bay_uuid',
|
|
||||||
bay_attr='uuid',
|
|
||||||
param_type=str)
|
|
||||||
self.add_parameter('insecure_registry_url',
|
|
||||||
baymodel_attr='insecure_registry')
|
|
||||||
|
|
||||||
self.add_output('api_address',
|
|
||||||
bay_attr='api_address',
|
|
||||||
mapping_type=K8sApiAddressOutputMapping)
|
|
||||||
self.add_output('kube_minions_private',
|
|
||||||
bay_attr=None)
|
|
||||||
self.add_output('kube_minions',
|
|
||||||
bay_attr='node_addresses')
|
|
||||||
self.add_output('kube_masters_private',
|
|
||||||
bay_attr=None)
|
|
||||||
self.add_output('kube_masters',
|
|
||||||
bay_attr='master_addresses')
|
|
||||||
|
|
||||||
def get_params(self, context, cluster_template, bay, **kwargs):
|
|
||||||
extra_params = kwargs.pop('extra_params', {})
|
|
||||||
scale_mgr = kwargs.pop('scale_manager', None)
|
|
||||||
if scale_mgr:
|
|
||||||
hosts = self.get_output('kube_minions_private')
|
|
||||||
extra_params['minions_to_remove'] = (
|
|
||||||
scale_mgr.get_removal_nodes(hosts))
|
|
||||||
|
|
||||||
extra_params['discovery_url'] = self.get_discovery_url(bay)
|
|
||||||
osc = self.get_osc(context)
|
|
||||||
extra_params['magnum_url'] = osc.magnum_url()
|
|
||||||
|
|
||||||
if cluster_template.tls_disabled:
|
|
||||||
extra_params['loadbalancing_protocol'] = 'HTTP'
|
|
||||||
extra_params['kubernetes_port'] = 8080
|
|
||||||
|
|
||||||
label_list = ['flannel_network_cidr', 'flannel_backend',
|
|
||||||
'flannel_network_subnetlen']
|
|
||||||
for label in label_list:
|
|
||||||
extra_params[label] = cluster_template.labels.get(label)
|
|
||||||
|
|
||||||
if cluster_template.registry_enabled:
|
|
||||||
extra_params['swift_region'] = CONF.docker_registry.swift_region
|
|
||||||
extra_params['registry_container'] = (
|
|
||||||
CONF.docker_registry.swift_registry_container)
|
|
||||||
|
|
||||||
return super(K8sTemplateDefinition,
|
|
||||||
self).get_params(context, cluster_template, bay,
|
|
||||||
extra_params=extra_params,
|
|
||||||
**kwargs)
|
|
||||||
|
|
||||||
|
|
||||||
class JeOSK8sTemplateDefinition(K8sTemplateDefinition):
|
|
||||||
"""Kubernetes template for openSUSE/SLES JeOS VM."""
|
"""Kubernetes template for openSUSE/SLES JeOS VM."""
|
||||||
|
|
||||||
provides = [
|
provides = [
|
||||||
@ -131,7 +32,11 @@ class JeOSK8sTemplateDefinition(K8sTemplateDefinition):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(JeOSK8sTemplateDefinition, self).__init__()
|
super(JeOSK8sTemplateDefinition, self).__init__()
|
||||||
self.add_parameter('docker_volume_size',
|
self.add_parameter('docker_volume_size',
|
||||||
baymodel_attr='docker_volume_size')
|
cluster_template_attr='docker_volume_size')
|
||||||
|
self.add_output('kube_minions',
|
||||||
|
bay_attr='node_addresses')
|
||||||
|
self.add_output('kube_masters',
|
||||||
|
bay_attr='master_addresses')
|
||||||
|
|
||||||
def get_params(self, context, cluster_template, bay, **kwargs):
|
def get_params(self, context, cluster_template, bay, **kwargs):
|
||||||
extra_params = kwargs.pop('extra_params', {})
|
extra_params = kwargs.pop('extra_params', {})
|
||||||
|
117
magnum/drivers/common/k8s_template_def.py
Normal file
117
magnum/drivers/common/k8s_template_def.py
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
|
||||||
|
from oslo_config import cfg
|
||||||
|
|
||||||
|
from magnum.drivers.common import template_def
|
||||||
|
|
||||||
|
CONF = cfg.CONF
|
||||||
|
|
||||||
|
|
||||||
|
"""kubernetes ports """
|
||||||
|
KUBE_SECURE_PORT = '6443'
|
||||||
|
KUBE_INSECURE_PORT = '8080'
|
||||||
|
|
||||||
|
|
||||||
|
class K8sApiAddressOutputMapping(template_def.OutputMapping):
|
||||||
|
|
||||||
|
def set_output(self, stack, cluster_template, bay):
|
||||||
|
if self.bay_attr is None:
|
||||||
|
return
|
||||||
|
|
||||||
|
output_value = self.get_output_value(stack)
|
||||||
|
if output_value is not None:
|
||||||
|
# TODO(yuanying): port number is hardcoded, this will be fix
|
||||||
|
protocol = 'https'
|
||||||
|
port = KUBE_SECURE_PORT
|
||||||
|
if cluster_template.tls_disabled:
|
||||||
|
protocol = 'http'
|
||||||
|
port = KUBE_INSECURE_PORT
|
||||||
|
|
||||||
|
params = {
|
||||||
|
'protocol': protocol,
|
||||||
|
'address': output_value,
|
||||||
|
'port': port,
|
||||||
|
}
|
||||||
|
value = "%(protocol)s://%(address)s:%(port)s" % params
|
||||||
|
setattr(bay, self.bay_attr, value)
|
||||||
|
|
||||||
|
|
||||||
|
class K8sTemplateDefinition(template_def.BaseTemplateDefinition):
|
||||||
|
"""Base Kubernetes template."""
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
super(K8sTemplateDefinition, self).__init__()
|
||||||
|
self.add_parameter('master_flavor',
|
||||||
|
cluster_template_attr='master_flavor_id')
|
||||||
|
self.add_parameter('minion_flavor',
|
||||||
|
cluster_template_attr='flavor_id')
|
||||||
|
self.add_parameter('number_of_minions',
|
||||||
|
bay_attr='node_count')
|
||||||
|
self.add_parameter('external_network',
|
||||||
|
cluster_template_attr='external_network_id',
|
||||||
|
required=True)
|
||||||
|
self.add_parameter('network_driver',
|
||||||
|
cluster_template_attr='network_driver')
|
||||||
|
self.add_parameter('volume_driver',
|
||||||
|
cluster_template_attr='volume_driver')
|
||||||
|
self.add_parameter('tls_disabled',
|
||||||
|
cluster_template_attr='tls_disabled',
|
||||||
|
required=True)
|
||||||
|
self.add_parameter('registry_enabled',
|
||||||
|
cluster_template_attr='registry_enabled')
|
||||||
|
self.add_parameter('bay_uuid',
|
||||||
|
bay_attr='uuid',
|
||||||
|
param_type=str)
|
||||||
|
self.add_parameter('insecure_registry_url',
|
||||||
|
cluster_template_attr='insecure_registry')
|
||||||
|
self.add_parameter('kube_version',
|
||||||
|
bay_attr='coe_version')
|
||||||
|
|
||||||
|
self.add_output('api_address',
|
||||||
|
bay_attr='api_address',
|
||||||
|
mapping_type=K8sApiAddressOutputMapping)
|
||||||
|
self.add_output('kube_minions_private',
|
||||||
|
bay_attr=None)
|
||||||
|
self.add_output('kube_masters_private',
|
||||||
|
bay_attr=None)
|
||||||
|
|
||||||
|
def get_params(self, context, cluster_template, bay, **kwargs):
|
||||||
|
extra_params = kwargs.pop('extra_params', {})
|
||||||
|
scale_mgr = kwargs.pop('scale_manager', None)
|
||||||
|
if scale_mgr:
|
||||||
|
hosts = self.get_output('kube_minions_private')
|
||||||
|
extra_params['minions_to_remove'] = (
|
||||||
|
scale_mgr.get_removal_nodes(hosts))
|
||||||
|
|
||||||
|
extra_params['discovery_url'] = self.get_discovery_url(bay)
|
||||||
|
osc = self.get_osc(context)
|
||||||
|
extra_params['magnum_url'] = osc.magnum_url()
|
||||||
|
|
||||||
|
if cluster_template.tls_disabled:
|
||||||
|
extra_params['loadbalancing_protocol'] = 'HTTP'
|
||||||
|
extra_params['kubernetes_port'] = 8080
|
||||||
|
|
||||||
|
label_list = ['flannel_network_cidr', 'flannel_backend',
|
||||||
|
'flannel_network_subnetlen']
|
||||||
|
for label in label_list:
|
||||||
|
extra_params[label] = cluster_template.labels.get(label)
|
||||||
|
|
||||||
|
if cluster_template.registry_enabled:
|
||||||
|
extra_params['swift_region'] = CONF.docker_registry.swift_region
|
||||||
|
extra_params['registry_container'] = (
|
||||||
|
CONF.docker_registry.swift_registry_container)
|
||||||
|
|
||||||
|
return super(K8sTemplateDefinition,
|
||||||
|
self).get_params(context, cluster_template, bay,
|
||||||
|
extra_params=extra_params,
|
||||||
|
**kwargs)
|
@ -13,114 +13,14 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
from magnum.drivers.common import k8s_template_def
|
||||||
from magnum.drivers.common import template_def
|
from magnum.drivers.common import template_def
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
|
|
||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
KUBE_SECURE_PORT = '6443'
|
|
||||||
KUBE_INSECURE_PORT = '8080'
|
|
||||||
|
|
||||||
|
|
||||||
class K8sApiAddressOutputMapping(template_def.OutputMapping):
|
class CoreOSK8sTemplateDefinition(k8s_template_def.K8sTemplateDefinition):
|
||||||
|
|
||||||
def set_output(self, stack, cluster_template, bay):
|
|
||||||
if self.bay_attr is None:
|
|
||||||
return
|
|
||||||
|
|
||||||
output_value = self.get_output_value(stack)
|
|
||||||
if output_value is not None:
|
|
||||||
# TODO(yuanying): port number is hardcoded, this will be fix
|
|
||||||
protocol = 'https'
|
|
||||||
port = KUBE_SECURE_PORT
|
|
||||||
if cluster_template.tls_disabled:
|
|
||||||
protocol = 'http'
|
|
||||||
port = KUBE_INSECURE_PORT
|
|
||||||
|
|
||||||
params = {
|
|
||||||
'protocol': protocol,
|
|
||||||
'address': output_value,
|
|
||||||
'port': port,
|
|
||||||
}
|
|
||||||
value = "%(protocol)s://%(address)s:%(port)s" % params
|
|
||||||
setattr(bay, self.bay_attr, value)
|
|
||||||
|
|
||||||
|
|
||||||
class K8sTemplateDefinition(template_def.BaseTemplateDefinition):
|
|
||||||
"""Base Kubernetes template."""
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
super(K8sTemplateDefinition, self).__init__()
|
|
||||||
self.add_parameter('master_flavor',
|
|
||||||
cluster_template_attr='master_flavor_id')
|
|
||||||
self.add_parameter('minion_flavor',
|
|
||||||
cluster_template_attr='flavor_id')
|
|
||||||
self.add_parameter('number_of_minions',
|
|
||||||
bay_attr='node_count')
|
|
||||||
self.add_parameter('external_network',
|
|
||||||
cluster_template_attr='external_network_id',
|
|
||||||
required=True)
|
|
||||||
self.add_parameter('network_driver',
|
|
||||||
cluster_template_attr='network_driver')
|
|
||||||
self.add_parameter('volume_driver',
|
|
||||||
cluster_template_attr='volume_driver')
|
|
||||||
self.add_parameter('tls_disabled',
|
|
||||||
cluster_template_attr='tls_disabled',
|
|
||||||
required=True)
|
|
||||||
self.add_parameter('registry_enabled',
|
|
||||||
cluster_template_attr='registry_enabled')
|
|
||||||
self.add_parameter('bay_uuid',
|
|
||||||
bay_attr='uuid',
|
|
||||||
param_type=str)
|
|
||||||
self.add_parameter('insecure_registry_url',
|
|
||||||
cluster_template_attr='insecure_registry')
|
|
||||||
self.add_parameter('kube_version',
|
|
||||||
bay_attr='coe_version')
|
|
||||||
|
|
||||||
self.add_output('api_address',
|
|
||||||
bay_attr='api_address',
|
|
||||||
mapping_type=K8sApiAddressOutputMapping)
|
|
||||||
self.add_output('kube_minions_private',
|
|
||||||
bay_attr=None)
|
|
||||||
self.add_output('kube_minions',
|
|
||||||
bay_attr='node_addresses')
|
|
||||||
self.add_output('kube_masters_private',
|
|
||||||
bay_attr=None)
|
|
||||||
self.add_output('kube_masters',
|
|
||||||
bay_attr='master_addresses')
|
|
||||||
|
|
||||||
def get_params(self, context, cluster_template, bay, **kwargs):
|
|
||||||
extra_params = kwargs.pop('extra_params', {})
|
|
||||||
scale_mgr = kwargs.pop('scale_manager', None)
|
|
||||||
if scale_mgr:
|
|
||||||
hosts = self.get_output('kube_minions_private')
|
|
||||||
extra_params['minions_to_remove'] = (
|
|
||||||
scale_mgr.get_removal_nodes(hosts))
|
|
||||||
|
|
||||||
extra_params['discovery_url'] = self.get_discovery_url(bay)
|
|
||||||
osc = self.get_osc(context)
|
|
||||||
extra_params['magnum_url'] = osc.magnum_url()
|
|
||||||
|
|
||||||
if cluster_template.tls_disabled:
|
|
||||||
extra_params['loadbalancing_protocol'] = 'HTTP'
|
|
||||||
extra_params['kubernetes_port'] = 8080
|
|
||||||
|
|
||||||
label_list = ['flannel_network_cidr', 'flannel_backend',
|
|
||||||
'flannel_network_subnetlen']
|
|
||||||
for label in label_list:
|
|
||||||
extra_params[label] = cluster_template.labels.get(label)
|
|
||||||
|
|
||||||
if cluster_template.registry_enabled:
|
|
||||||
extra_params['swift_region'] = CONF.docker_registry.swift_region
|
|
||||||
extra_params['registry_container'] = (
|
|
||||||
CONF.docker_registry.swift_registry_container)
|
|
||||||
|
|
||||||
return super(K8sTemplateDefinition,
|
|
||||||
self).get_params(context, cluster_template, bay,
|
|
||||||
extra_params=extra_params,
|
|
||||||
**kwargs)
|
|
||||||
|
|
||||||
|
|
||||||
class CoreOSK8sTemplateDefinition(K8sTemplateDefinition):
|
|
||||||
"""Kubernetes template for CoreOS VM."""
|
"""Kubernetes template for CoreOS VM."""
|
||||||
|
|
||||||
provides = [
|
provides = [
|
||||||
@ -129,6 +29,13 @@ class CoreOSK8sTemplateDefinition(K8sTemplateDefinition):
|
|||||||
'coe': 'kubernetes'},
|
'coe': 'kubernetes'},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
super(CoreOSK8sTemplateDefinition, self).__init__()
|
||||||
|
self.add_output('kube_minions',
|
||||||
|
bay_attr='node_addresses')
|
||||||
|
self.add_output('kube_masters',
|
||||||
|
bay_attr='master_addresses')
|
||||||
|
|
||||||
def get_env_files(self, cluster_template):
|
def get_env_files(self, cluster_template):
|
||||||
if cluster_template.master_lb_enabled:
|
if cluster_template.master_lb_enabled:
|
||||||
return [template_def.COMMON_ENV_PATH + 'with_master_lb.yaml']
|
return [template_def.COMMON_ENV_PATH + 'with_master_lb.yaml']
|
||||||
|
@ -18,40 +18,15 @@ import os
|
|||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
|
|
||||||
from magnum.common import exception
|
from magnum.common import exception
|
||||||
|
from magnum.drivers.common import k8s_template_def
|
||||||
from magnum.drivers.common import template_def
|
from magnum.drivers.common import template_def
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
|
|
||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
KUBE_SECURE_PORT = '6443'
|
|
||||||
KUBE_INSECURE_PORT = '8080'
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class K8sApiAddressOutputMapping(template_def.OutputMapping):
|
|
||||||
|
|
||||||
def set_output(self, stack, cluster_template, bay):
|
|
||||||
if self.bay_attr is None:
|
|
||||||
return
|
|
||||||
|
|
||||||
output_value = self.get_output_value(stack)
|
|
||||||
if output_value is not None:
|
|
||||||
# TODO(yuanying): port number is hardcoded, this will be fix
|
|
||||||
protocol = 'https'
|
|
||||||
port = KUBE_SECURE_PORT
|
|
||||||
if cluster_template.tls_disabled:
|
|
||||||
protocol = 'http'
|
|
||||||
port = KUBE_INSECURE_PORT
|
|
||||||
|
|
||||||
params = {
|
|
||||||
'protocol': protocol,
|
|
||||||
'address': output_value,
|
|
||||||
'port': port,
|
|
||||||
}
|
|
||||||
value = "%(protocol)s://%(address)s:%(port)s" % params
|
|
||||||
setattr(bay, self.bay_attr, value)
|
|
||||||
|
|
||||||
|
|
||||||
class ServerAddressOutputMapping(template_def.OutputMapping):
|
class ServerAddressOutputMapping(template_def.OutputMapping):
|
||||||
|
|
||||||
public_ip_output_key = None
|
public_ip_output_key = None
|
||||||
@ -80,84 +55,7 @@ class NodeAddressOutputMapping(ServerAddressOutputMapping):
|
|||||||
private_ip_output_key = 'kube_minions_private'
|
private_ip_output_key = 'kube_minions_private'
|
||||||
|
|
||||||
|
|
||||||
class K8sTemplateDefinition(template_def.BaseTemplateDefinition):
|
class AtomicK8sTemplateDefinition(k8s_template_def.K8sTemplateDefinition):
|
||||||
"""Base Kubernetes template."""
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
super(K8sTemplateDefinition, self).__init__()
|
|
||||||
self.add_parameter('master_flavor',
|
|
||||||
cluster_template_attr='master_flavor_id')
|
|
||||||
self.add_parameter('minion_flavor',
|
|
||||||
cluster_template_attr='flavor_id')
|
|
||||||
self.add_parameter('number_of_minions',
|
|
||||||
bay_attr='node_count')
|
|
||||||
self.add_parameter('external_network',
|
|
||||||
cluster_template_attr='external_network_id',
|
|
||||||
required=True)
|
|
||||||
self.add_parameter('network_driver',
|
|
||||||
cluster_template_attr='network_driver')
|
|
||||||
self.add_parameter('volume_driver',
|
|
||||||
cluster_template_attr='volume_driver')
|
|
||||||
self.add_parameter('tls_disabled',
|
|
||||||
cluster_template_attr='tls_disabled',
|
|
||||||
required=True)
|
|
||||||
self.add_parameter('registry_enabled',
|
|
||||||
cluster_template_attr='registry_enabled')
|
|
||||||
self.add_parameter('bay_uuid',
|
|
||||||
bay_attr='uuid',
|
|
||||||
param_type=str)
|
|
||||||
self.add_parameter('insecure_registry_url',
|
|
||||||
cluster_template_attr='insecure_registry')
|
|
||||||
self.add_parameter('kube_version',
|
|
||||||
bay_attr='coe_version')
|
|
||||||
|
|
||||||
self.add_output('api_address',
|
|
||||||
bay_attr='api_address',
|
|
||||||
mapping_type=K8sApiAddressOutputMapping)
|
|
||||||
self.add_output('kube_minions_private',
|
|
||||||
bay_attr=None)
|
|
||||||
self.add_output('kube_minions',
|
|
||||||
bay_attr='node_addresses',
|
|
||||||
mapping_type=NodeAddressOutputMapping)
|
|
||||||
self.add_output('kube_masters_private',
|
|
||||||
bay_attr=None)
|
|
||||||
self.add_output('kube_masters',
|
|
||||||
bay_attr='master_addresses',
|
|
||||||
mapping_type=MasterAddressOutputMapping)
|
|
||||||
|
|
||||||
def get_params(self, context, cluster_template, bay, **kwargs):
|
|
||||||
extra_params = kwargs.pop('extra_params', {})
|
|
||||||
scale_mgr = kwargs.pop('scale_manager', None)
|
|
||||||
if scale_mgr:
|
|
||||||
hosts = self.get_output('kube_minions_private')
|
|
||||||
extra_params['minions_to_remove'] = (
|
|
||||||
scale_mgr.get_removal_nodes(hosts))
|
|
||||||
|
|
||||||
extra_params['discovery_url'] = self.get_discovery_url(bay)
|
|
||||||
osc = self.get_osc(context)
|
|
||||||
extra_params['magnum_url'] = osc.magnum_url()
|
|
||||||
|
|
||||||
if cluster_template.tls_disabled:
|
|
||||||
extra_params['loadbalancing_protocol'] = 'HTTP'
|
|
||||||
extra_params['kubernetes_port'] = 8080
|
|
||||||
|
|
||||||
label_list = ['flannel_network_cidr', 'flannel_backend',
|
|
||||||
'flannel_network_subnetlen']
|
|
||||||
for label in label_list:
|
|
||||||
extra_params[label] = cluster_template.labels.get(label)
|
|
||||||
|
|
||||||
if cluster_template.registry_enabled:
|
|
||||||
extra_params['swift_region'] = CONF.docker_registry.swift_region
|
|
||||||
extra_params['registry_container'] = (
|
|
||||||
CONF.docker_registry.swift_registry_container)
|
|
||||||
|
|
||||||
return super(K8sTemplateDefinition,
|
|
||||||
self).get_params(context, cluster_template, bay,
|
|
||||||
extra_params=extra_params,
|
|
||||||
**kwargs)
|
|
||||||
|
|
||||||
|
|
||||||
class AtomicK8sTemplateDefinition(K8sTemplateDefinition):
|
|
||||||
"""Kubernetes template for a Fedora Atomic VM."""
|
"""Kubernetes template for a Fedora Atomic VM."""
|
||||||
|
|
||||||
provides = [
|
provides = [
|
||||||
@ -172,6 +70,12 @@ class AtomicK8sTemplateDefinition(K8sTemplateDefinition):
|
|||||||
cluster_template_attr='docker_volume_size')
|
cluster_template_attr='docker_volume_size')
|
||||||
self.add_parameter('docker_storage_driver',
|
self.add_parameter('docker_storage_driver',
|
||||||
cluster_template_attr='docker_storage_driver')
|
cluster_template_attr='docker_storage_driver')
|
||||||
|
self.add_output('kube_minions',
|
||||||
|
bay_attr='node_addresses',
|
||||||
|
mapping_type=NodeAddressOutputMapping)
|
||||||
|
self.add_output('kube_masters',
|
||||||
|
bay_attr='master_addresses',
|
||||||
|
mapping_type=MasterAddressOutputMapping)
|
||||||
|
|
||||||
def get_params(self, context, cluster_template, bay, **kwargs):
|
def get_params(self, context, cluster_template, bay, **kwargs):
|
||||||
extra_params = kwargs.pop('extra_params', {})
|
extra_params = kwargs.pop('extra_params', {})
|
||||||
|
Loading…
Reference in New Issue
Block a user