Skip to content

Use library chart with k8s managed app - #1026

Merged
Andrei Kvapil (kvaps) merged 1 commit into
mainfrom
chore/library-chart-k8s
Jun 16, 2025
Merged

Use library chart with k8s managed app#1026
Andrei Kvapil (kvaps) merged 1 commit into
mainfrom
chore/library-chart-k8s

Conversation

@lllamnyp

@lllamnyp Timofei Larkin (lllamnyp) commented Jun 4, 2025

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • Refactor
    • Updated resource configuration rendering in cluster templates to use standardized resource handling from a shared library, improving consistency in resource definitions.

@coderabbitai

coderabbitai Bot commented Jun 4, 2025

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

Andrei Kvapil (@kvaps) has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 14 minutes and 19 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 2fa967c and 8663dc9.

📒 Files selected for processing (1)
  • packages/apps/kubernetes/templates/cluster.yaml (2 hunks)

Walkthrough

A new file referencing the shared cozy-lib library was added under the Kubernetes charts directory. The cluster template was updated to use resource handling functions from cozy-lib for rendering component resource configurations and presets, replacing previous direct YAML serialization and local preset references.

Changes

File(s) Change Summary
packages/apps/kubernetes/charts/cozy-lib Added a file referencing the shared cozy-lib library via a relative path.
packages/apps/kubernetes/templates/cluster.yaml Updated resource and preset rendering to use cozy-lib resource functions instead of direct serialization.

Sequence Diagram(s)

sequenceDiagram
    participant HelmChart
    participant cozy-lib
    participant KubernetesTemplate

    HelmChart->>KubernetesTemplate: Render cluster.yaml
    KubernetesTemplate->>cozy-lib: Call resources.sanitize for resource blocks
    KubernetesTemplate->>cozy-lib: Call resources.preset for presets
    cozy-lib-->>KubernetesTemplate: Return processed resource YAML
    KubernetesTemplate-->>HelmChart: Output rendered template
Loading

Possibly related PRs

Suggested reviewers

  • kvaps
  • klinch0

Poem

In cozy charts, a change takes flight,
Resource blocks now rendered right.
With cozy-lib, we sanitize,
And presets too, we harmonize.
A rabbit hops with code so neat—
Kubernetes templates, now complete! 🐇✨


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.
    • Explain this complex logic.
    • 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. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • 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 src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

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

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

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

Documentation and Community

  • 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 coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7e24297 and 2fa967c.

