Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable compliance tests to use plugins for cluster provisioning #753

Open
wants to merge 36 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
a326e99
Enable compliance tests to use plugins for cluster provisioning
tonifinger Sep 18, 2024
ab0803b
Fix python style
tonifinger Sep 18, 2024
199fdf2
Fix path to junit file
tonifinger Sep 20, 2024
f994cde
Inital integration of the plugin into the 'scs-test-runner.py'
tonifinger Oct 7, 2024
4a51c0d
Adjust 'scs-test-runner.py' to handle kaas tests
tonifinger Oct 10, 2024
928ea83
Add ability to deploy clusters for different K8s versions
tonifinger Oct 14, 2024
acc451d
Update `scs-test-runner.py`
tonifinger Oct 18, 2024
e4d6c3c
still draft: a few steps towards my vision
mbuechse Oct 23, 2024
1dd220c
add missing file
mbuechse Oct 23, 2024
7c063d8
Fixup!
tonifinger Oct 23, 2024
5b11641
Fixup plugin kubeconfig file generation
tonifinger Oct 24, 2024
7fb5f32
Draft: split up clusterspec file
tonifinger Nov 4, 2024
9a2809a
Merge to back to usage of one single clustersspec
tonifinger Nov 4, 2024
bfa6ba4
Rearange configuration files
tonifinger Nov 5, 2024
1cfee94
Fixup configuration files
tonifinger Nov 5, 2024
9f7fe4c
Fixup configuration files
tonifinger Nov 5, 2024
3e5357a
revert sonobuoy executor handling form this PR
tonifinger Nov 5, 2024
99c450f
Apply cluster configuration file handling
tonifinger Nov 5, 2024
5adb9f6
Update Tests/kaas/plugin/run_plugin.py
tonifinger Nov 5, 2024
2127323
Update Tests/config.toml
tonifinger Nov 5, 2024
5392c5e
Fixup
tonifinger Nov 5, 2024
73edf99
Restructure abstract method handling in plugin
tonifinger Nov 6, 2024
90d958e
Add example plugin implementation to interface.py
tonifinger Nov 6, 2024
fc78a7c
Fixup: change kube_plugin_config directory name
tonifinger Nov 6, 2024
76134d6
Fixup: missing adjustment to config.toml
tonifinger Nov 6, 2024
cfa113c
Remove abstract base clase handling and directly
tonifinger Nov 7, 2024
d43a38d
Update 'kind_plugin.py' kubeconfig filepath handling
tonifinger Nov 7, 2024
8f4970b
Sort python imports
tonifinger Nov 7, 2024
5a8f8ca
Fixup: use '__name__' for logging handler
tonifinger Nov 7, 2024
7d6a0cb
Update Tests/kaas/plugin/run_plugin.py
tonifinger Nov 7, 2024
c4b2611
Update plugin kubeconfig handling
tonifinger Nov 7, 2024
78fd694
Update plugin_static.py
tonifinger Nov 7, 2024
2301ba3
Fixup remove obsolete f-string
tonifinger Nov 7, 2024
fa0247e
Fixup
tonifinger Nov 8, 2024
932ed7a
Fixup: remove default value in description
tonifinger Nov 8, 2024
a96047d
Fixup: remove version parameter form delete
tonifinger Nov 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Tests/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ subject_root = "{subject}"

[subjects._.kubernetes_setup]
kube_plugin = "kind"
kube_plugin_config = "../playbooks/kubernetes_cluster_configs/kind_cluster_config.yaml"
clusterspec = "kaas/clusterspec.yaml"
clusterspec_cluster = "current-k8s-release"
tonifinger marked this conversation as resolved.
Show resolved Hide resolved

Expand Down
15 changes: 5 additions & 10 deletions Tests/kaas/plugin/interface.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from abc import ABC, abstractmethod
from abc import abstractmethod
from typing import final
import os
import os.path
Expand All @@ -8,7 +8,7 @@
logger = logging.getLogger("interface")


class KubernetesClusterPlugin(ABC):
class KubernetesClusterPlugin():
"""
An abstract base class for custom Kubernetes cluster provider plugins.
It represents an interface class from which the api provider-specific
Expand All @@ -21,9 +21,9 @@ class KubernetesClusterPlugin(ABC):
working_directory = None

@final
def __init__(self, config=None):
def __init__(self, config_file=None):
logger.info(f"Init provider plug-in of type {self.__class__.__name__}")
self.config = config
self.config = config_file
logger.debug(self.config)
self.working_directory = os.getcwd()
logger.debug(f"Working from {self.working_directory}")
Expand Down Expand Up @@ -56,12 +56,7 @@ def create(self, name="scs-cluster", version=None, kubeconfig_filepath=None):
self.cluster_name = name
self.cluster_version = version

self._create_cluster() # TODO: maybe we do not need to use try exept here?
# try:
# self._create_cluster()
# except Exception as e:
# logging.exception(e)
# self._delete_cluster()
self._create_cluster()

if kubeconfig_filepath:
shutil.move(self.kubeconfig, kubeconfig_filepath)
Expand Down
9 changes: 5 additions & 4 deletions Tests/kaas/plugin/run_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ def init_plugin(plugin_kind, config=None):
return plugin_maker(config)


def run_plugin_create(plugin_kind, clusterspec_cluster, clusterspec):
plugin = init_plugin(plugin_kind)
def run_plugin_create(plugin_kind, plugin_config, clusterspec_cluster, clusterspec):
plugin = init_plugin(plugin_kind, plugin_config)
plugin.create(clusterspec_cluster, clusterspec[clusterspec_cluster]['branch'], os.path.abspath(clusterspec[clusterspec_cluster]['kubeconfig']))


Expand All @@ -44,11 +44,12 @@ def cli():

@cli.command()
@click.argument('plugin_kind', type=click.Choice(list(PLUGIN_LOOKUP), case_sensitive=False))
@click.argument('plugin_config', type=click.Path(exists=True, dir_okay=False))
@click.argument('clusterspec_path', type=click.Path(exists=True, dir_okay=False))
@click.argument('clusterspec_cluster', type=str, default="default")
def create(plugin_kind, clusterspec_path, clusterspec_cluster):
def create(plugin_kind, plugin_config, clusterspec_path, clusterspec_cluster):
clusterspec = load_spec(clusterspec_path)['clusters']
run_plugin_create(plugin_kind, clusterspec_cluster, clusterspec)
run_plugin_create(plugin_kind, plugin_config, clusterspec_cluster, clusterspec)
tonifinger marked this conversation as resolved.
Show resolved Hide resolved


@cli.command()
Expand Down
1 change: 1 addition & 0 deletions Tests/scs-test-runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ def build_provision_command(self, subject):
sys.executable, self.run_plugin_py,
'create',
kubernetes_setup['kube_plugin'],
self.abspath(kubernetes_setup['kube_plugin_config']),
self.abspath(kubernetes_setup['clusterspec']),
kubernetes_setup['clusterspec_cluster'],
],
Expand Down
Loading