remove kubernetes service-catalog finalizer with cli

牧云@^-^@ 提交于 2021-02-10 06:55:15

问题


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.


回答1:


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 -



回答2:


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}}


来源:https://stackoverflow.com/questions/52819428/remove-kubernetes-service-catalog-finalizer-with-cli

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!