Prerequisites
1
Ensure Python 3.10+ is installed
2
Install the library
3
Configure cluster access
Ensure you have a valid kubeconfig file or cluster credentials. Test your connection:
Your First Resource
Let’s create a simple Namespace resource to understand the basic workflow.The context manager pattern (
with statement) is recommended as it ensures automatic resource cleanup, even if an error occurs.Working with Pods
Pods are fundamental workload resources. Here’s how to create and interact with them:Working with Deployments
Deployments manage replica sets and pod lifecycles:Advanced Patterns
Using Resource Body
For complex resources, you can provide a complete body dictionary:Creating Multiple Resources
UseResourceList to create multiple similar resources efficiently:
Resource with Different API Groups
Some resources exist in multiple API groups:Schema Validation
The wrapper includes built-in schema validation to catch errors early:Common Operations
Wait for Conditions
Wait for resources to reach desired states:Resource Discovery
Query and filter resources:Resource Updates
Update existing resources:Error Handling
Handle common scenarios gracefully:Testing with Fake Client
Write tests without requiring a real cluster:Best Practices
Use Context Managers
Use Context Managers
Always prefer context managers (
with statements) for automatic cleanup:Enable Schema Validation
Enable Schema Validation
Catch configuration errors early:
Wait for Resource Ready State
Wait for Resource Ready State
Don’t assume immediate availability:
Use Appropriate Timeouts
Use Appropriate Timeouts
Set realistic timeouts based on resource type:
Handle Cleanup Failures
Handle Cleanup Failures
Ensure resources are cleaned up even on errors:
Next Steps
Core Concepts
Learn about resources, namespaces, and context managers
API Reference
Explore all available resource classes and methods
Advanced Testing
See real-world examples and patterns
Fake Client
Learn how to test your code with the fake client
API Reference
Explore all available resource classes and methods
Class Generator
Auto-generate resource wrappers
Testing Guide
Learn how to test your code with the fake client