Draft
Conversation
Demonstrates: - Creating, reading, updating, and deleting ConfigMaps - Listing resources with filtering - Using create_or_update_k8s_resource for upsert operations - Proper async/await patterns with kubesdk
b9fca21 to
325fc86
Compare
Documents required changes to examples when upgrading to kubesdk v0.1.0: - path_picker module removed, exports moved to root - new replace_() function for deep nested updates - updated import patterns for consistency
- add proper return type hints to all functions - remove unnecessary namespace fetch in authentication example (login checks API access) - remove unused imports: NotFoundError, DeleteOptions
- add 03_request_config.py: timeouts, retries, logging configuration - rename 03_deployments.py -> 04_deployments.py - rename 04_watching.py -> 05_watching.py New order: 01_quickstart - CRUD basics 02_authentication - login patterns 03_request_config - client configuration 04_deployments - complex resources + patching 05_watching - event streaming
Covers: - strategic merge patch with built_from_latest - selective field updates with path picker - nested field updates - full replacement (PUT) with force=True - JSON patch with conflict guards - conflict handling with retry pattern
examples/02_authentication.py
Outdated
| import asyncio | ||
| import os | ||
|
|
||
| from kubesdk.login import login, KubeConfig |
Member
There was a problem hiding this comment.
from kubesdk import login, KubeConfig, ServerInfoCovers: - connecting to clusters via kubeconfig contexts - server= parameter for targeting specific clusters - parallel queries across clusters
Shows: typed exceptions, return_api_exceptions, Status object parsing, batch error aggregation, and login error handling
Demonstrates asyncio.gather for parallel operations and label selectors for batch queries
Shows how to define K8sResource class for CRDs and perform CRUD operations
examples/09_batch_operations.py
Outdated
Member
There was a problem hiding this comment.
this is basic Python, isn't needed here
examples/08_error_handling.py
Outdated
Member
There was a problem hiding this comment.
this is basic Python, isn't needed as a separate example
examples/10_custom_resources.py
Outdated
| patch_strategies_: ClassVar[set] = {PatchRequestType.merge} | ||
|
|
||
| metadata: ObjectMeta = field(default_factory=ObjectMeta) | ||
| spec: dict | None = None |
Member
There was a problem hiding this comment.
this isn't a valid spec, but I'm gonna write a separate md file on extending kubesdk with CRDs anyway
examples/02_authentication.py
Outdated
| await default_login() | ||
|
|
||
| # Check connection details | ||
| await check_connection_info() |
Member
There was a problem hiding this comment.
Should be merged into auth example
examples/02_authentication.py
Outdated
| # Check connection details | ||
| await check_connection_info() | ||
|
|
||
| # Uncomment to test other patterns: |
Member
There was a problem hiding this comment.
should be no "uncomment something" sections in examples
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Comprehensive examples demonstrating kubesdk features:
Also includes:
examples/README.mdwith key patterns and usage guideTest plan