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 this issue: #6973

Which issue(s) this PR fixes:

Fixes #6973

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

karmada-operator Helm chart: Added support for configuring priority class and pod disruption budget config for Karmada operator deployment

@karmada-bot karmada-bot added the kind/feature Categorizes issue or PR as related to a new feature. label Dec 13, 2025
@gemini-code-assist
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 significantly enhances the robustness and operational stability of the Karmada operator by introducing configurable support for Kubernetes Priority Classes and Pod Disruption Budgets (PDBs) via its Helm chart. These additions allow administrators to ensure the operator's critical components are prioritized during scheduling and maintain desired availability levels even during cluster maintenance or scaling events.

Highlights

  • Priority Class Support: The Karmada operator deployment can now be configured with a priorityClassName, allowing its pods to be scheduled with higher priority on Kubernetes clusters.
  • Pod Disruption Budget (PDB) Support: A new Pod Disruption Budget resource can be enabled for the Karmada operator, enhancing its availability during voluntary disruptions by ensuring a minimum number of pods remain available.
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 requested review from a7i and seanlaii December 13, 2025 17:34
@karmada-bot karmada-bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Dec 13, 2025
@jabellard
Copy link
Member Author

/cc @RainbowMango @seanlaii

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 adds support for priorityClassName and PodDisruptionBudget (PDB) to the Karmada operator Helm chart, which is a great feature for enhancing the reliability of operator deployments. The implementation is mostly correct, but I've found a potential issue in the PDB template logic. The current implementation doesn't correctly handle a value of 0 for minAvailable or maxUnavailable, which could lead to generating an invalid PDB resource or one with unintended behavior. I've provided a suggestion to make the template more robust by using toString for checks and adding a fail guard to ensure a valid PDB configuration is always present when enabled.

@codecov-commenter
Copy link

codecov-commenter commented Dec 13, 2025

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

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 46.59%. Comparing base (9ba7dc0) to head (d80ef83).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7015      +/-   ##
==========================================
- Coverage   46.60%   46.59%   -0.01%     
==========================================
  Files         699      699              
  Lines       48182    48182              
==========================================
- Hits        22453    22451       -2     
  Misses      24032    24032              
- Partials     1697     1699       +2     
Flag Coverage Δ
unittests 46.59% <ø> (-0.01%) ⬇️

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.

Copy link
Contributor

@seanlaii seanlaii left a comment

Choose a reason for hiding this comment

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

Thanks for the contributions! Left some comments.

Comment on lines +35 to +36
{{- if .Values.operator.priorityClassName }}
priorityClassName: {{ .Values.operator.priorityClassName }}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit:

Suggested change
{{- if .Values.operator.priorityClassName }}
priorityClassName: {{ .Values.operator.priorityClassName }}
{{- with .Values.operator.priorityClassName }}
priorityClassName: {{ . | quote }}

Copy link
Member Author

Choose a reason for hiding this comment

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

You feel strongly about this? What's the benefit of changing it?

Copy link
Contributor

@seanlaii seanlaii Dec 15, 2025

Choose a reason for hiding this comment

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

No, it is just more idiomatic. It's fine if you don't want to change it.
Normally, if is for condition check, and with is to check if the value is presented.
But I don't have strong opinion. The current behavior is correct.

Comment on lines +9 to +11
{{- if .Values.commonLabels }}
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- end }}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit:

Suggested change
{{- if .Values.commonLabels }}
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- end }}
{{- with .Values.commonLabels }}
{{- include "common.tplvalues.render" (dict "value" . "context" $) | nindent 4 }}
{{- end }}

Comment on lines +12 to +14
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit:

