Skip to content

Conversation

jabellard
Copy link
Member

What type of PR is this?

/kind feature

What this PR does / why we need it:
Please see #6819

Which issue(s) this PR fixes:

Fixes #6819

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

NONE

Signed-off-by: Joe Nathan Abellard <[email protected]>
Signed-off-by: Joe Nathan Abellard <[email protected]>
Signed-off-by: Joe Nathan Abellard <[email protected]>
Signed-off-by: Joe Nathan Abellard <[email protected]>
Signed-off-by: Joe Nathan Abellard <[email protected]>
@karmada-bot karmada-bot added the kind/feature Categorizes issue or PR as related to a new feature. label Oct 12, 2025
@karmada-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign chaosi-zju for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copy link

Summary of Changes

Hello @jabellard, 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 integrates admission control into the Karmada Operator, enhancing the management of Karmada resources by introducing API-level validation and defaulting. This change improves the reliability and consistency of resource configurations by enforcing rules closer to the source of truth, and provides a configurable option for operators to enable or disable this new functionality.

Highlights

  • Admission Control for Karmada Operator: Introduced mutating and validating webhooks for Karmada resources, allowing for policy enforcement and automatic defaulting at the API server level.
  • Helm Chart Updates: Modified the karmada-operator Helm chart to deploy necessary webhook components, including a service, cert-manager resources for webhook certificates, and the MutatingWebhookConfiguration and ValidatingWebhookConfiguration.
  • Conditional In-Controller Logic: The operator's in-controller validation and defaulting logic for Karmada resources will now only be applied if the admission webhooks are not registered, preventing redundant operations.
  • New Command-Line Flag: Added a new command-line flag --register-admission-webhooks to the Karmada Operator, allowing users to explicitly enable or disable the registration of these new admission webhooks.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@karmada-bot karmada-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Oct 12, 2025
@jabellard jabellard marked this pull request as draft October 12, 2025 23:35
@karmada-bot karmada-bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 12, 2025
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a valuable admission webhook for the Karmada operator, which is a best practice for handling validation and defaulting of custom resources. The implementation is clean, leveraging controller-runtime's webhook framework and cert-manager for certificate management. The feature is thoughtfully gated behind a Helm value, ensuring it's disabled by default. The refactoring to conditionally skip in-controller validation when the webhook is active is correct and avoids redundant processing. I've identified a few minor issues, mainly concerning a futuristic copyright year and missing newlines in YAML files.

apiVersions: ["v1alpha1"]
operations: ["CREATE","UPDATE"]
resources: ["karmadas"]
{{- end }} No newline at end of file

Choose a reason for hiding this comment

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

medium

It's a good practice to end files with a newline character. This ensures file integrity and prevents issues with some Unix tools and concatenation.

{{- end }}

protocol: TCP
selector:
app: {{ include "karmada.operator.fullname" . }}
{{- end }} No newline at end of file

Choose a reason for hiding this comment

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

medium

It's a good practice to end files with a newline character. This ensures file integrity and prevents issues with some Unix tools and concatenation.

{{- end }}

@@ -0,0 +1,136 @@
/*
Copyright 2025 The Karmada Authors.

Choose a reason for hiding this comment

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

medium

The copyright year is set to 2025, which is in the future. Please update it to the current year to reflect the correct copyright information.

Suggested change
Copyright 2025 The Karmada Authors.
Copyright 2024 The Karmada Authors.

Copy link
Member Author

Choose a reason for hiding this comment

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

@RainbowMango, This is so funny.

Copy link
Member

Choose a reason for hiding this comment

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

LOL ;) Maybe the model was trained last year.

@codecov-commenter
Copy link

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 0.95238% with 104 lines in your changes missing coverage. Please review.
✅ Project coverage is 45.81%. Comparing base (10a5f0f) to head (71ab46a).

Files with missing lines Patch % Lines
...rator/internal/webhook/v1alpha1/karmada_webhook.go 0.00% 65 Missing ⚠️
operator/cmd/operator/app/operator.go 0.00% 19 Missing ⚠️
operator/pkg/controller/karmada/controller.go 0.00% 18 Missing ⚠️
operator/cmd/operator/app/options/options.go 0.00% 1 Missing ⚠️
operator/pkg/controller/karmada/validating.go 50.00% 1 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6820      +/-   ##
==========================================
- Coverage   45.87%   45.81%   -0.07%     
==========================================
  Files         690      691       +1     
  Lines       57392    57478      +86     
==========================================
  Hits        26331    26331              
- Misses      29425    29510      +85     
- Partials     1636     1637       +1     
Flag Coverage Δ
unittests 45.81% <0.95%> (-0.07%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. kind/feature Categorizes issue or PR as related to a new feature. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Admission Control for Karmada Operator

4 participants