Update the Kubernetes Python Client
This document outlines the process for updating the Kubernetes Python client.
Steps:
Run the Update Script:
Before making any API changes, run the update client script to ensure there are no unintentional changes.
scripts/update-client.sh
Note: If there are any API changes, commit them to the master branch first and then run the script again.
Update Release Notes:
Ensure that the change logs are up to date in the
devel/release.md
file. Review commits made after the last release and update the change logs accordingly.Create a Release Branch:
After merging a new snapshot, create a release branch from the master branch:
git checkout master git checkout -b release-x.y
Cherry-Pick Changes (for Patch Releases):
For patch releases, use the
cherry_pick_pull.sh
script to cherry-pick changes from the master branch into the release branch:scripts/cherry_pick_pull.sh
Note: Do not merge master into a stable release branch.
Update Local Branch:
After merging the cherry-pick PR, update your local release branch:
git checkout release-x.y git fetch upstream git rebase upstream/release-x.y
Release Types:
There are several release types for the Kubernetes Python client:
- Snapshot: A preliminary release that includes the latest changes.
- Alpha (a1): The first stable release candidate, typically released two weeks after the snapshot.
- Beta (b1): A more polished release candidate, typically released two weeks after the alpha.
- Final Release: The final, stable release of a version.
Release Process:
The release process involves the following steps:
- Create or Update Release Branch: Create a release branch based on the latest snapshot or use an existing release branch.
- Update Release Tags: Update the release tags based on the chosen release type.
- Create and Upload Distribution Packages: Create distribution packages and upload them to PyPI.
API Changes:
When making API changes, ensure that the changes are documented in the change logs and the API documentation.
Examples:
Patching a LeaseCandidate: The following code snippet demonstrates how to patch a LeaseCandidate resource using the Kubernetes Python client:
from kubernetes.client import CoordinationV1alpha1Api api_instance = CoordinationV1alpha1Api() body = { # V1alpha1LeaseCandidate "spec": { "lease_duration_seconds": 120 } } pretty = 'pretty_example' dry_run = 'dry_run_example' field_manager = 'field_manager_example' field_validation = 'field_validation_example' force = True name = 'name_example' namespace = 'namespace_example' try: api_response = api_instance.patch_namespaced_lease_candidate( name=name, namespace=namespace, body=body, pretty=pretty, dry_run=dry_run, field_manager=field_manager, field_validation=field_validation, force=force, ) pprint(api_response) except ApiException as e: print("Exception when calling CoordinationV1alpha1Api->patch_namespaced_lease_candidate: %s\n" % e)
Updating a DaemonSet Update Strategy: The following code snippet demonstrates how to update the update strategy of a DaemonSet resource:
from kubernetes.client import V1DaemonSetUpdateStrategy, V1RollingUpdateDaemonSet update_strategy = V1DaemonSetUpdateStrategy( rolling_update=V1RollingUpdateDaemonSet(max_unavailable=1), type='RollingUpdate' ) # Use the update_strategy object to update the DaemonSet resource
Documentation:
- Kubernetes Python Client Release Process
- Kubernetes Python Client API Documentation
- Kubernetes Python Client API Models
Source Code:
- Update Client Script
- REST Client Patch
- DaemonSet Update Strategy Model
- Rolling Update DaemonSet Model
## Top-Level Directory Explanations
<a class='local-link directory-link' data-ref="doc/" href="#doc/">doc/</a> - This directory contains documentation files for the project.
<a class='local-link directory-link' data-ref="doc/source/" href="#doc/source/">doc/source/</a> - This directory contains the source files for the documentation.
<a class='local-link directory-link' data-ref="examples/" href="#examples/">examples/</a> - This directory contains example usage of the Kubernetes client library.
<a class='local-link directory-link' data-ref="examples/dynamic-client/" href="#examples/dynamic-client/">examples/dynamic-client/</a> - This directory contains examples of using the dynamic client to interact with Kubernetes.
<a class='local-link directory-link' data-ref="examples/watch/" href="#examples/watch/">examples/watch/</a> - This directory contains examples of using the watch function to monitor Kubernetes resources.
<a class='local-link directory-link' data-ref="kubernetes/" href="#kubernetes/">kubernetes/</a> - This directory contains the main Kubernetes client library.
<a class='local-link directory-link' data-ref="kubernetes/base/" href="#kubernetes/base/">kubernetes/base/</a> - This directory contains the base Kubernetes client library.
<a class='local-link directory-link' data-ref="kubernetes/base/config/" href="#kubernetes/base/config/">kubernetes/base/config/</a> - This directory contains configuration files for the base library.
<a class='local-link directory-link' data-ref="kubernetes/base/dynamic/" href="#kubernetes/base/dynamic/">kubernetes/base/dynamic/</a> - This directory contains the dynamic client implementation for the base library.
<a class='local-link directory-link' data-ref="kubernetes/base/hack/" href="#kubernetes/base/hack/">kubernetes/base/hack/</a> - This directory contains hack files for the base library.
<a class='local-link directory-link' data-ref="kubernetes/base/leaderelection/" href="#kubernetes/base/leaderelection/">kubernetes/base/leaderelection/</a> - This directory contains the leader election implementation for the base library.
<a class='local-link directory-link' data-ref="kubernetes/base/stream/" href="#kubernetes/base/stream/">kubernetes/base/stream/</a> - This directory contains the stream implementation for the base library.
<a class='local-link directory-link' data-ref="kubernetes/base/watch/" href="#kubernetes/base/watch/">kubernetes/base/watch/</a> - This directory contains the watch implementation for the base library.
<a class='local-link directory-link' data-ref="kubernetes/client/" href="#kubernetes/client/">kubernetes/client/</a> - This directory contains the top-level client for the Kubernetes client library.
<a class='local-link directory-link' data-ref="kubernetes/client/api/" href="#kubernetes/client/api/">kubernetes/client/api/</a> - This directory contains the API definitions for the client library.
<a class='local-link directory-link' data-ref="kubernetes/client/apis/" href="#kubernetes/client/apis/">kubernetes/client/apis/</a> - This directory contains the API implementations for the client library.
<a class='local-link directory-link' data-ref="kubernetes/client/models/" href="#kubernetes/client/models/">kubernetes/client/models/</a> - This directory contains the data models used by the client library.
<a class='local-link directory-link' data-ref="kubernetes/e2e_test/" href="#kubernetes/e2e_test/">kubernetes/e2e_test/</a> - This directory contains end-to-end tests for the Kubernetes client library.
<a class='local-link directory-link' data-ref="scripts/" href="#scripts/">scripts/</a> - This directory contains scripts used in the development and build process.
<a class='local-link directory-link' data-ref="scripts/util/" href="#scripts/util/">scripts/util/</a> - This directory contains utility scripts.