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
}
If you know kubectl command to do this, just run the command with -v9 and you would see the format of selector kubectl sends to api server.
sorry,I can't find it. I have solve this problem by scanning all service to find specified service
can you post your solution here. It useful for other community members if they hit the same issue. Thanks.
I want to find service belong to the deployment,but failed depend on field_selector. The solution is that list all services to find specified one that match labels
@TracyBin Can you please reopen the issue? Looks like you have a snippet in the description that fails to work.
@dims ok, I have been reopened this issue
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')
Dose field_selector support regex?
@YitongFeng I'm afraid not, https://kubernetes.io/docs/concepts/overview/working-with-objects/field-selectors/#supported-operators
Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
If this issue is safe to close now please do so with /close.
Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale
/close
Most helpful comment
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: