Python: ApiException and 404 response when calling CustomObjectsApi

Created on 5 Sep 2019  路  3Comments  路  Source: kubernetes-client/python

What happened (please include outputs or screenshots):
When I try to call this API I get an ApiException and the request fails. Here is the error output:

Traceback (most recent call last):
  File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/Users/zach/Documents/dzd2/examples/custom_object.py", line 93, in <module>
    main()
  File "/Users/zach/Documents/dzd2/examples/custom_object.py", line 65, in main
    body=my_resource,
  File "/usr/local/lib/python3.7/site-packages/kubernetes/client/apis/custom_objects_api.py", line 178, in create_namespaced_custom_object
    (data) = self.create_namespaced_custom_object_with_http_info(group, version, namespace, plural, body, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/kubernetes/client/apis/custom_objects_api.py", line 277, in create_namespaced_custom_object_with_http_info
    collection_formats=collection_formats)
  File "/usr/local/lib/python3.7/site-packages/kubernetes/client/api_client.py", line 334, in call_api
    _return_http_data_only, collection_formats, _preload_content, _request_timeout)
  File "/usr/local/lib/python3.7/site-packages/kubernetes/client/api_client.py", line 168, in __call_api
    _request_timeout=_request_timeout)
  File "/usr/local/lib/python3.7/site-packages/kubernetes/client/api_client.py", line 377, in request
    body=body)
  File "/usr/local/lib/python3.7/site-packages/kubernetes/client/rest.py", line 266, in POST
    body=body)
  File "/usr/local/lib/python3.7/site-packages/kubernetes/client/rest.py", line 222, in request
    raise ApiException(http_resp=r)
kubernetes.client.rest.ApiException: (404)
Reason: Not Found
HTTP response headers: HTTPHeaderDict({'Audit-Id': 'e1e34583-bc4d-45e2-96ec-9072d3624586', 'Content-Type': 'text/plain; charset=utf-8', 'X-Content-Type-Options': 'nosniff', 'Date': 'Thu, 05 Sep 2019 18:18:33 GMT', 'Content-Length': '19'})
HTTP response body: 404 page not found

What you expected to happen:
To not receive an error and the API to be called.

How to reproduce it (as minimally and precisely as possible):
Copy the custom_object.py file from the examples folder in this repo and try to run it with python3.7.4, you should get the same error.

Anything else we need to know?:

Environment:

  • Kubernetes version (kubectl version):
Client Version: version.Info{Major:"1", Minor:"15", GitVersion:"v1.15.1", GitCommit:"4485c6f18cee9a5d3c3b4e523bd27972b1b53892", GitTreeState:"clean", BuildDate:"2019-07-18T09:18:22Z", GoVersion:"go1.12.5", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"12+", GitVersion:"v1.12.8-gke.10", GitCommit:"f53039cc1e5295eed20969a4f10fb6ad99461e37", GitTreeState:"clean", BuildDate:"2019-06-19T20:48:40Z", GoVersion:"go1.10.8b4", Compiler:"gc", Platform:"linux/amd64"}
  • OS (e.g., MacOS 10.13.6): MacOS 10.14.5
  • Python version (python --version) Python3.7.4
  • Python client version (pip list | grep kubernetes) 10.0.1
kinbug

Most helpful comment

I am dumb

All 3 comments

Have you applied the yaml manifest first?

I am dumb

Use python to call kubernetes client. The official demos are all wrong. Always ApiException 404

Was this page helpful?
0 / 5 - 0 ratings