<p>I have accidentally deleted all the services in my minikube setup, including "kubernetes" service in the default namespace.</p>

<p>But within a few seconds, I noticed the "kubernetes" service created again, automatically.
If I understand corrected, the replica in deployment takes care of only pods, right?
I am wondering how this "kubernetes" service created automatically and what is the use of this service after all.</p>

<pre><code>$ kubectl get svc -owide
NAME         TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)   AGE   SELECTOR
kubernetes   ClusterIP   10.96.0.1    &lt;none&gt;        443/TCP   13m   &lt;none&gt;

$ kubectl delete svc kubernetes                              
service "kubernetes" deleted

$ kubectl get svc -owide
NAME         TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)   AGE   SELECTOR
kubernetes   ClusterIP   10.96.0.1    &lt;none&gt;        443/TCP   3s    &lt;none&gt;
</code></pre>

<p>Is there a way we can implement the same functionality for our own service?</p>

<p>E.g. whenever it gets deleted, it should be recreated automatically.</p>

<p>Kuberneetes API server will recreate it. You can check below line in the logs of Kubernetes API Server right after you delete the service.</p>

<pre><code>Resetting endpoints for master service "kubernetes" to
</code></pre>

<p>This service is used when you want to interact with Kubernetes API Server from pods using a service account.</p>

<p>Check the <a href="https://github.com/kubernetes/kubernetes/blob/abe6321296123aaba8e83978f7d17951ab1b64fd/pkg/master/controller.go" rel="nofollow noreferrer">source code</a>.</p>
