[keycloak] Add storageclass support for CNPG cluster#2188
[keycloak] Add storageclass support for CNPG cluster#2188BROngineer wants to merge 2 commits intomainfrom
Conversation
Signed-off-by: Artem Bortnikov <brongineer747@gmail.com>
📝 WalkthroughWalkthroughThese changes introduce configurable StorageClass support to the Keycloak Helm chart. A new StorageClass template is added with conditional rendering, configuration values are introduced for enabling and customizing the storage class, and the database template is updated to reference the configured storage class settings. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the Keycloak deployment by introducing a mechanism to prevent data loss for its CNPG database. It achieves this by allowing the configuration of a dedicated Kubernetes StorageClass with a Retain reclaim policy, ensuring that database Persistent Volumes are not automatically deleted when the CNPG cluster is removed. This change provides a crucial safety net for data integrity. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces optional storage class support for the CNPG cluster, specifically addressing data loss prevention by setting reclaimPolicy: Retain. However, a potential YAML injection vulnerability was identified in the new storageclass.yaml template where the provisioner field is not properly quoted, which could allow for the injection of arbitrary YAML fields. Additionally, there are opportunities to enhance the flexibility and configurability of the storage class name.
Signed-off-by: Artem Bortnikov <brongineer747@gmail.com>
There was a problem hiding this comment.
🧹 Nitpick comments (2)
packages/system/keycloak/values.yaml (1)
14-17: Consider adding documentation comments for the storageClass block.The ingress section above includes helpful comments explaining the configuration options. Adding similar documentation would improve discoverability for users, e.g.:
storageClass: # Enable creation of a dedicated StorageClass with Retain policy for CNPG cluster data. enable: false # Custom name for the StorageClass (defaults to "keycloak-db-retain" if empty). name: "" # Storage provisioner to use (required when enable is true). provisioner: ""🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/system/keycloak/values.yaml` around lines 14 - 17, Add inline documentation comments to the storageClass YAML block to explain each option (storageClass.enable, storageClass.name, storageClass.provisioner): describe that enable toggles creating a dedicated StorageClass with Retain policy for CNPG data, name can override the default StorageClass name if empty, and provisioner specifies the storage provisioner required when enable is true; keep wording consistent with the existing ingress comments and place comments directly above each key.packages/system/keycloak/templates/storageclass.yaml (1)
4-5: Consider adding standard labels for consistency.Other StorageClass templates in this repository include labels (e.g.,
packages/system/nfs-driver/charts/csi-driver-nfs/templates/storageclass.yaml). Adding labels would improve resource organization and querying.♻️ Suggested enhancement
metadata: name: {{ .Values.storageClass.name | default "keycloak-db-retain" }} + labels: + app.kubernetes.io/name: keycloak + app.kubernetes.io/component: database provisioner: {{ required ".Values.storageClass.provisioner is required when storageClass.enable is true" .Values.storageClass.provisioner | quote }}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/system/keycloak/templates/storageclass.yaml` around lines 4 - 5, Add standard metadata.labels to the StorageClass manifest so resources are consistent with other templates; update the storage class template around metadata.name (the template using {{ .Values.storageClass.name | default "keycloak-db-retain" }}) to include a labels block populated from values (e.g., .Values.storageClass.labels) or sensible defaults, and ensure the chart values.yaml exposes storageClass.labels so callers can override them for organization and querying.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@packages/system/keycloak/templates/storageclass.yaml`:
- Around line 4-5: Add standard metadata.labels to the StorageClass manifest so
resources are consistent with other templates; update the storage class template
around metadata.name (the template using {{ .Values.storageClass.name | default
"keycloak-db-retain" }}) to include a labels block populated from values (e.g.,
.Values.storageClass.labels) or sensible defaults, and ensure the chart
values.yaml exposes storageClass.labels so callers can override them for
organization and querying.
In `@packages/system/keycloak/values.yaml`:
- Around line 14-17: Add inline documentation comments to the storageClass YAML
block to explain each option (storageClass.enable, storageClass.name,
storageClass.provisioner): describe that enable toggles creating a dedicated
StorageClass with Retain policy for CNPG data, name can override the default
StorageClass name if empty, and provisioner specifies the storage provisioner
required when enable is true; keep wording consistent with the existing ingress
comments and place comments directly above each key.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 8dfe35fb-4782-4137-b4dd-b712d74565cd
📒 Files selected for processing (3)
packages/system/keycloak/templates/db.yamlpackages/system/keycloak/templates/storageclass.yamlpackages/system/keycloak/values.yaml
|
Won't fix for now: CNPG cluster more likely won't be able to reuse the retained volume |
What this PR does
This PR adds optional storageClass with
reclaimPolicy: Retainto be used for CNPG cluster to prevent PV deletion in case of CNPG cluster deletion. This is crucial to prevent data loss.Release note
Summary by CodeRabbit