question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to use field_selector

See original GitHub issue

hi,I want to list service in specified namespace. I call list_namespaced_service,but output error. This is my code:


field_selector = {'spec.selector': label}   //label:   {u'app': 'admin-test'}
service = v1.list_namespaced_service(namespace='default', pretty='true', field_selector=field_selector, watch=False)

error:

ApiException: (500)
Reason: Internal Server Error
HTTP response headers: HTTPHeaderDict({'Date': 'Wed, 05 Apr 2017 03:57:23 GMT', 'Content-Length': '240', 'Content-Type': 'application/json'})
HTTP response body: {
  "kind": "Status",
  "apiVersion": "v1",
  "metadata": {},
  "status": "Failure",
  "message": "invalid selector: '{'spec.selector': {u'app': 'admin-test'}}'; can't understand '{'spec.selector': {u'app': 'admin-test'}}'",
  "code": 500
}

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:5
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

34reactions
jinglejengelcommented, Jun 28, 2017

I ran into this as well.

Reading the docs shows it is a str, but doesn’t give a good, valid, example of it anywhere.

This gets appended to a dictionary of items to pass into a raw request call down the line, in which kubernetes expects it in the form of ‘key=value’. So, for example, if I’m trying to find a secret named star-cert, the following should return the object:

kube.list_namespaced_secret('default', field_selector='metadata.name=star-cert') 
4reactions
YitongFengcommented, Oct 9, 2018

Dose field_selector support regex?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Field Selectors - Kubernetes
Using unsupported field selectors produces an error. For example: kubectl get ingress --field-selector foo.bar=baz.
Read more >
How to use Kubernetes fieldSelector to query ownerReferences
The --field-selector only works with some limited fields. Which contains: "metadata.name", "metadata.namespace", "spec.nodeName", "spec.
Read more >
How to use `FieldSelector`? How to filter Services service-side?
namespace or metadata.name as FieldSelector . Am I using this incorrectly? Is there a way to filter (e.g. Services) service-side like this? I've ......
Read more >
Kubernetes Label Selector and Field Selector - MayaData Blog
In this blog, I will explain how label and field selectors will help you in understanding how they work and how they can...
Read more >
Field Selectors - Kubernetes
Using unsupported field selectors produces an error. For example: $ kubectl get ingress --field-selector foo.bar=baz Error from server ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found