python: Unable to use create_namespaced_deployment_rollback in Kubernetes 1.16+
What happened (please include outputs or screenshots):
Got a 404 error from the Kubernetes API due to the fact that both ExtensionsV1beta1Api and AppsV1beta1Api are deprecated in Kubernetes 1.16
The recently released 12.0.0a1 is supposed to have Kubernetes 1.16 support, but also doesn’t have rollback with the proper API AppsV1Api
https://github.com/kubernetes-client/python/blob/v12.0.0a1/kubernetes/README.md
File "/usr/lib/python3.8/site-packages/kubernetes/client/apis/apps_v1beta1_api.py", line 291, in create_namespaced_deployment_rollback
(data) = self.create_namespaced_deployment_rollback_with_http_info(name, namespace, body, **kwargs)
File "/usr/lib/python3.8/site-packages/kubernetes/client/apis/apps_v1beta1_api.py", line 375, in create_namespaced_deployment_rollback_with_http_info
return self.api_client.call_api('/apis/apps/v1beta1/namespaces/{namespace}/deployments/{name}/rollback', 'POST',
File "/usr/lib/python3.8/site-packages/kubernetes/client/api_client.py", line 330, in call_api
return self.__call_api(resource_path, method,
File "/usr/lib/python3.8/site-packages/kubernetes/client/api_client.py", line 163, in __call_api
response_data = self.request(method, url,
File "/usr/lib/python3.8/site-packages/kubernetes/client/api_client.py", line 371, in request
return self.rest_client.POST(url,
File "/usr/lib/python3.8/site-packages/kubernetes/client/rest.py", line 260, in POST
return self.request("POST", url,
File "/usr/lib/python3.8/site-packages/kubernetes/client/rest.py", line 222, in request
raise ApiException(http_resp=r)
kubernetes.client.rest.ApiException: (404)
Reason: Not Found
What you expected to happen:
There should be a create_namespaced_deployment_rollback in the AppsV1Api Class so that it uses the non-deprecated API
How to reproduce it (as minimally and precisely as possible): Attempt to rollback a deployment with either API against a cluster running 1.16:
api_response = client.AppsV1beta1Api().create_namespaced_deployment_rollback(
name=deployment_name,
namespace=namespace,
body=body,
_preload_content=False)
OR
api_response = client.ExtensionsV1beta1Api().create_namespaced_deployment_rollback(
name=deployment_name,
namespace=namespace,
body=body,
_preload_content=False)
Environment:
- Kubernetes version (
kubectl version): 1.16.11 - Python version (
python --version) 3.8.5 - Python client version (
pip list | grep kubernetes) 12.0.0a1
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 2
- Comments: 16 (3 by maintainers)
An interim solution that may help others who stumble upon this issue:
Basically, I’ve reverse-engineered what
kubectl rollout unto ...appears to be doing.