Our Kubernetes deployments often come with a ton of unnecessary packages from base images, sometimes even hundreds. This not only increases vulnerability exposure but also bloats the images, making it tough to debug runtime issues. We've tried pruning the images, but it's challenging to figure out which system libraries or language runtimes are safe to remove. Do you build minimal images from the start, or do you prefer pruning existing ones? What methods do you use to keep everything compatible with Kubernetes tools and sidecars while minimizing the attack surface?
4 Answers
It's better to tackle this at the source. Start with a minimal image and add only the dependencies you need. Test and deploy that right away. It's not really a Kubernetes issue—it’s about how you start your image.
We work with Go and use distroless base images for our builds. They keep things clean and you won't have the extra dependencies cluttering up your image.
The key is to build everything minimal from the get-go, not by trying to prune later. I recommend using multi-stage builds and going with distroless or slim base images. Make sure your app images only contain what's necessary, and treat sidecars separately for compatibility. You can catch any missing dependencies through CI with some runtime tests.
I definitely suggest using multi-stage builds for your Docker images. It helps keep them lean and focused.

Related Questions
Can't Load PhpMyadmin On After Server Update
Redirect www to non-www in Apache Conf
How To Check If Your SSL Cert Is SHA 1
Windows TrackPad Gestures