k8s coreos bay driver

This patch moves k8s-coreos specific templates and
template_definition class to the new drivers folder.

It also deletes the /magnum/templates folder
as everything has been moved to the drivers directory.

Change-Id: I6b2ca49e4d7d5fcfb96d0abc373d6476fd907358
Paritially-Implements: blueprint bay-drivers
This commit is contained in:
murali allada 2016-07-07 13:05:57 -05:00
parent a5ae8b37aa
commit f09f314da4
63 changed files with 20 additions and 102 deletions

View File

@ -15,10 +15,10 @@
import os
from magnum.conductor import template_definition
from magnum.drivers.common import template_def
class ExampleTemplate(template_definition.BaseTemplateDefinition):
class ExampleTemplate(template_def.BaseTemplateDefinition):
provides = [
{'server_type': 'vm', 'os': 'example', 'coe': 'example_coe'},
{'server_type': 'vm', 'os': 'example2', 'coe': 'example_coe'},

View File

@ -22,7 +22,6 @@ import six
from magnum.common import clients
from magnum.common import exception
from magnum.common import paths
from magnum.i18n import _
from magnum.i18n import _LW
@ -33,11 +32,6 @@ LOG = logging.getLogger(__name__)
template_def_opts = [
cfg.StrOpt('k8s_coreos_template_path',
default=paths.basedir_def('templates/kubernetes/'
'kubecluster-coreos.yaml'),
help=_(
'Location of template to build a k8s cluster on CoreOS.')),
cfg.StrOpt('etcd_discovery_service_endpoint_format',
default='https://discovery.etcd.io/new?size=%(size)d',
help=_('Url for etcd public discovery endpoint.')),

View File

View File

@ -1,4 +1,4 @@
# Copyright 2014 Rackspace Inc. All rights reserved.
# Copyright 2016 Rackspace Inc. All rights reserved.
#
# 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
@ -11,46 +11,14 @@
# 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 oslo_log import log as logging
import os
from magnum.common import paths
from magnum.drivers.common import template_def
from magnum.i18n import _
LOG = logging.getLogger(__name__)
KUBE_SECURE_PORT = '6443'
KUBE_INSECURE_PORT = '8080'
template_def_opts = [
cfg.StrOpt('k8s_coreos_template_path',
default=paths.basedir_def('templates/kubernetes/'
'kubecluster-coreos.yaml'),
help=_(
'Location of template to build a k8s cluster on CoreOS.')),
cfg.StrOpt('etcd_discovery_service_endpoint_format',
default='https://discovery.etcd.io/new?size=%(size)d',
help=_('Url for etcd public discovery endpoint.')),
cfg.ListOpt('enabled_definitions',
default=['magnum_vm_atomic_k8s', 'magnum_vm_coreos_k8s',
'magnum_vm_atomic_swarm', 'magnum_vm_ubuntu_mesos'],
help=_('Enabled bay definition entry points.')),
]
docker_registry_opts = [
cfg.StrOpt('swift_region',
help=_('Region name of Swift')),
cfg.StrOpt('swift_registry_container',
default='docker_registry',
help=_('Name of the container in Swift which docker registry '
'stores images in'))
]
from oslo_config import cfg
CONF = cfg.CONF
CONF.register_opts(template_def_opts, group='bay')
CONF.register_opts(docker_registry_opts, group='docker_registry')
KUBE_SECURE_PORT = '6443'
KUBE_INSECURE_PORT = '8080'
class K8sApiAddressOutputMapping(template_def.OutputMapping):
@ -149,12 +117,6 @@ class K8sTemplateDefinition(template_def.BaseTemplateDefinition):
extra_params=extra_params,
**kwargs)
def get_env_files(self, baymodel):
if baymodel.master_lb_enabled:
return ['environments/with_master_lb.yaml']
else:
return ['environments/no_master_lb.yaml']
class CoreOSK8sTemplateDefinition(K8sTemplateDefinition):
"""Kubernetes template for CoreOS VM."""
@ -165,4 +127,5 @@ class CoreOSK8sTemplateDefinition(K8sTemplateDefinition):
@property
def template_path(self):
return cfg.CONF.bay.k8s_coreos_template_path
return os.path.join(os.path.dirname(os.path.realpath(__file__)),
'templates/kubecluster-coreos.yaml')

View File

@ -5,12 +5,11 @@
echo "configuring kubernetes (minion)"
ETCD_SERVER_IP=${ETCD_SERVER_IP:-$KUBE_MASTER_IP}
KUBE_PROTOCOL="https"
KUBE_CONFIG=""
if [ "$TLS_DISABLED" = "True" ]; then
KUBE_PROTOCOL="http"
KUBE_CONFIG=""
else
KUBE_PROTOCOL="https"
KUBE_CONFIG="--kubeconfig=/srv/kubernetes/kubeconfig.yaml"
fi
KUBE_MASTER_URI="$KUBE_PROTOCOL://$KUBE_MASTER_IP:$KUBE_API_PORT"

View File

@ -27,8 +27,8 @@ import magnum.conductor.config
import magnum.conductor.handlers.bay_conductor
import magnum.conductor.handlers.docker_conductor
import magnum.conductor.handlers.k8s_conductor
import magnum.conductor.template_definition
import magnum.db
import magnum.drivers.common.template_def
def list_opts():
@ -40,7 +40,7 @@ def list_opts():
magnum.common.service.service_opts,
)),
('api', magnum.api.app.API_SERVICE_OPTS),
('bay', magnum.conductor.template_definition.template_def_opts),
('bay', magnum.drivers.common.template_def.template_def_opts),
('conductor', magnum.conductor.config.SERVICE_OPTS),
('database', magnum.db.sql_opts),
('docker', magnum.common.docker_utils.docker_opts),
@ -61,5 +61,5 @@ def list_opts():
('baymodel', magnum.api.validation.baymodel_opts),
('keystone_auth', magnum.common.keystone.keystone_auth_opts),
('docker_registry',
magnum.conductor.template_definition.docker_registry_opts)
magnum.drivers.common.template_def.docker_registry_opts)
]

