python icon indicating copy to clipboard operation
python copied to clipboard

How to list nodes in k8s python client with multiple labels?

Open nileshsalpe opened this issue 3 years ago • 8 comments

Link to the issue (please include a link to the specific documentation or example):

Documentation list for list_node

https://k8s-python.readthedocs.io/en/stable/kubernetes.client.apis.html or https://github.com/kubernetes-client/python/blob/master/kubernetes/docs/CoreV1Api.md#list_node

Description of the issue (please include outputs or screenshots if possible):

I want to list nodes with multiple labels and values with AND condition.

Example : I want to list nodes with filter node with two labels say label_1 ='x' and label_2='y'

Question: How to create label_selector for multiple labels? is it string literal, regex or function expression as string ? is label_selector is like label_1 =x,label_2='y' ? Please provide example.

nileshsalpe avatar Feb 14 '22 22:02 nileshsalpe

As per my experimentation, following works. I expect it should be documented properly

label_selector  = 'label_1 =x,label_2=y'
v1_k8s_client.list_node(label_selector='label_1 =x, label_2=y')

nileshsalpe avatar Feb 14 '22 23:02 nileshsalpe

/assign @yliaog

roycaihw avatar Feb 28 '22 17:02 roycaihw

@nileshsalpe do you mind to create a PR for an example to document it?

yliaog avatar Feb 28 '22 23:02 yliaog

/assign @Akasurde

Akasurde avatar Mar 22 '22 13:03 Akasurde

@yliaog can I proceed with this issue, if no one's currently working on this?

Shivansh2407 avatar May 02 '22 16:05 Shivansh2407

sure, thanks.

yliaog avatar May 02 '22 16:05 yliaog

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Mark this issue or PR as rotten with /lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

k8s-triage-robot avatar Jul 31 '22 16:07 k8s-triage-robot

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

k8s-triage-robot avatar Aug 30 '22 17:08 k8s-triage-robot

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Reopen this issue with /reopen
  • Mark this issue as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close not-planned

k8s-triage-robot avatar Sep 29 '22 18:09 k8s-triage-robot

@k8s-triage-robot: Closing this issue, marking it as "Not Planned".

In response to this:

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Reopen this issue with /reopen
  • Mark this issue as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close not-planned

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

k8s-ci-robot avatar Sep 29 '22 18:09 k8s-ci-robot