krr icon indicating copy to clipboard operation
krr copied to clipboard

Feature/vcluster

Open mysiki opened this issue 7 months ago • 3 comments
trafficstars

Add support of VCluster (https://www.vcluster.com/) (resolve my issue : https://github.com/robusta-dev/krr/issues/415)

VCluster (VC) work on top of physical cluster with workload sync between virtual cluster and physical cluster. During the sync, VC rename the pod to avoid naming collision. VC only sync the pod, not the other stuff like RS, Deployment, ... The sync is done on the physical namespace where vcluster is present.

Summarize design :

Physical cluster Namespace Physical cluster pod name Virtual cluster Namespace Virtual cluster pod name
vcluster-foo myappfront-1234-x-myappns-x-vclusterfooname myappns myappfront-1234
vcluster-foo myappback-123-x-myappns-x-vclusterfooname myappns myappback-123
vcluster-foo otherapp-1234-x-otherappns-x-vclusterfooname otherappns otherapp-1234
vcluster-foo otherapp-4567-x-otherappns-x-vclusterfooname otherappns otherapp-4567
vcluster-foo otherappwithreallylongnammmmme-1234567891234567891234-x-othera-f5fef5e6fe otherappns otherappwithreallylongnammmmme-1234567891234567891234

The renaming is done following algo present in added function get_vcluster_pod_real_name.

To reduce pod number and cluster load, usually metrics are read read from physical cluster (avoid to have all exporter pod inside VC).

Because of VC only sync pod, KRR need to run connected to the VC (to detect DP, STS,..). But the pod name and pod namespace in prometheus are the one present in physical cluster.

This PR add 2 new arguments that are mandatory to calculate the pod name and pod namespace for prom query and function to use it. I also add debug logger on prom query (can be remove if you think is useless :) )

Readme is update

Test done with success on my VC (with VC args) and without (like before this change).

mysiki avatar Mar 28 '25 15:03 mysiki

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Mar 28 '25 15:03 CLAassistant

some news ?

mysiki avatar May 21 '25 06:05 mysiki

Walkthrough

Introduces VCluster support across configuration, CLI, and Prometheus query builders. Adds helper methods for vcluster pod/namespace mapping, updates CPU/Memory loaders to use them and log PromQL, adds README documentation, and makes a trivial requirements.txt newline fix.

Changes

Cohort / File(s) Summary of changes
VCluster config & CLI
robusta_krr/core/models/config.py, robusta_krr/main.py
Added Config fields vcluster_name and vcluster_namespace. Exposed corresponding Typer CLI options and threaded them into Config.
Prometheus metric base helpers (VCluster)
robusta_krr/core/integrations/prometheus/metrics/base.py
Added hashlib import and two methods: get_vcluster_pod_real_name and get_pod_namespace to map vcluster pod/namespace to host-cluster equivalents.
CPU metrics: vcluster support + logging
robusta_krr/core/integrations/prometheus/metrics/cpu.py
Switched pod selectors to vcluster-aware names, computed namespace via helper, and logged constructed PromQL queries.
Memory metrics: vcluster support + logging
robusta_krr/core/integrations/prometheus/metrics/memory.py
Applied same vcluster-aware pod/namespace handling and PromQL logging across memory loaders; added module logger.
Docs updates
README.md
Added VCluster usage section (including sample command), plus minor whitespace/formatting tweaks.
Dependency housekeeping
requirements.txt
Added trailing newline; no dependency changes.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant CLI as KRR CLI
  participant Config
  participant Loader as Metric Loader
  participant Prom as Prometheus

  User->>CLI: run krr ... --vcluster-name --vcluster-namespace
  CLI->>Config: build Config(vcluster_name, vcluster_namespace, ...)
  CLI->>Loader: instantiate with settings
  Loader->>Loader: get_vcluster_pod_real_name()/get_pod_namespace()
  Loader->>Prom: query PromQL (vcluster-aware)
  Prom-->>Loader: timeseries
  Loader-->>CLI: results
  CLI-->>User: output

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15–25 minutes

Suggested reviewers

  • aantn
  • arikalon1
✨ Finishing Touches
  • [ ] 📝 Generate Docstrings
🧪 Generate unit tests
  • [ ] Create PR with unit tests
  • [ ] Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

coderabbitai[bot] avatar Aug 12 '25 13:08 coderabbitai[bot]