13

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.

Damien Gu
  • 77
  • 8
XYZ_Allen
  • 253
  • 2
  • 3
  • 15

2 Answers2

27

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
cclloyd
  • 8,171
  • 16
  • 57
  • 104
jaxxstorm
  • 12,422
  • 5
  • 57
  • 67
10

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
  • 58,485
  • 12
  • 111
  • 141