Ubuntu actually only keeps the current and the previous kernel as necessary and give the user the option to purge all the old kernels. These old kernels will be marked as autoremovable and by setting a flag in unattended upgrades config you can make it autoremove those. On desktops this happens automatically.