feat: Cluster-wide LimitRange module for ephemeral-storage defaults#335
Closed
sanmesh-kakade wants to merge 1 commit intomainfrom
Closed
feat: Cluster-wide LimitRange module for ephemeral-storage defaults#335sanmesh-kakade wants to merge 1 commit intomainfrom
sanmesh-kakade wants to merge 1 commit intomainfrom
Conversation
Add a Facets module that creates Kubernetes LimitRange resources across all namespaces (cluster-wide) or a specific set, with per-namespace override support. Enforces default cpu, memory, and ephemeral-storage requests/limits on containers that don't set their own. Motivated by fleet-wide investigation showing 100% of pods across 18 CP clusters have zero ephemeral-storage requests/limits set, contributing to uncontrolled disk pressure from containerd image sprawl. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
limit_range/default/1.0— a Facets module that creates Kubernetes LimitRange resources cluster-wide or to specific namespaces, enforcing default resource requests and limits on containers that don't set their own.Features
Two modes:
cluster_wide: true— applies LimitRange to all namespaces (usesdata "kubernetes_all_namespaces"), with configurableexclude_namespacesto skip specific onescluster_wide: false— applies only to explicitly listedtarget_namespacesFull LimitRange spec — configures all fields supported by
kubernetes_limit_range_v1:default— default limits injected if container doesn't set its owndefault_request— default requests injected if container doesn't set its ownmin/max— hard floor/ceiling, rejects pods outside the range at admissionmax_limit_request_ratio— rejects pods where limit/request ratio exceeds thresholdcpu,memory, andephemeral-storageNamespace overrides — per-namespace overrides merged on top of the base spec. Allows different limits for different namespaces (e.g., tighter limits for CI/CD namespaces, looser for workload namespaces)
Usage example
Caveats
data "kubernetes_all_namespaces"reads at plan time — namespaces created between applies won't get a LimitRange until the next release cycleTest plan
terraform init && terraform validatepassesspecific_namespacesmode with 1-2 namespaceskubectl get limitrange -Acluster_widemode withexclude_namespacesnamespace_overridesproduces different limits per namespace🤖 Generated with Claude Code