Features
Full CRUD Operations
Create, Read, Update, and Delete operations for all resources
Custom Resources
Support for standard Kubernetes resources and CRDs
Label & Field Selectors
Filter resources using labels and field selectors
Watch Operations
Watch functionality with event generation
Realistic Status
Automatic status generation for resources
Namespace Support
Full namespace isolation and management
Installation & Setup
The fake client is included withopenshift-python-wrapper. To use it in your tests:
Basic Usage
Creating Resources
Create resources using standard Kubernetes manifests:Listing Resources
Updating Resources
Deleting Resources
Watch Operations
Configuring Resource Ready Status
You can configure resources to be in a “not ready” state for testing failure scenarios.Using Annotations
Add thefake-client.io/ready annotation to any resource:
For Pods specifically, you can also use
fake-client.io/pod-ready annotation for backward compatibility.Using Spec Field
Alternatively, usereadyStatus in the spec:
Resource-Specific Behavior
Different resources behave differently when not ready:Pods
Pods
Show as not ready with containers in waiting state:
status.phase:Pending- Container states show as
waiting - Ready condition is
False
Deployments
Deployments
Show 0 ready replicas and unavailable condition:
status.readyReplicas:0status.availableReplicas:0- Available condition is
False
Namespaces
Namespaces
Show as Terminating phase:
status.phase:Terminating
Other Resources
Other Resources
Show Ready condition as False:
- Ready condition set to
False - Resource-specific status fields reflect not-ready state
Custom Resources
The fake client automatically supports any Custom Resource:Advanced Features
Automatic Namespace Creation
Namespaces are automatically created when you create resources in non-existent namespaces:Realistic Resource Status
Resources automatically get realistic status fields:OpenShift Resources
The client includes OpenShift-specific resources:Testing Patterns
Using Pytest Fixtures
Testing Resource Lifecycle
Testing Error Conditions
Limitations
No Real Execution
No Real Execution
No real networking or pod execution occurs. Containers don’t actually run.
Simplified Watch
Simplified Watch
Watch implementation provides immediate events only, not continuous streaming.
Limited Field Selectors
Limited Field Selectors
Only
metadata.name and metadata.namespace field selectors are supported.No Admission Control
No Admission Control
No admission webhooks or validation beyond basic structure checking.
Simplified Status
Simplified Status
Status updates are simplified and may not reflect all real-world complexities.
Complete Testing Example
Next Steps
Testing Guide
Learn comprehensive testing patterns and best practices
Class Generator
Generate wrapper classes for your resources