Plugins¶
Kube-IDEA supports a plugin system based on Python entry points.
How it works¶
- A plugin is a regular Python package that declares an entry point under
the
kubeidea.pluginsgroup. - At startup, the Plugin Host discovers all installed entry points in that group and exposes them for activation.
- Each plugin implements the
PluginInterfaceprotocol (defined inkubeidea.plugins.host).
Writing a plugin¶
1. Create a new Python package¶
2. Implement the interface¶
# src/kubeidea_myplugin/__init__.py
from __future__ import annotations
from typing import Any
class Plugin:
"""Example Kube-IDEA plugin."""
name = "my-plugin"
def activate(self, host_api: Any) -> None:
"""Called when the plugin is loaded."""
print(f"{self.name} activated")
def deactivate(self) -> None:
"""Called when the plugin is unloaded."""
print(f"{self.name} deactivated")
3. Register the entry point¶
In the plugin's pyproject.toml:
4. Install and test¶
# Install the plugin in the same environment
pip install -e ./kubeidea-myplugin
# Start Kube-IDEA — the plugin will be discovered automatically
poetry run flet run src/kubeidea/app.py
Plugin Host API¶
The PluginHost class (in kubeidea.plugins.host) provides:
| Method | Description |
|---|---|
discover() |
Scan entry points and return a list of PluginInfo |
activate(name, …) |
Load and activate a plugin by name |
deactivate(name) |
Deactivate a loaded plugin |
loaded_plugins |
Property listing all currently active plugins |