Generic framework for running health validation rules on OpenShift cluster nodes
Project description
In-Cluster Checks
A generic framework for running health validation rules directly on OpenShift cluster nodes using oc debug.
Overview
This framework provides infrastructure for:
- Running validation rules on cluster nodes via
oc debug - Parallel execution of rules across multiple nodes
- Secret filtering and output formatting
- Prerequisite checking and domain orchestration
- Insights-compatible JSON output
Originally developed as part of Red Hat's Pendrive project, this framework has been extracted as open-source to benefit the broader OpenShift community.
Features
- Generic validation framework: Base classes for creating custom health check rules
- OpenShift integration: Direct node access via
oc debugwith persistent connections - Domain organization: Group related rules into domains (hardware, network, linux, storage)
- Parallel execution: Run rules concurrently across multiple nodes
- Secret filtering: Automatic redaction of sensitive data from outputs
- Extensible: Easy to add new rules and domains
Installation
pip install in-cluster-checks
Quick Start
First, ensure you're logged into your OpenShift cluster:
oc login https://api.your-cluster.com:6443
Then run the checks:
# Run all checks (output saved to ./cluster-checks.json)
in-cluster-checks --output ./cluster-checks.json
# Run with debug logging
in-cluster-checks --log-level DEBUG
# Debug a specific rule (disables secret filtering)
in-cluster-checks --debug-rule "check_disk_usage"
# List available domains
in-cluster-checks --list-domains
# List all available rules
in-cluster-checks --list-rules
Programmatic Usage
You can also use the framework programmatically in your Python code:
from in_cluster_checks.runner import InClusterCheckRunner
from pathlib import Path
# Create runner with default configuration
runner = InClusterCheckRunner()
# Or customize configuration
runner = InClusterCheckRunner(
max_workers=75, # Maximum concurrent workers (default: 50)
debug_rule_flag=False, # Enable debug mode (default: False)
debug_rule_name="", # Specific rule to debug (default: "")
)
# Run checks and save results
output_path = Path("./results/cluster-checks.json")
runner.run(output_path=output_path)
Configuration Options
- max_workers (int, default: 50): Maximum number of concurrent workers for parallel execution
- debug_rule_flag (bool, default: False): Enable debug mode with verbose output
- debug_rule_name (str, default: ""): Name of specific rule to run in debug mode
Note: When debug mode is enabled:
- Only the specified rule runs
- Secret filtering is automatically disabled
- JSON output is disabled (real-time console output only)
- Detailed command execution logs are printed
Architecture
Core Components
- Rule: Base class for validation rules
- RuleDomain: Orchestrator for groups of related rules
- Operator: Command execution abstraction
- NodeExecutor: Execute commands on cluster nodes via
oc debug - LoggerInterface: Pluggable logging abstraction
Built-in Domains
- Hardware: Disk usage, memory, CPU, temperature validation
- Network: OVS, DNS, bonding checks
- Linux: Systemd, SELinux, clock synchronization
- Storage: Storage validation rules
- Hardware/Firmware Details: Informational collectors for hardware inventory
Creating Custom Rules
from in_cluster_checks.core.rule import Rule
from in_cluster_checks.core.rule_result import RuleResult
from in_cluster_checks.utils.enums import Status, Objectives
class MyCustomRule(Rule):
"""Example custom validation rule."""
objective_hosts = [Objectives.ALL_NODES]
def set_document(self):
self.unique_name = "my_custom_rule"
self.title = "My Custom Validation Rule"
def run_rule(self):
# Run validation logic
return_code, stdout, stderr = self.run_cmd("my-command")
if return_code == 0:
return RuleResult.passed("Validation passed")
else:
return RuleResult.failed(f"Validation failed: {stderr}")
Requirements
- Python 3.9+
- OpenShift CLI (
oc) installed and configured - Access to OpenShift cluster
Development
# Clone repository
git clone https://github.com/sprizend-rh/in-cluster-checks.git
cd in-cluster-checks
# Install development dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Run pre-commit checks
pre-commit run --all-files
License
GNU General Public License v3.0 or later
See LICENSE for full text.
Contributing
Contributions are welcome! Please feel free to submit pull requests or open issues.
Related Projects
- Pendrive: Red Hat's on-premise Insights validation tool (internal)
- OpenShift: Container orchestration platform
Acknowledgments
This framework was extracted from Red Hat's Pendrive project. The core validation infrastructure is generic and contains no confidential logic, making it suitable for open-source release to benefit the wider OpenShift community.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file in_cluster_checks-0.1.4.tar.gz.
File metadata
- Download URL: in_cluster_checks-0.1.4.tar.gz
- Upload date:
- Size: 108.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c67423d01c3929668deb40d0dc9ef98131dda193b93dfb4030a6bf5950c047ee
|
|
| MD5 |
af71f20ef46b67280fffa26d468013be
|
|
| BLAKE2b-256 |
44d95b63b9a365c605d6263baafa479d4c50fa861989e9f5d252092032ba06f5
|
Provenance
The following attestation bundles were made for in_cluster_checks-0.1.4.tar.gz:
Publisher:
publish.yml on sprizend-rh/in-cluster-checks
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
in_cluster_checks-0.1.4.tar.gz -
Subject digest:
c67423d01c3929668deb40d0dc9ef98131dda193b93dfb4030a6bf5950c047ee - Sigstore transparency entry: 1073447429
- Sigstore integration time:
-
Permalink:
sprizend-rh/in-cluster-checks@e93ac1b87942fb50632f7e033055208d0e5fbf4e -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/sprizend-rh
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@e93ac1b87942fb50632f7e033055208d0e5fbf4e -
Trigger Event:
release
-
Statement type:
File details
Details for the file in_cluster_checks-0.1.4-py3-none-any.whl.
File metadata
- Download URL: in_cluster_checks-0.1.4-py3-none-any.whl
- Upload date:
- Size: 130.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
256669a5c568158bc37827702283c70b18ea919c626a5c69ba28573b44553bd4
|
|
| MD5 |
1f6fb4bc71ece15dd0bdcd1185ccf8aa
|
|
| BLAKE2b-256 |
bc6273eaf56919c6680efc6cbf05bb2cceda41ddad11f1a09d015443e036998a
|
Provenance
The following attestation bundles were made for in_cluster_checks-0.1.4-py3-none-any.whl:
Publisher:
publish.yml on sprizend-rh/in-cluster-checks
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
in_cluster_checks-0.1.4-py3-none-any.whl -
Subject digest:
256669a5c568158bc37827702283c70b18ea919c626a5c69ba28573b44553bd4 - Sigstore transparency entry: 1073447430
- Sigstore integration time:
-
Permalink:
sprizend-rh/in-cluster-checks@e93ac1b87942fb50632f7e033055208d0e5fbf4e -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/sprizend-rh
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@e93ac1b87942fb50632f7e033055208d0e5fbf4e -
Trigger Event:
release
-
Statement type: