Skip to content

feat(t8s-cluster): make apiserver resources configurable #1485

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 28, 2025

Conversation

cwrau
Copy link
Member

@cwrau cwrau commented May 27, 2025

Summary by CodeRabbit

  • New Features

    • Added support for configuring resource requests and limits for control plane components via chart values.
    • Introduced example configuration files to demonstrate resource customization for control plane deployments.
  • Documentation

    • Updated configuration schema and default values to reflect new resource settings options for the control plane.

@Copilot Copilot AI review requested due to automatic review settings May 27, 2025 13:25
Copy link

coderabbitai bot commented May 27, 2025

Walkthrough

Resource configuration for the control plane components in the Helm chart was made configurable. Static memory requests and limits were replaced with values sourced from the chart's configuration. New YAML files were added for different resource profiles, and the values schema was updated to validate these settings.

Changes

Files/Paths Change Summary
charts/t8s-cluster/ci/cp-with-resources-values.yaml,
charts/t8s-cluster/ci/hcp-with-resources-values.yaml
Added new YAML files defining control plane resource requests and limits for different profiles.
charts/t8s-cluster/templates/management-cluster/clusterClass/k0smotronControlPlaneTemplate/_k0smotronControlPlaneTemplateSpec.yaml Added a resources field using the common template for dynamic resource configuration.
charts/t8s-cluster/templates/management-cluster/clusterClass/kubeadmControlPlaneTemplate/_helpers.tpl Switched from hardcoded to templated resource configuration for kube-apiserver using chart values.
charts/t8s-cluster/values.schema.json Introduced resources property to the controlPlane schema, referencing Kubernetes resource schema.
charts/t8s-cluster/values.yaml Added a resources section under controlPlane with memory requests and limits.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant HelmChart
    participant TemplateEngine
    participant Kubernetes

    User->>HelmChart: Provide values.yaml (with controlPlane.resources)
    HelmChart->>TemplateEngine: Render templates with provided values
    TemplateEngine->>Kubernetes: Generate manifests with controlPlane resource requests/limits
    Kubernetes-->>User: Deploy control plane components with specified resources
Loading

Poem

In the warren of charts, a change hops through,
Memory limits set, requests anew!
No more hardcode, just values to tweak,
Control planes now strong, never weak.
Resourceful rabbits, we leap with delight,
Our clusters now balanced, running just right!
🐇✨


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.

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR makes the apiserver resources configurable by allowing resource requests and limits to be defined from the values file and propagated through the templates.

  • Introduces a new resources field in charts/t8s-cluster/values.yaml for controlPlane.
  • Updates the JSON schema in values.schema.json to validate the resources field.
  • Propagates configurable resource settings in both kubeadm and k0smotron control plane templates.
  • Adds CI test values files to verify the new resource configurations.

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
charts/t8s-cluster/values.yaml Adds configurable resource requests and limits.
charts/t8s-cluster/values.schema.json Updates schema to validate the new resources field via reference.
charts/t8s-cluster/templates/management-cluster/clusterClass/kubeadmControlPlaneTemplate/_helpers.tpl Replaces hard-coded resource values with a dynamic inclusion.
charts/t8s-cluster/templates/management-cluster/clusterClass/k0smotronControlPlaneTemplate/_k0smotronControlPlaneTemplateSpec.yaml Adds resource configuration using dynamic inclusion.
charts/t8s-cluster/ci/hcp-with-resources-values.yaml Provides CI values with hosted controlPlane and resource configuration.
charts/t8s-cluster/ci/cp-with-resources-values.yaml Provides CI values with resource configuration for controlPlane.

@teutonet-bot
Copy link
Contributor

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
charts/t8s-cluster/values.yaml (1)

45-49: Good addition of configurable control plane resources.

The default memory resource values (2Gi request, 4Gi limit) are reasonable and provide a good baseline. The configuration is backward compatible and follows Helm best practices.

Consider adding CPU resource specifications for completeness:

 resources:
   requests:
     memory: 2Gi
+    cpu: 500m
   limits:
     memory: 4Gi
+    cpu: 2000m
charts/t8s-cluster/values.schema.json (2)

177-180: Define optional resources property on controlPlane
The new resources property is correctly inserted under controlPlane.properties and references #/$defs/resourceRequirements, making it optional as intended. For better discoverability and documentation, consider adding a "description" field to explain its purpose (e.g., "Resource requests and limits for control plane components").


306-308: Pin external $defs.resourceRequirements reference to a stable release
The $ref correctly points to the Kubernetes ResourceRequirements definition, but relying on the master branch may introduce unexpected breaks if that repository updates. Consider referencing a specific tagged version or commit SHA in the URL to ensure schema stability.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 805e15f and bedde4b.

📒 Files selected for processing (6)
  • charts/t8s-cluster/ci/cp-with-resources-values.yaml (1 hunks)
  • charts/t8s-cluster/ci/hcp-with-resources-values.yaml (1 hunks)
  • charts/t8s-cluster/templates/management-cluster/clusterClass/k0smotronControlPlaneTemplate/_k0smotronControlPlaneTemplateSpec.yaml (1 hunks)
  • charts/t8s-cluster/templates/management-cluster/clusterClass/kubeadmControlPlaneTemplate/_helpers.tpl (1 hunks)
  • charts/t8s-cluster/values.schema.json (2 hunks)
  • charts/t8s-cluster/values.yaml (1 hunks)
🔇 Additional comments (4)
charts/t8s-cluster/ci/hcp-with-resources-values.yaml (1)

1-7: LGTM! Well-structured CI configuration for hosted control plane testing.

The resource configuration is appropriate for CI testing scenarios with higher memory requirements (4Gi request, 8Gi limit) compared to the defaults. The hosted: true flag correctly identifies this as a hosted control plane configuration.

charts/t8s-cluster/ci/cp-with-resources-values.yaml (1)

1-6: LGTM! Consistent CI configuration for control plane testing.

The resource configuration matches the hosted control plane variant, providing consistent testing across different control plane types. The identical memory settings (4Gi request, 8Gi limit) ensure uniform test coverage.

charts/t8s-cluster/templates/management-cluster/clusterClass/k0smotronControlPlaneTemplate/_k0smotronControlPlaneTemplateSpec.yaml (1)

8-8: Excellent implementation of configurable resources.

The use of the common.resources template helper with .Values.controlPlane as input provides clean, consistent resource injection. The nindent 2 properly formats the YAML output and maintains template readability.

charts/t8s-cluster/templates/management-cluster/clusterClass/kubeadmControlPlaneTemplate/_helpers.tpl (1)

33-33:

✅ Verification successful

Good implementation of dynamic resource configuration for kube-apiserver.

The change successfully replaces hardcoded resource values with configurable ones using the common.resources template helper. The fromYaml conversion properly parses the template output for use in the apiserver patch.

Please verify that the common.resources template helper is properly defined and handles the .Values.controlPlane input correctly:


🏁 Script executed:

#!/bin/bash
# Description: Verify the common.resources template helper exists and understand its implementation
# Expected: Find the template definition and confirm it handles resource configuration properly

# Search for the common.resources template definition
rg -A 10 -B 2 "define.*common\.resources"

# Also check for any usage patterns to understand expected input/output
rg -A 5 -B 2 "common\.resources"

Length of output: 23345


common.resources helper verified and change approved

Verified that common.resources is defined in charts/common/templates/_resources.tpl and correctly merges provided .resources with any preset via mustMerge and fromYaml. The helper’s output aligns with the intended dynamic resource configuration.

No further action required—approving these changes.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (1)
charts/t8s-cluster/templates/management-cluster/clusterClass/kubeadmControlPlaneTemplate/_helpers.tpl (1)

33-33: Consider passing only the resources configuration to the template.

The change successfully makes kube-apiserver resources configurable, which aligns well with the PR objectives. However, there's a previous review suggestion that's still relevant.

Consider passing only the resources sub-property (e.g., .Values.controlPlane.resources) to the include function instead of the entire controlPlane block to ensure only relevant configuration is processed:

-{{- $apiserverPatch := dict "spec" (dict "containers" (list (dict "name" "kube-apiserver" "resources" (include "common.resources" .Values.controlPlane | fromYaml)))) -}}
+{{- $apiserverPatch := dict "spec" (dict "containers" (list (dict "name" "kube-apiserver" "resources" (include "common.resources" .Values.controlPlane.resources | fromYaml)))) -}}

