Scale up k8s cluster using fuel-ccp-installer

Change-Id: I9a16bafe003a71702ac6f1742acee99df6f29164
This commit is contained in:
Dennis Dmitriev 2016-09-07 17:29:06 +03:00
parent b4be1413a8
commit 3002cff1b6
11 changed files with 225 additions and 12 deletions

View File

@ -164,7 +164,8 @@ def underlay(revert_snapshot, config, hardware):
"""
# Try to guess environment config for reverted snapshot
if revert_snapshot and not config.underlay.ssh:
config.underlay.ssh = hardware.get_ssh_data()
config.underlay.ssh = hardware.get_ssh_data(
roles=config.underlay.roles)
# Create Underlay
if not config.underlay.ssh:
@ -175,7 +176,8 @@ def underlay(revert_snapshot, config, hardware):
# If config.underlay.ssh wasn't provided from external config, then
# try to get necessary data from hardware manager (fuel-devops)
config.underlay.ssh = hardware.get_ssh_data()
config.underlay.ssh = hardware.get_ssh_data(
roles=config.underlay.roles)
hardware.create_snapshot(ext.SNAPSHOT.underlay)

View File

@ -25,6 +25,7 @@ NODE_ROLE = enum(
'master',
'slave',
'k8s',
'k8s_scale',
)
NETWORK_TYPE = enum(

View File

@ -100,9 +100,16 @@ class EnvironmentManager(object):
network_pool = default_node_group.get_network_pool(name=net_pool_name)
return network_pool
def get_ssh_data(self):
def get_ssh_data(self, roles=None):
"""Generate ssh config for Underlay
:param roles: list of strings
"""
if roles is None:
raise Exception("No roles specified for the environment!")
config_ssh = []
for d_node in self.k8s_nodes:
for d_node in self._env.get_nodes(role__in=roles):
ssh_data = {
'node_name': d_node.name,
'address_pool': self._get_network_pool(

View File

@ -32,7 +32,7 @@ class EnvironmentManagerEmpty(object):
"""
self.__config = config
def get_ssh_data(self):
def get_ssh_data(self, roles=None):
raise Exception("EnvironmentManagerEmpty doesn't have SSH details. "
"Please provide SSH details in config.underlay.ssh")

View File

