# Kubelet eviction policy

**URL:** <https://discuss.kubernetes.io/t/kubelet-eviction-policy/29688>\
**Category:** microk8s\
**Created:** [September 9, 2024, 6:21am UTC](https://discuss.kubernetes.io/t/kubelet-eviction-policy/29688 "2024-09-09T06:21:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![T-Lakshmi](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/t-lakshmi/32/15741_2.png) [@T-Lakshmi](https://discuss.kubernetes.io/u/T-Lakshmi)\
**Post date:** [September 9, 2024, 6:21am UTC](https://discuss.kubernetes.io/t/kubelet-eviction-policy/29688/1 "2024-09-09T06:21:20Z")

</div>

Hello folks,  
I was trying to implement Container garbage collection policy in k8s and found that it was already deprecated in favour of evictionHard and evictionSoft fatures.

> <https://github.com/kubernetes/kubernetes/issues/127157>
>
> \### What happened?
> 
> Iam trying to disable maxPerPodContainer feature in my clust…er. To achieve this followed the docs \[Container garbage collection\](https://kubernetes.io/docs/concepts/architecture/garbage-collection/#container-image-garbage-collection) and gone through code related to garbage collection.
> 
> Configured Container garbage collection parameters in the kubelet config file and restarted the kubelet sucessfully.
> After that if i check, values in kubelet configuration file are persist but those are actually not reflected in cluster.
> 
> 
> 
> \### What did you expect to happen?
> 
> Container garbage collection parameters which i added in config file should reflect in cluster.
> 
> \*\*minAge:
> maxPerPodContainer: 
> maxContainers:\*\* 
> 
> \### How can we reproduce it (as minimally and precisely as possible)?
> 
> 
> 
> Ex: 
> 1. Add below values in kubelet configuration file: /var/lib/kubelet/config.yaml
> 
> \`\`\`
> minAge: "5m"
> maxPerPodContainer: 1
> maxContainers: 50
> \`\`\`
> 2. Restart kubelet service: 
> \`sudo systemctl restart kubelet\`
> Make sure kubelet restarted sucessfully: sudo systemctl status kubelet
> 
> 3. Run: kubectl proxy
> 4. Open another terminal and check whether added parameters are present in configuration or not:
> curl http://localhost:8001/api/v1/nodes/\<hostname/proxy/configz
> 
> 
> 
> 
> \### Anything else we need to know?
> 
> I tried many ways to add these parameters but no use. even these are not listed in api-resources.
> https://kubernetes.io/docs/reference/config-api/kubelet-config.v1beta1/
> https://kubernetes.io/docs/reference/command-line-tools-reference/kubelet/
> 
> Is it possible to define these values in kubelet as mentioned in \[docs\](https://kubernetes.io/docs/concepts/architecture/garbage-collection/#container-image-garbage-collection)? if possible how can we configure them?
> 
> \### Kubernetes version
> 
> \<details\>
> 
> \`\`\`console
> $ kubectl version
> Client Version: v1.30.3
> Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
> Server Version: v1.30.3
> \`\`\`
> 
> \</details\>
> 
> 
> \### Cloud provider
> 
> \<details\>
> 
> \</details\>
> 
> 
> \### OS version
> 
> \<details\>
> 
> \`\`\`console
> \# On Linux:
> $ cat /etc/os-release
> \# paste output here
> $ uname -a
> \# paste output here
> 
> \# On Windows:
> C:\\\> wmic os get Caption, Version, BuildNumber, OSArchitecture
> \# paste output here
> \`\`\`
> 
> \</details\>
> 
> 
> \### Install tools
> 
> \<details\>
> 
> \</details\>
> 
> 
> \### Container runtime (CRI) and version (if applicable)
> 
> \<details\>
> 
> \</details\>
> 
> 
> \### Related plugins (CNI, CSI, ...) and versions (if applicable)
> 
> \<details\>
> 
> \</details\>

I would like to know the deprecated reason on this.  
Also, [wikimedia website](https://github.com/wikimedia/operations-software-kubernetes/blob/master/docs/proposals/kubelet-eviction.md) mentioned container gc flags (`--maximum-dead-containers`, `--maximum-dead-containers-per-container`, `--minimum-container-ttl-duration`) deprated deprecated once old logs are stored outside of container’s context. Is k8s also following the same way of implementaion? Can you please provide me the feature plan on these?

> <https://github.com/wikimedia/operations-software-kubernetes/blob/master/docs/proposals/kubelet-eviction.md>

### Cluster information:

Kubernetes version: v1.30  
Cloud being used: bare-metal  
Host OS: ubuntu 24.04  
CNI and version:  
CRI and version:

/cc
