A Python-based CLI toolkit for automating daily DevOps operations.
Project description
DevOpsToolbox
A Python-based CLI toolkit for automating daily DevOps operations.
Features
- Kubernetes Management: Manage pods, services, jobs, and certificates from the command line
- File Validation: Validate YAML and JSON files for syntax errors with detailed error reporting
- Utilities: Generate passwords, encode/decode base64 strings
- Human-readable Output: Formatted tables with Rich for clear visualization
- Metrics Support: View CPU and memory usage for pods (requires Metrics Server)
- Certificate Management: List and monitor cert-manager certificates
Requirements
- Python 3.9+
- Access to a Kubernetes cluster (kubeconfig configured)
- Metrics Server (optional, for pod metrics)
- cert-manager (optional, for certificate management)
Installation
# Clone the repository
git clone https://github.com/georgesouzafarias/DevOpsToolbox.git
cd DevOpsToolbox
# Install in development mode
pip install -e .
Usage
General Commands
# Show version
devopstoolbox version
# Show help
devopstoolbox --help
Short Aliases
All Kubernetes commands support short aliases for common options, matching kubectl conventions:
| Long Form | Short | Description |
|---|---|---|
--namespace |
-n |
Specify the namespace |
--all-namespaces |
-A |
List resources across all namespaces |
Pods Management
# List all pods in default namespace
devopstoolbox k8s pods list
# List all pods in a specific namespace
devopstoolbox k8s pods list -n monitoring
# List all pods across all namespaces
devopstoolbox k8s pods list -A
# List unhealthy pods (not Running or Succeeded)
devopstoolbox k8s pods unhealthy -A
# Show pod metrics (CPU and memory usage)
devopstoolbox k8s pods metrics -n default
# Show pod metrics sorted by CPU usage
devopstoolbox k8s pods metrics -A --sort-by cpu
# Show top 10 pods by memory usage
devopstoolbox k8s pods metrics -A --sort-by memory --limit 10
# Find overprovisioned pods (usage below 50% of request)
devopstoolbox k8s pods overprovisioned -n default
# Find overprovisioned pods with custom threshold (30%)
devopstoolbox k8s pods overprovisioned -A --threshold 30
# Find overprovisioned pods sorted by CPU, limit to top 10
devopstoolbox k8s pods overprovisioned -A --sort-by cpu --limit 10
Services Management
# List services in default namespace
devopstoolbox k8s services list
# List services in a specific namespace
devopstoolbox k8s services list -n kube-system
# List all services across all namespaces
devopstoolbox k8s services list -A
Jobs Management
# List all jobs in default namespace
devopstoolbox k8s jobs list
# List all jobs in a specific namespace
devopstoolbox k8s jobs list -n batch
# List all jobs across all namespaces
devopstoolbox k8s jobs list -A
# List only failed jobs
devopstoolbox k8s jobs failed -A
Certificates Management
# List certificates in default namespace
devopstoolbox k8s certificates list
# List certificates in a specific namespace
devopstoolbox k8s certificates list -n cert-manager
# List certificates that are not ready
devopstoolbox k8s certificates not-ready -n default
Miscellaneous Utilities
Password Generation
# Generate a 16-character password (default)
devopstoolbox misc generate
# Generate a password with custom length
devopstoolbox misc generate -l 30
devopstoolbox misc generate --length 24
Base64 Encoding/Decoding
# Encode a string to base64
devopstoolbox misc base64 --encode "hello world"
devopstoolbox misc base64 -e "secret text"
# Encode a file to base64
devopstoolbox misc base64 --file /path/to/file.txt
devopstoolbox misc base64 -f ./config.yaml
# Decode a base64 string
devopstoolbox misc base64 --decode "aGVsbG8gd29ybGQ="
devopstoolbox misc base64 -d "c2VjcmV0IHRleHQ="
File Validation
# Validate a single YAML file
devopstoolbox misc validate yaml -f deployment.yaml
# Validate all YAML files in a directory (recursive)
devopstoolbox misc validate yaml -d ./manifests
# Validate a single JSON file
devopstoolbox misc validate json -f config.json
# Validate all JSON files in a directory (recursive)
devopstoolbox misc validate json -d ./configs
Command Reference
| Command | Description |
|---|---|
devopstoolbox version |
Show tool version |
| Kubernetes - Pods | |
devopstoolbox k8s pods list |
List pods with status and restart count |
devopstoolbox k8s pods metrics |
Show CPU and memory usage per container |
devopstoolbox k8s pods unhealthy |
List pods not in Running/Succeeded state |
devopstoolbox k8s pods overprovisioned |
Find pods with resources below threshold |
| Kubernetes - Services | |
devopstoolbox k8s services list |
List services with type and traffic policy |
| Kubernetes - Jobs | |
devopstoolbox k8s jobs list |
List jobs with status and age |
devopstoolbox k8s jobs failed |
List only failed jobs with error messages |
| Kubernetes - Certificates | |
devopstoolbox k8s certificates list |
List cert-manager certificates |
devopstoolbox k8s certificates not-ready |
List certificates not in Ready state |
| Misc - Generate | |
devopstoolbox misc generate |
Generate a secure random password |
| Misc - Base64 | |
devopstoolbox misc base64 -e <string> |
Encode a string to base64 |
devopstoolbox misc base64 -f <file> |
Encode a file to base64 |
devopstoolbox misc base64 -d <string> |
Decode a base64 string |
| Misc - Validate | |
devopstoolbox misc validate yaml |
Validate YAML files for syntax errors |
devopstoolbox misc validate json |
Validate JSON files for syntax errors |
Dependencies
- boto3
- kubernetes
- pyyaml
- typer
- rich
Contributing
Contributions are welcome! Please read our Contributing Guidelines before submitting a pull request.
Development
Setup
# Install with dev dependencies
pip install -e ".[dev]"
# Install the pre-push git hook
./scripts/install-hooks.sh
Running Tests
# Run all tests
pytest
# Run with verbose output
pytest -v
# Run with coverage report
pytest --cov=devopstoolbox --cov-report=html
# Run specific test file
pytest tests/test_pods.py
# Run specific test class
pytest tests/test_pods.py::TestPodsListCommand
# Run specific test
pytest tests/test_pods.py::TestPodsListCommand::test_list_pods_default_namespace
Code Quality
The project uses Ruff for linting and formatting, and pytest for testing.
# Check for linting issues
ruff check .
# Fix auto-fixable issues
ruff check --fix .
# Format code
ruff format .
All tests must pass before pushing code.
Git Hooks
A pre-push hook automatically runs tests before each push to ensure code quality:
# Install the hook (one-time setup)
./scripts/install-hooks.sh
# The hook will run automatically on git push
# If tests fail, the push will be rejected
To bypass the hook (not recommended):
git push --no-verify
License
See LICENSE file for details.
Author
George Farias (georgesouzafarias@gmail.com)
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 devopstoolbox-1.0.0b1.tar.gz.
File metadata
- Download URL: devopstoolbox-1.0.0b1.tar.gz
- Upload date:
- Size: 37.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0253c98d140049af90b08a0db953f7cec26b79024184dd9a45dbeea718e870f4
|
|
| MD5 |
5fa10565d222e4000c6aabda7ba57a02
|
|
| BLAKE2b-256 |
7d6bf9ae8e9af32bfaedb7c55bb789e7dbf7f294c1052ac3b36bd50f89df6351
|
Provenance
The following attestation bundles were made for devopstoolbox-1.0.0b1.tar.gz:
Publisher:
publish.yml on georgesouzafarias/DevOpsToolbox
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
devopstoolbox-1.0.0b1.tar.gz -
Subject digest:
0253c98d140049af90b08a0db953f7cec26b79024184dd9a45dbeea718e870f4 - Sigstore transparency entry: 814112462
- Sigstore integration time:
-
Permalink:
georgesouzafarias/DevOpsToolbox@bf64dd0202bf5ee0a88740c771330500a5595c33 -
Branch / Tag:
refs/tags/v1.0.0b1 - Owner: https://github.com/georgesouzafarias
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@bf64dd0202bf5ee0a88740c771330500a5595c33 -
Trigger Event:
release
-
Statement type:
File details
Details for the file devopstoolbox-1.0.0b1-py3-none-any.whl.
File metadata
- Download URL: devopstoolbox-1.0.0b1-py3-none-any.whl
- Upload date:
- Size: 19.2 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 |
a7f735e02c54193e1ae19623371cba626205706f4a0a7032650499f3b719ee54
|
|
| MD5 |
2917ee547183be4e0f94b11cd4a83d3b
|
|
| BLAKE2b-256 |
44158cfcbe729d3ed98d0b77ae1e34a111c7ab436cdb15e8cdf57864803657ea
|
Provenance
The following attestation bundles were made for devopstoolbox-1.0.0b1-py3-none-any.whl:
Publisher:
publish.yml on georgesouzafarias/DevOpsToolbox
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
devopstoolbox-1.0.0b1-py3-none-any.whl -
Subject digest:
a7f735e02c54193e1ae19623371cba626205706f4a0a7032650499f3b719ee54 - Sigstore transparency entry: 814112466
- Sigstore integration time:
-
Permalink:
georgesouzafarias/DevOpsToolbox@bf64dd0202bf5ee0a88740c771330500a5595c33 -
Branch / Tag:
refs/tags/v1.0.0b1 - Owner: https://github.com/georgesouzafarias
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@bf64dd0202bf5ee0a88740c771330500a5595c33 -
Trigger Event:
release
-
Statement type: