Skip to content

feat(scanner): kubernetes plugin support + generic provider options#169

Draft
glenngillen wants to merge 8 commits into
mainfrom
feature/kubernetes-plugin-v2
Draft

feat(scanner): kubernetes plugin support + generic provider options#169
glenngillen wants to merge 8 commits into
mainfrom
feature/kubernetes-plugin-v2

Conversation

@glenngillen

Copy link
Copy Markdown
Contributor

The CLI side of kubernetes-plugin-v2.

  • Provider options: new ScanProjectOptions.ProviderOptions + buildProviderOptions (mirrors the parser buildIaCOptions); the provider loop sets TreeInput.raw_options per plugin. The scanner resolves --kubernetes-cluster-from and passes the cluster JSON through ProviderOptions["infracost/kubernetes"] instead of os.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 => ../proto for the unreleased raw_options proto 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.

…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant