Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

remove kubernetes service-catalog finalizer with cli

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.

like image 344
XYZ_Allen Avatar asked Nov 24 '25 16:11

XYZ_Allen


2 Answers

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}}' --type=merge
like image 87
jaxxstorm Avatar answered Nov 27 '25 07:11

jaxxstorm


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 -
like image 36
Rico Avatar answered Nov 27 '25 07:11

Rico



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!