Skip to content

examples: add pod_node_selector example for V1PodSpec - #2814

Open
anisayakmitra-in wants to merge 1 commit into
kubernetes-client:masterfrom
anisayakmitra-in:example-pod-node-selector
Open

anisayakmitra-in wants to merge 1 commit into
kubernetes-client:masterfrom
anisayakmitra-in:example-pod-node-selector

Conversation

@anisayakmitra-in

Copy link
Copy Markdown
Contributor

What type of PR is this?

/kind documentation

What this PR does / why we need it:

Adds an example script examples/pod_node_selector.py demonstrating how to assign a Pod to specific cluster nodes using node_selector in client.V1PodSpec.

The example covers:

  • Discovering cluster nodes and inspecting node labels (v1.list_node()).
  • Configuring client.V1PodSpec with node_selector={"kubernetes.io/os": "linux"} (mapping to spec.nodeSelector).
  • Creating the namespaced Pod via v1.create_namespaced_pod.
  • Waiting for the scheduler to bind the Pod and verifying pod.spec.node_name.
  • Cleaning up the created Pod.
  • Indexing the script in examples/README.md.

Which issue(s) this PR fixes:

Fixes #1934

Special notes for your reviewer:

None

Does this PR introduce a user-facing change?

NONE

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:

None

Signed-off-by: ANISAYAK MITRA <266799942+anisayakmitra-in@users.noreply.github.com>
@kubernetes-prow kubernetes-prow Bot added release-note-none Denotes a PR that doesn't merit a release note. kind/documentation Categorizes issue or PR as related to documentation. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Nov 28, 2026
@kubernetes-prow
kubernetes-prow Bot requested review from roycaihw and yliaog November 28, 2026 04:25
@kubernetes-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: anisayakmitra-in
Once this PR has been reviewed and has the lgtm label, please assign yliaog for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubernetes-prow kubernetes-prow Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Nov 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/documentation Categorizes issue or PR as related to documentation. release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Please can you provide an example of node_selector in V1PodSpec

1 participant