View File

@ -1,38 +0,0 @@
# This file contains docker storage drivers configuration for fedora
# atomic hosts. Currently, devicemapper and overlay are supported.
# Remove any existing docker-storage configuration. In case of an
# existing configuration, docker-storage-setup will fail.
clear_docker_storage_congiguration () {
if [ -f /etc/sysconfig/docker-storage ]; then
sed -i "/^DOCKER_STORAGE_OPTIONS=/ s/=.*/=/" /etc/sysconfig/docker-storage
fi
}
# Configure docker storage with xfs as backing filesystem.
configure_overlay () {
clear_docker_storage_congiguration
rm -rf /var/lib/docker/*
mkfs.xfs ${device_path}
echo "${device_path} /var/lib/docker xfs defaults 0 0" >> /etc/fstab
mount -a
echo "STORAGE_DRIVER=overlay" > /etc/sysconfig/docker-storage-setup
# SELinux must be enabled and in enforcing mode on the physical
# machine, but must be disabled in the container when performing
# container separation
sed -i "/^OPTIONS=/ s/--selinux-enabled/--selinux-enabled=false/" /etc/sysconfig/docker
}
# Configure docker storage with devicemapper using direct LVM
configure_devicemapper () {
clear_docker_storage_congiguration
pvcreate ${device_path}
vgcreate docker ${device_path}
echo "VG=docker" > /etc/sysconfig/docker-storage-setup
}

View File

@ -297,7 +297,7 @@ class TestBayConductorWithK8s(base.TestCase):
'insecure_registry_url': '10.0.0.1:5000',
}
self.assertEqual(expected, definition)
self.assertEqual(['environments/no_master_lb.yaml'], env_files)
self.assertEqual([], env_files)
@patch('requests.get')
@patch('magnum.objects.BayModel.get_by_uuid')
@ -349,7 +349,7 @@ class TestBayConductorWithK8s(base.TestCase):
'insecure_registry_url': '10.0.0.1:5000',
}
self.assertEqual(expected, definition)
self.assertEqual(['environments/no_master_lb.yaml'], env_files)
self.assertEqual([], env_files)
@patch('requests.get')
@patch('magnum.objects.BayModel.get_by_uuid')

View File

View File

@ -16,8 +16,8 @@ import mock
from oslo_config import cfg
from magnum.common import exception
from magnum.conductor import template_definition as tdef
from magnum.drivers.common import template_def as cmn_tdef
from magnum.drivers.k8s_coreos_v1 import template_def as k8s_coreos_tdef
from magnum.drivers.k8s_fedora_atomic_v1 import template_def as k8sa_tdef
from magnum.drivers.mesos_ubuntu_v1 import template_def as mesos_tdef
from magnum.drivers.swarm_fedora_atomic_v1 import template_def as swarm_tdef
@ -52,7 +52,7 @@ class TemplateDefinitionTestCase(base.TestCase):
self.assertEqual(k8sa_tdef.AtomicK8sTemplateDefinition,
vm_atomic_k8s['magnum_vm_atomic_k8s'])
self.assertEqual(1, len(vm_coreos_k8s))
self.assertEqual(tdef.CoreOSK8sTemplateDefinition,
self.assertEqual(k8s_coreos_tdef.CoreOSK8sTemplateDefinition,
vm_coreos_k8s['magnum_vm_coreos_k8s'])
def test_get_vm_atomic_kubernetes_definition(self):
@ -71,7 +71,7 @@ class TemplateDefinitionTestCase(base.TestCase):
'kubernetes')
self.assertIsInstance(definition,
tdef.CoreOSK8sTemplateDefinition)
k8s_coreos_tdef.CoreOSK8sTemplateDefinition)
def test_get_vm_atomic_swarm_definition(self):
definition = cmn_tdef.TemplateDefinition.get_template_definition(

View File

@ -57,7 +57,7 @@ oslo.config.opts.defaults =
magnum.template_definitions =
magnum_vm_atomic_k8s = magnum.drivers.k8s_fedora_atomic_v1.template_def:AtomicK8sTemplateDefinition
magnum_vm_coreos_k8s = magnum.conductor.template_definition:CoreOSK8sTemplateDefinition
magnum_vm_coreos_k8s = magnum.drivers.k8s_coreos_v1.template_def:CoreOSK8sTemplateDefinition
magnum_vm_atomic_swarm = magnum.drivers.swarm_fedora_atomic_v1.template_def:AtomicSwarmTemplateDefinition
magnum_vm_ubuntu_mesos = magnum.drivers.mesos_ubuntu_v1.template_def:UbuntuMesosTemplateDefinition