Not able to delete kubernetes ingress-object through kubernetes python client

2/14/2018

I am getting this error while deleting the ingress objects.

Reason: Internal Server Error
HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json', 'Content-Length': '161', 'Date': 'Wed, 14 Feb 2018 10:14:03 GMT'})
HTTP response body: {"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"no kind \"Ingress\" is registered for version \"extensions/v1beta1\"","code":500}

And this is the code snippet I'm using to perform the delete...

try:
    resp = k8s_beta.read_namespaced_ingress(name=ing_name, namespace=namespace_name)
    resp1 = k8s_beta.delete_namespaced_ingress(
        name=resp['metadata']['name'],
        body=resp,
        namespace=namespace_name)
    print("Ingress deleted. status='%s'" % str(resp1.status))
except client.rest.ApiException:
    raise client.rest.ApiException

I ensured that the ingress-object actually exists with correct API versioning.Getting similar errors while trying to delete deployment objects!

-- Abhishek
kubernetes
kubernetes-ingress
kubernetes-python-client

1 Answer

2/15/2018

The param body needs to be an instance of client.V1DeleteOptions not the config of the ingress object. body = client.V1DeleteOptions()

-- Abhishek
Source: StackOverflow