Prevent disruption of core services using safety guardrails#129
Prevent disruption of core services using safety guardrails#129Ayushdk wants to merge 3 commits intokrkn-chaos:mainfrom
Conversation
Signed-off-by: Ayush Nagar <ayushnagar2310@gmail.com>
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
||||||||||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
|||||||||||||||||||
Signed-off-by: Ayush Nagar <ayushnagar2310@gmail.com>
Signed-off-by: Ayush Nagar <ayushnagar2310@gmail.com>
User description
Fixes #25
This PR introduces safety guardrails to prevent Krkn-AI from disrupting
critical services it depends on (e.g. Prometheus, monitoring stack).
Key changes:
This ensures observation layer remains available during chaos experiments.
PR Type
Bug fix, Enhancement
Description
Implements safety guardrails to prevent disruption of critical Kubernetes services
Adds
SafetyConfigmodel with namespace, pod, and node exclusion rulesApplies safety configuration automatically during config initialization
Filters out protected components before genetic algorithm operates
Includes unit test validating namespace exclusion functionality
Diagram Walkthrough
File Walkthrough
safety.py
New SafetyConfig model for protection ruleskrkn_ai/models/safety.py
SafetyConfigmodel with safety guardrailskube-system,kube-public,kube-node-leasecluster_components.py
Add apply_safety method to ClusterComponentskrkn_ai/models/cluster_components.py
apply_safety()method to mark protected components as disabledfnmatchconfig.py
Integrate SafetyConfig into ConfigFile modelkrkn_ai/models/config.py
SafetyConfigmodelsafetyfield toConfigFilewith default factorycmd.py
Apply safety guardrails during config initializationkrkn_ai/cli/cmd.py
apply_safety()on cluster components with parsed safety configtest_safety.py
Unit test for safety configuration exclusiontests/test_safety.py
SafetyConfigexcludeskube-systemnamespaceget_active_components()filters protected namespacescorrectly