Skip to main content

openshift-python-wrapper (wrapper)

📖 Full Documentation

Pypi: openshift-python-wrapper
A python wrapper for kubernetes-python-client with support for RedHat Container Virtualization
Docs: openshift-python-wrapper docs

The wrapper offers a simple and intuitive interface for interacting with the API.
It standardizes how to work with cluster resources and offers unified resource CRUD (Create, Read, Update, and Delete) flows.
The wrapper also provides additional capabilities, such as resource-specific functionality that otherwise needs to be implemented by users.
The wrapper makes code easier to read and maintain over time.

One example of simplified usage is interacting with a container.
Running a command inside a container requires using Kubernetes stream, handling errors, and more.
The wrapper handles it all and provides simple and intuitive functionality — see Executing Commands in Pods and Retrieving Logs.

Both developers or testers can use the wrapper. The code is modular and easy to maintain.
Instead of writing custom code for every API, you can use the wrapper that provides a consistent interface for interacting with APIs.
It saves time, avoids code duplications, and reduces the chance of errors.

Using Python capabilities, context managers can provide out-of-the-box resource creation and deletion,
and inheritance can be used to extend functionality for specific use cases.
Pytest fixtures can utilize the code for setup and teardown, leaving no leftovers.
Resources can even be saved for debugging.
Resource manifests and logs can be easily collected.

Installation

Requires Python 3.11-3.14.

From source:

git clone https://github.com/RedHatQE/openshift-python-wrapper.git
cd openshift-python-wrapper
uv sync

To use the wrapper in another project:

uv pip install /path/to/openshift-python-wrapper

From Pypi:

uv pip install openshift-python-wrapper

Fake Kubernetes Client

The project includes a comprehensive fake Kubernetes client for testing without a real cluster. See Fake Kubernetes Client documentation for details.

MCP Server

The project includes an MCP (Model Context Protocol) server that exposes OpenShift/Kubernetes functionality through a standardized interface. See MCP Server documentation for details.

Release new version

requirements

  • Export GitHub token
export GITHUB_TOKEN=<your_github_token>
sudo npm install --global release-it
npm install --save-dev @release-it/bumper

usage

  • Create a release, run from the relevant branch.
    To create a 4.11 release, run:
git checkout v4.11
git pull
release-it # Follow the instructions

docs

Hosted on GitHub Pages openshift-python-wrapper

PR dependency

For PR dependency we use dpulls
To make PR depends on other PR add depends on #<PR NUMBER> in the PR description.

Logging configuration

To change log level export OPENSHIFT_PYTHON_WRAPPER_LOG_LEVEL:

export OPENSHIFT_PYTHON_WRAPPER_LOG_LEVEL=<LOG_LEVEL> # can be: "DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"
  • By default some sensitive information is hashed in the logs, and if running with DEBUG the log output can be corrupted.
    In secure environments user can set OPENSHIFT_PYTHON_WRAPPER_HASH_LOG_DATA="false" environment variable to disable the log hashing.

    export OPENSHIFT_PYTHON_WRAPPER_HASH_LOG_DATA="false"
    

Proxy Enablement

This configuration allows the client to route traffic through a specified proxy server.

To enable proxy configuration for the client:

  1. Define either HTTPS_PROXY or HTTP_PROXY environment variable with your proxy URL:
export HTTPS_PROXY="http://proxy.example.com:8080"
# or
export HTTP_PROXY="http://proxy.example.com:8080"

Code check

We use prek for code check.

prek install

Some code examples locate at examples directory

Adding Tests for New Resources

Add tests

Generate automated tests for newly added resources using the test generator:

Note: Tests are only generated for classes that were generated by class-generator.

# Generate tests for a specific resource
uv run tests/scripts/generate_pytest_test.py --kind ResourceName

# Generate tests for multiple resources
uv run tests/scripts/generate_pytest_test.py --kind Pod,Service,Deployment

# Preview generated tests without writing files
uv run tests/scripts/generate_pytest_test.py --kind ResourceName --dry-run

The generator creates standard CRUD tests in tests/test_resources/test_resource_name.py using the fake client for isolated testing without requiring a real Kubernetes cluster.

Run the generated tests:

# Run tests for specific resource
uv run --group tests pytest tests/test_resources/test_resource_name.py

# Run all resource tests
uv run --group tests pytest tests/test_resources/

Contribute to the project

To contribute new additions or changes to the project, please refer to the contribution guide first.

Metadata

Release files for openshift-python-wrapper 5.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for openshift-python-wrapper 5.0.0
File Size Uploaded Provenance Actions
openshift_python_wrapper-5.0.0.tar.gz 8.6 MB Without provenance Details for openshift_python_wrapper-5.0.0.tar.gz

Release files / openshift_python_wrapper-5.0.0.tar.gz

Download URL openshift_python_wrapper-5.0.0.tar.gz
Size 8.6 MB
Tags Source
SHA-256 checksum
How to use checksums
f3b7b8b2317936b4ce631801cd36f646a003b2428ef732976c63fab8c9c32303
BLAKE2b-256 checksum
How to use checksums
aedd948bfd2b82cd2f78571b5e04405c2fda25dfdd13d3b098c3c7396f0bee0a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Security for openshift-python-wrapper 5.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

5.0.0 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page