feat(init): init --with-opencost — deploy OpenCost for precise Tier-2 cost#21
Merged
Conversation
…2 cost Make `kubectl tidy init` optionally install OpenCost into the cluster so scans get precise allocated cost (spot/reserved/CUD discounts) out of the box, instead of blended derived pricing — no separate OpenCost setup. - Embed a minimal OpenCost manifest (namespace, SA, ClusterRole/Binding, Deployment, Service on :9003 at opencost.opencost.svc — which kubetidy already auto-detects for Tier 2). Prometheus endpoint is templated via a placeholder. - `init --with-opencost` applies it; `--prometheus-url` points OpenCost at your Prometheus (defaults to http://prometheus-server.monitoring.svc:80). - `init --print --with-opencost` emits the manifests for GitOps instead. - `uninstall --with-opencost` removes it (off by default, so a user's own OpenCost is never touched); deleted before the operator, idempotently. - Docs: README setup + Tier 2 section, ROADMAP (producer side of Tier 2), CHANGELOG [Unreleased].
mayur-tolexo
added a commit
that referenced
this pull request
Jun 3, 2026
feat(init): bundle Prometheus + fix OpenCost RBAC (follow-up to #21)
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.
What
Make
kubectl tidy initoptionally deploy OpenCost into the cluster, so scans report precise Tier-2 cost (real node pricing — spot / reserved / committed-use discounts) out of the box, instead of blended derived pricing. Before this, Tier 2 only worked if you already ran OpenCost yourself.How it works
internal/installer/assets/opencost.yaml):Namespace,ServiceAccount, read-onlyClusterRole/ClusterRoleBinding,Deployment(ghcr.io/opencost/opencost), and aServiceon :9003 atopencost.opencost.svc— exactly the endpoint kubetidy'sDetectOpenCostalready probes, so Tier 2 lights up automatically once it's ready.--prometheus-url(defaults tohttp://prometheus-server.monitoring.svc:80).uninstall --with-opencostdeletes OpenCost (before the operator), idempotently. It's off by default so a user's own OpenCost install is never touched.--print --with-opencostemits the manifests for inspection/GitOps instead of applying.Changes
internal/installer/installer.go: embed the manifest, addIncludeOpenCost/PrometheusURLtoOptionsandIncludeOpenCosttoUninstallOptions; wireinstallOpenCostintoInstall(both code paths) and OpenCost removal intoUninstall; exportOpenCostManifest(prometheusURL)for--print.internal/cli/init.go:--with-opencost+--prometheus-urlflags,--printsupport, friendly success note.internal/cli/uninstall.go:--with-opencostflag.[Unreleased].Tests
internal/installer/opencost_test.go: manifest substitution + defaulting, object decode (6 kinds),Uninstall --with-opencostremoves it / leaves it alone by default.internal/cli/init_test.go/uninstall_test.go: new flags present;--print --with-opencostincludes the substituted manifest, omitted otherwise.Full gate green:
go build,go vet,gofmt,go test ./...,golangci-lint(0 issues).🤖 Generated with Claude Code