Suggested change
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
{{- with .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" . "context" $ ) | nindent 4 }}
{{- end }}

namespace: {{ .Release.Namespace }}
labels: {{- include "common.labels.standard" . | nindent 4 }}
app: {{ include "karmada.operator.fullname" . }}
{{- if .Values.commonLabels }}
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we can provide commonLabels and commonAnnotations in values.yaml.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm just using the same labels used in the deployment to link it to the pbd.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

This expands the spoce of the PR, which is why I'd prefer to not add add it as part of this work. Would like to keep things as minimal as possible.

Copy link
Contributor

@seanlaii seanlaii Dec 15, 2025

Choose a reason for hiding this comment

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

Sure, since we also don't have commonAnnotations in Karmada helm chart, I don't feel strongly on this. Feel free to ignore.

metadata:
name: {{ include "karmada.operator.fullname" . }}
namespace: {{ .Release.Namespace }}
labels: {{- include "common.labels.standard" . | nindent 4 }}
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm just using the same labels used in the deployment to link it to the pbd.

selector:
matchLabels: {{- include "common.labels.matchLabels" . | nindent 6 }}
app: {{ include "karmada.operator.fullname" . }}
{{- if .Values.operator.pdb.minAvailable | toString }}
Copy link
Contributor

@seanlaii seanlaii Dec 13, 2025

Choose a reason for hiding this comment

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

I think we need to use hasKey since null value will be considered as true.
Maybe we can refer to cert-manager.

Copy link
Member Author

Choose a reason for hiding this comment

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

@seanlaii , thanks for the ref o the cert-manager approach and for thinking about the edge cases, but don't think we need to worry about this one. This would be a falsy value, so that block would not get evaluated.

Copy link
Contributor

Choose a reason for hiding this comment

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

Considering this case

minAvailable: null
maxAvailable: 1

the result will be

selector:
  matchLabels:
    minAvailable: 

Copy link
Member Author

Choose a reason for hiding this comment

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

Really? Let me try it.

Copy link
Member Author

Choose a reason for hiding this comment

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

@seanlaii , thanks for catching this. Will push update.

Copy link
Member Author

Choose a reason for hiding this comment

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

Just tried. Handling this weird edge case comes at the cost of the code becoming a lot of unreadable and requiring use more advanced stuff. I'm unsure if it's worth the tradeoff. hasKey also will not catch this. You have other ideas?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, will probably need this

{{- $pdb := .Values.operator.pdb }}

{{- if and (hasKey $pdb "minAvailable") (ne $pdb.minAvailable null) (ne $pdb.minAvailable "") }}
minAvailable: {{ $pdb.minAvailable }}
{{- else if and (hasKey $pdb "maxUnavailable") (ne $pdb.maxUnavailable null) (ne $pdb.maxUnavailable "") }}
maxUnavailable: {{ $pdb.maxUnavailable }}
{{- end }}

I am OK to keep it to maintain the readability.
Could you add some comment in the values.yaml to inform the users? Thanks!

Copy link
Member Author

Choose a reason for hiding this comment

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

Will add some instructions on how to have maxUnavailable be the field that takes precedence.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@seanlaii
Copy link
Contributor

/assign

Copy link
Contributor

@seanlaii seanlaii left a comment

Choose a reason for hiding this comment

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

LGTM

@karmada-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: seanlaii

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

The pull request process is described here

Details 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

@karmada-bot karmada-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 15, 2025
@zhzhuang-zju
Copy link
Contributor

Thanks
/assign

@RainbowMango RainbowMango added this to the v1.17 milestone Dec 15, 2025
@zhzhuang-zju
Copy link
Contributor

@jabellard Thanks, I have no further comments. It would be perfect if you could squash your commits into one.

@RainbowMango
Copy link
Member

@jabellard Thanks, I have no further comments. It would be perfect if you could squash your commits into one.

I rebased and squashed this; nothing has changed since the last review.

/lgtm

@karmada-bot karmada-bot added the lgtm Indicates that a PR is ready to be merged. label Dec 17, 2025
@karmada-bot karmada-bot merged commit ed620ac into karmada-io:master Dec 17, 2025
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Priority Class and Pod Disruption Budget Support for Karmada Operator Deployments

6 participants