@ -57,7 +57,6 @@ class UnderlaySSHManager(object):
self.remote(): SSHClient object by a node name (w/wo address pool)
or by a hostname.
"""
config_ssh = None
def __init__(self, config_ssh):
@ -65,12 +64,16 @@ class UnderlaySSHManager(object):
:param config_ssh: dict
"""
if config_ssh is None:
config_ssh = []
if self.config_ssh is None:
self.config_ssh = []
self.add_config_ssh(config_ssh)
def add_config_ssh(self, config_ssh):
if config_ssh is None:
config_ssh = []
for ssh in config_ssh:
ssh_data = {
# Required keys:
@ -92,6 +95,24 @@ class UnderlaySSHManager(object):
self.config_ssh.append(ssh_data)
def remove_config_ssh(self, config_ssh):
if config_ssh is None:
config_ssh = []
for ssh in config_ssh:
ssh_data = {
# Required keys:
'node_name': ssh['node_name'],
'host': ssh['host'],
'login': ssh['login'],
'password': ssh['password'],
# Optional keys:
'address_pool': ssh.get('address_pool', None),
'port': ssh.get('port', None),
'keys': ssh.get('keys', []),
}
self.config_ssh.remove(ssh_data)
def __get_keys(self, remote):
keys = []
remote.execute('cd ~')

View File

@ -50,6 +50,9 @@ underlay_opts = [
'port': (optional),
'keys': [(optional)],
}, ...]""", default=[]),
ct.Cfg('roles', ct.JSONList(),
help="Node roles managed by underlay in the environment",
default=[ext.NODE_ROLE.k8s, ]),
]
# TODO(ddmitriev): remove these variables from settings.py

View File

@ -70,7 +70,7 @@ template:
role: k8s
params: &rack-01-node-params
vcpu: !os_env SLAVE_NODE_CPU, 2
memory: !os_env SLAVE_NODE_MEMORY, 8048
memory: !os_env SLAVE_NODE_MEMORY, 8192
boot:
- hd
cloud_init_volume_name: iso

View File

@ -0,0 +1,120 @@
---
aliases:
dynamic_addresses_pool:
- &pool_default !os_env POOL_DEFAULT, 10.100.0.0/16:24
default_interface_model:
- &interface_model !os_env INTERFACE_MODEL, e1000
template:
devops_settings:
env_name: !os_env ENV_NAME
address_pools:
public-pool01:
net: *pool_default
params:
vlan_start: 1210
ip_reserved:
gateway: +1
l2_network_device: +1
ip_ranges:
dhcp: [+128, -32]
rack-01: [+2, +127]
private-pool01:
net: *pool_default
params:
ip_reserved:
l2_network_device: +1
ip_ranges:
dhcp: [+128, -32]
neutron-pool01:
net: *pool_default
groups:
- name: default
driver:
name: devops.driver.libvirt
params:
connection_string: !os_env CONNECTION_STRING, qemu:///system
storage_pool_name: !os_env STORAGE_POOL_NAME, default
stp: False
hpet: False
use_host_cpu: !os_env DRIVER_USE_HOST_CPU, true
network_pools:
public: public-pool01
private: private-pool01
neutron: neutron-pool01
l2_network_devices:
public:
address_pool: public-pool01
dhcp: true
forward:
mode: nat
private:
address_pool: private-pool01
dhcp: true
neutron:
address_pool: neutron-pool01
dhcp: false
group_volumes:
- name: baseimage # This name is used for 'backing_store' option for node volumes.
source_image: !os_env IMAGE_PATH
format: qcow2
nodes:
- name: node1
role: k8s
params: &rack-01-node-params
vcpu: !os_env SLAVE_NODE_CPU, 2
memory: !os_env SLAVE_NODE_MEMORY, 8192
boot:
- network
- hd
volumes:
- name: system
capacity: !os_env NODE_VOLUME_SIZE, 150
backing_store: baseimage
format: qcow2
interfaces:
- label: iface0
l2_network_device: public
interface_model: *interface_model
- label: iface1
l2_network_device: private
interface_model: *interface_model
- label: iface2
l2_network_device: neutron
interface_model: *interface_model
network_config:
iface0:
networks:
- public
iface1:
networks:
- private
iface2:
networks:
- neutron
- name: node2
role: k8s
params: *rack-01-node-params
- name: node3
role: k8s
params: *rack-01-node-params
- name: node4
role: k8s_scale
params: *rack-01-node-params
- name: node5
role: k8s_scale
params: *rack-01-node-params

View File

@ -72,7 +72,7 @@ template:
role: k8s
params: &rack-01-node-params
vcpu: !os_env SLAVE_NODE_CPU, 2
memory: !os_env SLAVE_NODE_MEMORY, 8048
memory: !os_env SLAVE_NODE_MEMORY, 8192
boot:
- network
- hd

View File

@ -72,7 +72,7 @@ template:
role: k8s
params: &rack-01-node-params
vcpu: !os_env SLAVE_NODE_CPU, 2
memory: !os_env SLAVE_NODE_MEMORY, 8048
memory: !os_env SLAVE_NODE_MEMORY, 8192
boot:
- network
- hd

View File

@ -0,0 +1,59 @@
# Copyright 2016 Mirantis, Inc.
#
# 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.
import pytest
import base_test
from fuel_ccp_tests.helpers import ext
@pytest.mark.fuel_ccp_scale_k8s
class TestLCMScaleK8s(base_test.SystemBaseTest):
"""Test class for testing k8s scale by fuel-ccp-installer
pytest.mark: fuel_ccp_scale_k8s
"""
@pytest.mark.snapshot_needed
@pytest.mark.revert_snapshot(ext.SNAPSHOT.k8s_deployed)
@pytest.mark.fail_snapshot
def test_lcm_k8s_scale_up(self, hardware, underlay, k8scluster):
"""Test for scale an k8s environment
pytest.mark: k8s_installed_default
Require:
- already installed k8s cluster with node roles 'k8s'
- fuel-devops environment with additional node roles 'k8s_scale'
Scenario:
1. Check number of kube nodes match underlay nodes.
2. Check etcd health.
3. Add to 'underlay' new nodes for k8s scale
4. Run fuel-ccp installer for old+new k8s nodes
5. Check number of kube nodes match underlay nodes.
6. Check etcd health.
"""
k8sclient = k8scluster.api
self.check_number_kube_nodes(underlay, k8sclient)
self.check_etcd_health(underlay)
config_ssh_scale = hardware.get_ssh_data(
roles=[ext.NODE_ROLE.k8s_scale])
underlay.add_config_ssh(config_ssh_scale)
k8scluster.install_k8s()
self.check_number_kube_nodes(underlay, k8sclient)
self.check_etcd_health(underlay)