As stated by @Tim Hockin, The default configurations of add-ons are appropriate for typical clusters. But can be fine-tuned by changing the resource limit specification.
Before working add-on resizing, remember you can also disable unecessary add-ons for your use. This can vary a little depending on the add-on, its version, the kubernetes version, and by provider. Google has a page covering some options, the same concepts can be used in other providers too
As of the solution to the issue linked in @Tim Hockin answer, the first accepted way to do it is by using addon-resizer. It basically find out the best limits and requirements, patches the Deployment/Pod/DaemonSet and recreates the associated pods to match the new limits, but with less effort than manually all of it.
However, another more robust way to achieve that is by using Vertical Pod Autoscaler as stated by @Tim Smart answer. VPA accomplishes what addon-resizer does but it has many benefits:
- VPA is a custom resource definition of a addon itself, allowing your code to be much more compact than using addon-resizer.
- By being a custom resource definition it is also much easier to keep the implementation up to date.
- some providers (as google) run VPA resources on control-plane processes, instead of deployments on your worker nodes. Making that, even if addon-resizer is simplier, VPA uses none of your resources while addon-resizer would.
An updated template would be:
apiVersion: autoscaling.k8s.io/v1
kind: VerticalPodAutoscaler
metadata:
name: <addon-name>-vpa
namespace: kube-system
spec:
targetRef:
apiVersion: "apps/v1"
kind: <addon-kind (Deployment/DaemonSet/Pod)>
name: <addon-name>
updatePolicy:
updateMode: "Auto"
It is important to check the addons being used in your current cluster, as they can vary a lot by providers (AWS, Google, etc) and its kubernetes implementation versions
Make sure you have VPA addon installed in your cluster (most kubernetes services has it as an easy option to check)
Update policy can be Initial (only applies new limits when new pods are created), Recreate (forces pods out of spec to die and applies to new pods), Off (create recommendations but don´t apply), or Auto (currently matches Recreate, can change in the future)
The only differences on @Tim Smart answer example are that the current api version is autoscaling.k8s.io/v1
, the current api version of targets is apps/v1
, and that newer versions of some providers use FluentBit in place of Fluentd. His answer might be better suited for earlier kubernetes versions
If you are using Google Kubernetes Engine for example currently some of the "heaviest" requirement addons are:
- fluentbit-gke (DaemonSet)
- gke-metadata-server (DaemonSet)
- kube-proxy (DaemonSet)
- kube-dns (Deployment)
- stackdriver-metadata-agent-cluster-level (Deployment)
By applying VPAs on it, my addon resource requirements dropped from 1.6 to 0.4.