How to delete a service from k8s?

12/28/2020

I have a service running in minikube cluster:

$ kubectl get service
NAME         TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)   AGE
kubernetes   ClusterIP   10.96.0.1    <none>        443/TCP   4s

I tried to delete the service:

$ kubectl delete --all services --all-namespaces
service "kubernetes" deleted

$ kubectl get service
NAME         TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)   AGE
kubernetes   ClusterIP   10.96.0.1    <none>        443/TCP   2s

It is deleted but it restarts by itself. I have deleted all pod and deployment. But what makes the service restart? How can I delete the whole service?

-- Joey Yi Zhao
kubernetes

1 Answer

12/28/2020

You can not delete the kubernetes service. Even if you delete it it will be re-created by kubernetes control plane. This service points to Kubernetes API Server pods and does not make sense to be deleted by users because that can render many other critical components that depends on this service non-functional.

-- Arghya Sadhu
Source: StackOverflow