k3s-server uses 10% CPU for no reason

no_connection

Patron
Joined
Dec 15, 2013
Messages
480
From what I can see this is Kubernetes but I have not configured any functions on SCALE at all except an empty smb share.
I don't find anything about Kubernetes in GUI at all, no way to turn it off and no reason for it to be there in the first place?

Code:
    PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND
  10187 root      20   0 2484124 634260  59636 S  11.8   7.8 467:56.94 k3s-server
4161039 root      20   0    9320   3768   2952 R   5.9   0.0   0:00.02 top
      1 root      20   0  167808   9120   5372 S   0.0   0.1   0:29.76 systemd
 

shadofall

Contributor
Joined
Jun 2, 2020
Messages
100
k3s should only be running if you've gone to Apps and set a pool for Apps, that would start k3s
 

no_connection

Patron
Joined
Dec 15, 2013
Messages
480
It did force me to set a pool for something when I was going through the menu but I have no apps or anything. This is a new test install.
*edit* I did find and unset pool and it's gone, thanks.
Seems to be fine when hitting cancel as well. Except that is asks you every time you go there, so I guess not as fine. And probably bad sine ppl will do that and waste CPU since it politely tell you you have to set it.
 
Last edited:

shadofall

Contributor
Joined
Jun 2, 2020
Messages
100
It did force me to set a pool for something when I was going through the menu but I have no apps or anything. This is a new test install.
yup once you set the pool. k3s was deployed and started. and as a note. the %CPU in top is an additive of per core/thread the process is running against. so at most that would be 11.8% of a single thread so depeding on number of cores/threads that would be less than could be <1% of entire CPU

you can delete the dataset it created on the pool, to stop it.
 

no_connection

Patron
Joined
Dec 15, 2013
Messages
480
It was using 10% of total CPU of two cores. I don't think top is accurate since GUI was also showing 50-100% usage of something when top was not showing anything else.
Regardless what it was it did cause 10% usage to happen even if it caused other processes or stuff to do work that was not seen in top.
 

no_connection

Patron
Joined
Dec 15, 2013
Messages
480
Used CPU cycles is used CPU cycles no matter where. Nothing different about VM here.
 

dirtyfreebooter

Explorer
Joined
Oct 3, 2020
Messages
72
yea, i am still seeing this today. k3s-server on idle is using 5% to 20% of the cpu when literally the system is idle, whether i have any apps running or created (but stopped). its kinda annoying as hell, all the complexity of k8s .. that extra CPU is wasted in both terms of idle power and cpu that could actually go to the apps.

i wish there was a way to just use native docker on a single host NAS instead of k3s. k3s supposed to be the lightweight k8s .. hah
 

Attachments

  • k3s-server.png
    k3s-server.png
    306 KB · Views: 325

fa2k

Dabbler
Joined
Jan 9, 2022
Messages
34
I'm using 6 apps, so it's a bit different, but I was just going to post about the somewhat high CPU usage of k3s server. My k3s server process is using 25 % of a core on average on Xeon E5-2697 v2 (somewhat old).

Code:
root       10256 24.6  0.5 6728472 729624 ?      Ssl  Mar18 247:54 /usr/local/bin/k3s server


Not sure if it's a problem or if it's supposed to be like that.
 

bzzjh

Dabbler
Joined
Mar 17, 2022
Messages
15
i have same issues,truenas scale install on my HPE gen10 plus server
 

Attachments

  • 1.JPG
    1.JPG
    62.8 KB · Views: 281

xiazuojie

Cadet
Joined
Dec 14, 2017
Messages
4
I was also annoyed by k3s constantly using about 10% CPU. Kubernetes is overkill for my single-node personal home NAS. I'd rather use vanilla docker.

Here's the trick I use to get rid of k3s while still having containers running.
* Set up containers with the built-in Apps web UI.
* Stop the k3s service with command 'systemctl stop k3s.service'.
Containers continue to work without k3s server, though the Apps web UI doesn't.
Whenever I need to set up new containers, I run 'systemctl start k3s.service' to enable the Apps web UI again.

What's more, I added a Post Init script (in System Settings -> Advanced -> Init/Shutdown Scripts) to stop k3s service automatically after boot:
'sleep 10m && systemctl stop k3s.service'.
 

Glowtape

Dabbler
Joined
Apr 8, 2017
Messages
45
I just drop to the shell and use docker there. You just need to remember to backup daemon.json and key.json in /etc/docker before an update, because those get nuked.

Why Kubernetes needs to spin up a whole CPU core for doing god knows what, when ran as single node, no one has been able to answer so far. Listening for signals ought to be enough for whatever it needs to monitor in that scenario.
 

e7balt

Cadet
Joined
May 6, 2021
Messages
5
I was seeing the CPU usage issue with k3s also. Since I'm not using apps I just unset the pool for apps and that solved the CPU usage issue for me.

I did do a quick search and found the following discussion: https://github.com/k3s-io/k3s/issues/2375

Assuming it is the same issue it looks like this isn't specific to TrueNAS Scale.
 

appliance

Explorer
Joined
Nov 6, 2019
Messages
96
in my case, the Apps works after the power hungry k3s stops. k3s takes 20% of cpu while middleware keeps ramping memory usage from 2GB to 8GB. Web UI is extremely slow (hanging for 30sec every minute). Need to figure this out or i have to reboot daily.
 

Jip-Hop

Contributor
Joined
Apr 13, 2021
Messages
118
* Stop the k3s service with command 'systemctl stop k3s.service'.
Containers continue to work without k3s server, though the Apps web UI doesn't.
Thanks for this tip! I was also seeing constant >10% CPU usage and the power draw from my server wasn't dropping below 17.5W. Now, with k3s disabled it's dropping to 15.5W :)

I was using just one TrueCharts app: docker-compose. And it continued to run stopping after k3s. Since I have setup Portainer with the docker-compose app I can still spin up new containers from a GUI after k3s is disabled. I'd just have to enable k3s regularly to update the docker-compose app.
 

zsteinkamp

Cadet
Joined
Apr 3, 2023
Messages
1
I was also observing 20-80% CPU usage with the top processes being `k3s-server`. Running no apps. Disabling the app pool fixed it.

Not sure how k3s is a good choice for this use case if that is expected resource usage? 20% of a modern multicore CPU is like 5 whole servers from days past. I can't imagine that it's doing anything value/productive while it burns those watts.
 

nasBuilder

Dabbler
Joined
Mar 25, 2023
Messages
26
Has this been solved? I'm playing around with photoprism and even when nothing runs at all, this k3s process consumes 10% of the CPU doing nothing at all, which does not let the machine go down to C-State 10, it's idling around C8 which results in 3 watts consumed permanently for nothing. I'm building a low consumption solution so that's a huge bummer.
 
Last edited:
Top