Skip to content

design:Add component certificate identification for karmada components #6269

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 14, 2025

Conversation

tiansuo114
Copy link
Contributor

@tiansuo114 tiansuo114 commented Apr 7, 2025

What type of PR is this?
/kind design

What this PR does / why we need it:
This pr is about #6091

Which issue(s) this PR fixes:
Fixes #6091

Special notes for your reviewer:
@XiShanYongYe-Chang
@zhzhuang-zju
Does this PR introduce a user-facing change?:


@karmada-bot karmada-bot added the kind/design Categorizes issue or PR as related to design. label Apr 7, 2025
@karmada-bot karmada-bot requested review from lfbear and Poor12 April 7, 2025 05:28
@karmada-bot karmada-bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Apr 7, 2025
@codecov-commenter
Copy link

codecov-commenter commented Apr 7, 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 49.34%. Comparing base (ba5ffba) to head (e67ae00).
Report is 110 commits behind head on master.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6269      +/-   ##
==========================================
+ Coverage   47.95%   49.34%   +1.38%     
==========================================
  Files         676      678       +2     
  Lines       55964    55122     -842     
==========================================
+ Hits        26837    27199     +362     
+ Misses      27355    26154    -1201     
+ Partials     1772     1769       -3     
Flag Coverage Δ
unittests 49.34% <ø> (+1.38%) ⬆️

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.

@tiansuo114 tiansuo114 force-pushed the server_cert branch 2 times, most recently from 2144a6f to 0d996d1 Compare April 9, 2025 13:57
@karmada-bot karmada-bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Apr 9, 2025
@tiansuo114 tiansuo114 changed the title design:Add component certificate identification for server components design:Add component certificate identification for karmada components Apr 10, 2025
@zhzhuang-zju
Copy link
Contributor

/assign

for component in "${components[@]}"
do
generate_config_secret ${component} ${karmada_ca} ${CLIENT_CRT} ${CLIENT_KEY}
done


Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change

Redundant blank lines

Comment on lines 199 to 200


Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change

ditto

util::create_certkey "" "${CERT_DIR}" "ca" karmada-webhook "system:karmada:karmada-webhook" "" "${karmada_webhook_alt_names[@]}"
util::create_certkey "" "${CERT_DIR}" "ca" karmada-search "system:karmada:karmada-search" "" "${karmada_search_alt_names[@]}"
util::create_certkey "" "${CERT_DIR}" "ca" karmada-metrics-adapter "system:karmada:karmada-metrics-adapter" "" "${karmada_metrics_adapter_alt_names[@]}"
util::create_certkey "" "${CERT_DIR}" "ca" karmada-scheduler-estimator "system:karmada:karmada-scheduler-estimator" "" "${karmadaAltNames[@]}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is the karmada-scheduler-estimator component still using karmadaAltNames?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reason the karmada-scheduler-estimator component still uses karmadaAltNames (i.e., uses wildcards to specify DNS names in the certificate) is that during Karmada cluster deployment, the karmada-scheduler-estimator component's Deployment name might be something like karmada-scheduler-estimator-member1. However, in x509 certificates, wildcards can only appear in the leftmost complete label and cannot be used in formats like karmada-scheduler-estimator-*.karmada-system.svc.cluster.local. Therefore, to meet runtime requirements, we use karmadaAltNames to assign the DNS field of the certificate for the karmada-scheduler-estimator component.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for your explanation. That makes sense. However, I suggest creating a new variable, karmada_scheduler_estimator_alt_names, whose value can be set as needed.

@@ -187,13 +196,53 @@ util::cmd_must_exist "openssl"
util::cmd_must_exist_cfssl ${CFSSL_VERSION}
# create CA signers
util::create_signing_certkey "" "${CERT_DIR}" ca karmada '"client auth","server auth"'
# signs a certificate


karmadaAltNames=("*.karmada-system.svc.cluster.local" "*.karmada-system.svc" "localhost" "127.0.0.1" $(util::get_apiserver_ip_from_kubeconfig "${HOST_CLUSTER_NAME}") "${interpreter_webhook_example_service_external_ip_address}")
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems that ${interpreter_webhook_example_service_external_ip_address} has not been included in the SAN of the new certificates. cc @XiShanYongYe-Chang Do you know whether this SAN entry is necessary, and which component relies on it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In the discussion, my understanding of the karmada-interpreter-webhook-example component was that it was still in a demo state and might undergo further changes, so I didn’t modify its certificate configuration at that time.