This approach follows the principle of least privilege by passing only the necessary configuration data to the template function.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 805e15f and bedde4b.

📒 Files selected for processing (6)
  • charts/t8s-cluster/ci/cp-with-resources-values.yaml (1 hunks)
  • charts/t8s-cluster/ci/hcp-with-resources-values.yaml (1 hunks)
  • charts/t8s-cluster/templates/management-cluster/clusterClass/k0smotronControlPlaneTemplate/_k0smotronControlPlaneTemplateSpec.yaml (1 hunks)
  • charts/t8s-cluster/templates/management-cluster/clusterClass/kubeadmControlPlaneTemplate/_helpers.tpl (1 hunks)
  • charts/t8s-cluster/values.schema.json (2 hunks)
  • charts/t8s-cluster/values.yaml (1 hunks)
🔇 Additional comments (6)
charts/t8s-cluster/values.schema.json (1)

177-180: Add optional resources property under controlPlane.

This introduces the new resources block in the schema, aligning with the values.yaml defaults and templating logic to allow specifying resource requests and limits for control plane components.

charts/t8s-cluster/ci/cp-with-resources-values.yaml (1)

1-6: Enable control plane memory resource override for non-hosted cluster.

This values file correctly sets controlPlane.resources.requests.memory to 4Gi and limits.memory to 8Gi, overriding the defaults in values.yaml.

charts/t8s-cluster/ci/hcp-with-resources-values.yaml (1)

1-7: Enable control plane memory resource override for hosted cluster.

This new CI values file properly sets hosted: true and configures controlPlane.resources for memory requests and limits, matching the expected override pattern.

charts/t8s-cluster/values.yaml (1)

45-49: Add default control plane resource requirements.

The defaults (2Gi request, 4Gi limit) are correctly placed under controlPlane.resources and will be schema-validated and applied by the templates.

charts/t8s-cluster/templates/management-cluster/clusterClass/k0smotronControlPlaneTemplate/_k0smotronControlPlaneTemplateSpec.yaml (1)

8-8: Inject dynamic resources in k0smotron control plane spec.

Including common.resources with .Values.controlPlane correctly renders the configured resource requests/limits for the k0smotron control plane.

charts/t8s-cluster/templates/management-cluster/clusterClass/kubeadmControlPlaneTemplate/_helpers.tpl (1)

33-33: Good improvement for resource configurability.

The change from hardcoded resource values to dynamic configuration via .Values.controlPlane is a positive improvement that makes the chart more flexible and configurable.

@cwrau cwrau added this pull request to the merge queue May 28, 2025
Merged via the queue into main with commit 3126661 May 28, 2025
56 checks passed
@cwrau cwrau deleted the feat/t8s-cluster/make-apiserver-resources-configurable branch May 28, 2025 11:03
github-merge-queue bot pushed a commit that referenced this pull request Jun 6, 2025
🤖 I have created a release *beep* *boop*
---


##
[9.3.0](t8s-cluster-v9.2.1...t8s-cluster-v9.3.0)
(2025-06-06)


### Features

* **t8s-cluster:** add rbac for teuto staff
([#1498](#1498))
([9e0a9e2](9e0a9e2))
* **t8s-cluster:** enable audit logging
([#1440](#1440))
([dcb28ca](dcb28ca))
* **t8s-cluster:** make apiserver resources configurable
([#1485](#1485))
([3126661](3126661))
* **t8s-cluster:** use new pullPolicy template
([#1383](#1383))
([6b253bd](6b253bd))


### Miscellaneous Chores

* **t8s-cluster:** pin versions
([#1482](#1482))
([372c92b](372c92b))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **New Features**
  - Added RBAC for Teuto staff.
  - Enabled audit logging.
  - Made apiserver resource configurations customizable.
  - Adopted a new pullPolicy template.

- **Enhancements**
- Updated OpenStack Cinder CSI plugin and related CSI component images
to newer versions.
- Improved documentation for control plane resource configuration and
security group rule options.

- **Chores**
  - Updated chart version to 9.3.0 and pinned image versions.
- Switched CSI image references and license entries from k8s.gcr.io to
registry.k8s.io.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Chris Werner Rau <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants