remove kubernetes service-catalog finalizer with cli

10/15/2018

I'm trying to provision/deprovision service instance/binding from my cloud provider (IBM cloud private), Currently, there is a bug that if the service is not deprovisioned in ICP, that leaves me the orphan service instance on my ICP environment which I can't delete even with force option. They provide a workaround solution of:

kubectl edit ServiceInstance <service-instance-name>
kubectl edit ServiceBinding <service-binding-name>

then delete the line:

...
finalizers:
    - kubernetes-incubator/service-catalog
...

and the orphan service instance/binding will get deleted properly. I'm wondering how to automate this process with bash cli (live edit + delete line + save + exit) or any alternative way.

-- XYZ_Allen
finalizer
ibm-cloud-private
kubernetes

2 Answers

10/15/2018

kubectl patch is one way. You can also use a jq/kubectl oneliner.

kubectl get ServiceInstance <service-instance-name> -o=json | \
jq '.metadata.finalizers = null' | kubectl apply -f -
-- Rico
Source: StackOverflow

10/15/2018

I'm not sure how this works with the ServiceInstance and ServiceBinding specifically, but you can use kubectl patch to update objects in place. As an example:

kubectl patch ServiceInstance <service-instance-name> -p '{"metadata":{"finalizers":null}}
-- jaxxstorm
Source: StackOverflow