📒 Files selected for processing (2)
  • packages/apps/kubernetes/charts/cozy-lib (1 hunks)
  • packages/apps/kubernetes/templates/cluster.yaml (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Build
🔇 Additional comments (3)
packages/apps/kubernetes/templates/cluster.yaml (3)

130-133: Consistent resource templating for controllerManager
The controllerManager block has been updated in line with the API server, leveraging cozy-lib functions. This looks correct and maintains consistency across control plane components.


136-139: Scheduler resource handling alignment
Scheduler resources now use the same sanitize/preset functions, ensuring uniform rendering of scheduling component specs. Implementation matches the pattern above.


149-152: Konnectivity server resource update
The konnectivity server resources are now sanitized and preset via cozy-lib. This completes the standardization for all control plane add-ons.

@@ -0,0 +1 @@
../../../library/cozy-lib/ No newline at end of file

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Approve: Local symlink for the cozy-lib Helm library is correctly added

The relative symlink in the charts directory correctly points to the shared cozy-lib library chart.

Run the following script to validate the symlink target and ensure Chart.yaml exists in the library chart:


🏁 Script executed:

#!/bin/bash
set -e
# Verify symlink path
target=$(readlink packages/apps/kubernetes/charts/cozy-lib)
echo "Symlink points to: $target"

# Confirm Chart.yaml in the target library chart
if [ ! -f "$target/Chart.yaml" ]; then
  echo "Error: Chart.yaml not found in library at $target"
  exit 1
fi

echo "Chart.yaml found; symlink is valid."

Length of output: 409


🏁 Script executed:

#!/usr/bin/env bash
set -e

echo "Listing all Chart.yaml files in the repo:"
find . -type f -name Chart.yaml

echo
echo "Looking specifically for Chart.yaml under any cozy-lib directory:"
find . -type f -path '*/cozy-lib/Chart.yaml' || echo "No cozy-lib Chart.yaml found"

Length of output: 7199


Approve: cozy-lib symlink is correctly pointing to packages/library/cozy-lib – update verification script

The symlink at packages/apps/kubernetes/charts/cozy-lib resolves to ../../../library/cozy-lib, and there is indeed a Chart.yaml at packages/library/cozy-lib/Chart.yaml. The failure in the previous script was due to testing the relative path from the repo root rather than from the chart directory.

• Corrected validation (run from repo root):

#!/usr/bin/env bash
set -e

# Change into the charts directory so relative symlink resolution works
cd packages/apps/kubernetes/charts

# Ensure cozy-lib is a symlink
if [ ! -L cozy-lib ]; then
  echo "Error: cozy-lib is not a symlink"
  exit 1
fi

# Verify Chart.yaml exists through the link
if [ ! -f cozy-lib/Chart.yaml ]; then
  echo "Error: Chart.yaml not found in linked cozy-lib"
  exit 1
fi

echo "✅ Symlink and Chart.yaml are valid."
🤖 Prompt for AI Agents
In packages/apps/kubernetes/charts/cozy-lib at line 1, the symlink validation
script should be updated to change the working directory to
packages/apps/kubernetes/charts before checking the symlink and Chart.yaml file.
Modify the script to first cd into the charts directory, then verify that
cozy-lib is a symlink and that cozy-lib/Chart.yaml exists relative to that
directory to ensure correct relative path resolution.

Comment on lines +124 to 127
resources: {{- include "cozy-lib.resources.sanitize" (list .Values.controlPlane.apiServer.resources $) | nindent 6 }}
{{- else if ne .Values.controlPlane.apiServer.resourcesPreset "none" }}
resources: {{- include "resources.preset" (dict "type" .Values.controlPlane.apiServer.resourcesPreset "Release" .Release) | nindent 6 }}
resources: {{- include "cozy-lib.resources.preset" (list .Values.controlPlane.apiServer.resourcesPreset $) | nindent 6 }}
{{- end }}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Resource rendering migration
The switch to cozy-lib.resources.sanitize and cozy-lib.resources.preset standardizes YAML output for the API server. Please confirm that cozy-lib is declared as a chart dependency (so these partials resolve at render time) and that the function signatures match the passed arguments (.Values.controlPlane.apiServer.resources or .resourcesPreset with the context $).

Run this script to verify the dependency in your Chart.yaml:


🏁 Script executed:

#!/bin/bash
# Verify cozy-lib chart is listed under dependencies
rg -n "cozy-lib" packages/apps/kubernetes/Chart.yaml

Length of output: 52


🏁 Script executed:

#!/bin/bash
# Locate Chart file under packages/apps/kubernetes
echo "Chart file(s) found:"
find packages/apps/kubernetes -maxdepth 2 -type f \( -iname 'Chart.yaml' -o -iname 'Chart.yml' \)

# Show the dependencies section in Chart.yaml (if present)
echo -e "\nDependencies section from Chart.yaml:"
rg -n "dependencies:" -A10 packages/apps/kubernetes/Chart.yaml || echo "→ No dependencies section found in Chart.yaml"

# Search specifically for cozy-lib in Chart.yaml
echo -e "\nSearching for 'cozy-lib' in Chart.yaml:"
rg -n "cozy-lib" packages/apps/kubernetes/Chart.yaml || echo "→ 'cozy-lib' not declared as a dependency"

Length of output: 692


Add cozy-lib as a chart dependency
Verification shows that packages/apps/kubernetes/Chart.yaml has no dependencies: section and does not list cozy-lib. Without this, the calls to cozy-lib.resources.sanitize and cozy-lib.resources.preset will fail at render time.

• File needing update:

  • packages/apps/kubernetes/Chart.yaml

• Required change:

  1. Add a dependencies: block including cozy-lib, for example:
    dependencies:
      - name: cozy-lib
        version: <chart-version>
        repository: <chart-repo-url>
  2. Run helm dependency update packages/apps/kubernetes to install the new dependency.
  3. Confirm that the partials’ function signatures still accept (list .Values.controlPlane.apiServer.resources $) and (list .Values.controlPlane.apiServer.resourcesPreset $) without errors.
🤖 Prompt for AI Agents
In packages/apps/kubernetes/Chart.yaml around lines 124 to 127, the cozy-lib
chart is not declared as a dependency, causing the calls to
cozy-lib.resources.sanitize and cozy-lib.resources.preset to fail at render
time. Fix this by adding a dependencies section in
packages/apps/kubernetes/Chart.yaml that includes cozy-lib with its name,
version, and repository URL. After updating the Chart.yaml, run helm dependency
update packages/apps/kubernetes to install the dependency. Finally, verify that
the function signatures for the partials still accept the passed arguments
without errors.

@kvaps Andrei Kvapil (kvaps) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we also update openapi schema and values for the helm chart?

@kvaps

Copy link
Copy Markdown
Member

I mean do we really want to let users specify both requests and limits?

@kvaps
Andrei Kvapil (kvaps) force-pushed the chore/library-chart-k8s branch 2 times, most recently from f536016 to d3266a8 Compare June 16, 2025 18:52
Signed-off-by: Timofei Larkin <lllamnyp@gmail.com>
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.

3 participants