Copy link
Contributor

Choose a reason for hiding this comment

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

Get it


# 3. generate secret with ca cert or sa key
generate_ca_cert_secret kube-controller-manager ${karmada_ca} ${karmada_ca_key}
generate_key_pair_secret kube-controller-manager ${SA_PUB} ${SA_KEY}
generate_key_pair_secret karmada-apiserver ${SA_PUB} ${SA_KEY}

# 4. generate secret with karmada config
components=(karmada-aggregated-apiserver karmada-controller-manager kube-controller-manager karmada-scheduler karmada-descheduler karmada-metrics-adapter karmada-search karmada-webhook karmada-interpreter-webhook-example)
# 5. generate secret with karmada config for each component using their specific client certs
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# 5. generate secret with karmada config for each component using their specific client certs
# 4. generate secret with karmada config for each component using their specific client certs

SA_PUB=$(base64 < "${CERT_DIR}/sa.pub" | tr -d '\r\n')
SA_KEY=$(base64 < "${CERT_DIR}/sa.key" | tr -d '\r\n')

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The issue with extra spaces has been completely fixed. How does the file look now?

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks~ looks well

@zhzhuang-zju
Copy link
Contributor

@tiansuo114 You can merge the commits. Others LGTM

@zhzhuang-zju
Copy link
Contributor

ask @XiShanYongYe-Chang for another look

Copy link
Member

@XiShanYongYe-Chang XiShanYongYe-Chang left a comment

Choose a reason for hiding this comment

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

Thanks all~
/approve

I have an idea that is not related to the current pr. The current file looks a little long and a little hard to read. There is no clear code block organization and step order. Do you have any ideas to improve it?

@karmada-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: XiShanYongYe-Chang

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

The pull request process is described 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

@karmada-bot karmada-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 13, 2025
…pt deploy

Signed-off-by: tiansuo <zhaoyi_114@outlook.com>
@tiansuo114
Copy link
Contributor Author

Thanks all~ /approve

I have an idea that is not related to the current pr. The current file looks a little long and a little hard to read. There is no clear code block organization and step order. Do you have any ideas to improve it?

I think we can improve the readability of this file by adding some functions — for example, integrating all certificate generation logic into a single generate_all_certificates function. However, regarding the overall file length, I'm not sure if it's a good idea to put functions that are only used in deploy-karmada.sh into util.sh. I’d appreciate it if you could share your thoughts on this.

@XiShanYongYe-Chang
Copy link
Member

Thanks @tiansuo114~

I haven't really thought about it, I just feel like the file is a little big and not very easy to read. (Of course, it has nothing to do with the current pr, which is the result of a long-term update iteration.) If you want and have time, you can try it.

@zhzhuang-zju
Copy link
Contributor

I think we can improve the readability of this file by adding some functions — for example, integrating all certificate generation logic into a single generate_all_certificates function. However, regarding the overall file length, I'm not sure if it's a good idea to put functions that are only used in deploy-karmada.sh into util.sh. I’d appreciate it if you could share your thoughts on this.

Rather than adding more functions, I think the current issue affecting readability is the lack of a clear execution flow. It's not easy to understand what the script does exactly and in what order.

@tiansuo114
Copy link
Contributor Author

I think we can improve the readability of this file by adding some functions — for example, integrating all certificate generation logic into a single generate_all_certificates function. However, regarding the overall file length, I'm not sure if it's a good idea to put functions that are only used in deploy-karmada.sh into util.sh. I’d appreciate it if you could share your thoughts on this.

Rather than adding more functions, I think the current issue affecting readability is the lack of a clear execution flow. It's not easy to understand what the script does exactly and in what order.

Yes, what I mean is to refactor some of the current repeatable processes into separate functions, and reorganize the file into a structure like: variable declarations → logic execution → function definitions. This might make the file more readable.

@zhzhuang-zju
Copy link
Contributor

/lgtm

@karmada-bot karmada-bot added the lgtm Indicates that a PR is ready to be merged. label May 14, 2025
@karmada-bot karmada-bot merged commit a34c412 into karmada-io:master May 14, 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/design Categorizes issue or PR as related to design. lgtm Indicates that a PR is ready to be merged. 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.

[lfx-mentorship-2025-March-May] Karmada Self-Signed Certificate Content Standardization
5 participants