feat(scanner): kubernetes plugin support + generic provider options#169
Draft
glenngillen wants to merge 8 commits into
Draft
feat(scanner): kubernetes plugin support + generic provider options#169glenngillen wants to merge 8 commits into
glenngillen wants to merge 8 commits into
Conversation
…es-cluster-from Add a cluster resolver and wire it into scan. Pointing --kubernetes-cluster-from at the Terraform that defines the cluster (e.g. an EKS module, often a separate repo) derives the node pools and prices Kubernetes workloads against them. - internal/cluster: Config schema (mirrors the provider's contract) + FromTerraformTree (walks AWS.EKS.NodeGroups -> compute pools: instance family, count, spot) + ResolveFromDir (drives a Terraform parse of the target dir). Tested with a tree mirroring a real EKS managed-node-group setup. - scanner: after plugins are installed, resolve the cluster and expose it to the kubernetes provider via INFRACOST_KUBERNETES_CLUSTER (the plugin subprocess inherits it). Best-effort: logs and continues uncosted if the cluster can't be resolved. The same resolver is intended for reuse by Infracost Cloud, which can join app repos to their cluster repos across the org.
ComputePool.InstanceType -> InstanceTypes; FromTerraformTree collects every instance family in an EKS node group so the provider can price the cheapest (diversified Spot pools rarely run the first/newest type).
…ect dir --kubernetes-cluster-from pointed the terraform parser's RepoDirectory at the project dir (e.g. infra/prod), so sibling local modules (../modules/base, which holds the EKS module) were rejected as 'not within the repository' and no node groups were found. Set RepoDirectory to dir's enclosing git repo so local modules load.
applyKubernetesCluster resolved the cluster via the shared plugin manager, which connects (launches) every plugin — including the kubernetes provider — on first use. Setting INFRACOST_KUBERNETES_CLUSTER after that point never reached the provider, since a subprocess's environment is fixed at launch, so K8s workloads always costed $0. Resolve on a dedicated short-lived manager so the shared manager (which runs pricing) connects only later, after the env var is set, and its provider subprocess inherits it.
Read k8s_labels/k8s_taints raw attributes the terraform parser now emits for EKS node groups into ComputePool Labels/Taints, normalizing taint effects (NO_SCHEDULE -> NoSchedule). Enables taint/label-aware pod->pool matching for resolver-derived clusters.
Reset tears down the plugin manager so the next EnsurePlugins re-runs install + discovery and reconnects, letting the language server recover from a transient install failure or dropped connection without a restart. Also downgrade the no-pricing-enum provider log from warn to debug: provider keys like "kubernetes"/"ai" are priced by their own plugin, not the typed registry, and requiredProviders no longer gates plugin invocation.
Add ScanProjectOptions.ProviderOptions (keyed by provider plugin name) and buildProviderOptions, mirroring the parser buildIaCOptions path; the per-provider loop now sets TreeInput.raw_options/raw_options_format. The scanner resolves the kubernetes cluster from --kubernetes-cluster-from and passes the JSON through ProviderOptions["infracost/kubernetes"] instead of os.Setenv. DEV replace => ../proto until the proto change is tagged/published.
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.
The CLI side of kubernetes-plugin-v2.
ScanProjectOptions.ProviderOptions+buildProviderOptions(mirrors the parserbuildIaCOptions); the provider loop setsTreeInput.raw_optionsper plugin. The scanner resolves--kubernetes-cluster-fromand passes the cluster JSON throughProviderOptions["infracost/kubernetes"]instead ofos.Setenv(env-var hack removed).Config.Reset()for long-lived hosts (LSP); quieted the no-pricing-enum provider log.Note: carries a DEV
replace github.com/infracost/proto => ../protofor the unreleasedraw_optionsproto field — CI will fail to build until infracost/proto's provider-plugin-discovery change is tagged. The multi-parser feature also needs the matching infracost/config branch published (or replaced) to take effect at runtime.