<p>I installed <a href="https://github.com/kubernetes-sigs/kind" rel="nofollow noreferrer">kind</a> to play around with Kubernetes.</p>
<p>If I use <code>top</code> and sort by CPU usage (key <code>C</code>), then I see that <code>kube-apiserver</code> is constantly consuming 5 to 10% CPU.</p>
<p>Why?</p>
<p>I don't have installed something up to now:</p>
<pre><code>guettli@p15:~$ kubectl get pods --all-namespaces
NAMESPACE            NAME                                         READY   STATUS    RESTARTS   AGE
kube-system          coredns-558bd4d5db-ntg7c                     1/1     Running   0          40h
kube-system          coredns-558bd4d5db-sx8w9                     1/1     Running   0          40h
kube-system          etcd-kind-control-plane                      1/1     Running   0          40h
kube-system          kindnet-9zkkg                                1/1     Running   0          40h
kube-system          kube-apiserver-kind-control-plane            1/1     Running   0          40h
kube-system          kube-controller-manager-kind-control-plane   1/1     Running   0          40h
kube-system          kube-proxy-dthwl                             1/1     Running   0          40h
kube-system          kube-scheduler-kind-control-plane            1/1     Running   0          40h
local-path-storage   local-path-provisioner-547f784dff-xntql      1/1     Running   0          40h


guettli@p15:~$ kubectl get services --all-namespaces
NAMESPACE     NAME         TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)                  AGE
default       kubernetes   ClusterIP   10.96.0.1    &lt;none&gt;        443/TCP                  40h
kube-system   kube-dns     ClusterIP   10.96.0.10   &lt;none&gt;        53/UDP,53/TCP,9153/TCP   40h


guettli@p15:~$ kubectl get nodes
NAME                 STATUS   ROLES                  AGE   VERSION

kind-control-plane   Ready    control-plane,master   40h   v1.21.1
guettli@p15:~$ kubectl get nodes --all-namespaces
NAME                 STATUS   ROLES                  AGE   VERSION
kind-control-plane   Ready    control-plane,master   40h   v1.21.1

</code></pre>
<p>I am curious. Where does the CPU usage come from? How can I investigate this?</p>

guettli
<p>Even in an empty cluster with just one master node, there are at least 5 components that reach out to the API server on a regular basis:</p>
<ul>
<li>kubelet for the master node</li>
<li>Controller manager</li>
<li>Scheduler</li>
<li>CoreDNS</li>
<li>Kube proxy</li>
</ul>
<p>This is because API Server acts as the only entry point for all components in Kubernetes to know what the cluster state should be and take action if needed.</p>
<p>If you are interested in the details, you could enable audit logs in the API server and get a very verbose file with all the requests being made.
How to do so is not the goal of this answer, but you can start from the <a href="https://kubernetes.io/docs/reference/command-line-tools-reference/kube-apiserver/" rel="noreferrer">apiserver documentation</a>.</p>
