Skip to content

Use PEM directly accessed from secrets in KafkaConnect and MirrorMaker2#12735

Open
tinaselenge wants to merge 5 commits into
strimzi:mainfrom
tinaselenge:mirror-connect-pem
Open

Use PEM directly accessed from secrets in KafkaConnect and MirrorMaker2#12735
tinaselenge wants to merge 5 commits into
strimzi:mainfrom
tinaselenge:mirror-connect-pem

Conversation

@tinaselenge
Copy link
Copy Markdown
Contributor

@tinaselenge tinaselenge commented May 12, 2026

Type of change

Select the type of your PR

  • Refactoring

Description

Remove PKCS12 usage in MirrorMaker2 so that it uses PEM files from secrets directly accessed using KubernetesSecretConfigProvider. Also authentication clients secrets are accessed directly via KubernetesSecretConfigProvider instead of volume mounting them.

Refactor KafkaConnect to also access authentication clients secrets directly instead of volume mounting them and to use AuthenticationUtils for creating role/rolebinding resources for them.

Closes #12605

Checklist

Please go through this checklist and make sure all applicable tasks have been done

  • Write tests
  • Make sure all tests pass
  • Update documentation
  • Check RBAC rights for Kubernetes / OpenShift roles
  • Try your changes from Pod inside your Kubernetes and OpenShift cluster, not just locally
  • Reference relevant issue(s) and close them after merging
  • Update CHANGELOG.md
  • Supply screenshots for visual changes, such as Grafana dashboards

Signed-off-by: Gantigmaa Selenge <tina.selenge@gmail.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented May 12, 2026

Codecov Report

❌ Patch coverage is 63.93443% with 22 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.05%. Comparing base (7eec8a3) to head (d1553d2).
⚠️ Report is 25 commits behind head on main.

Files with missing lines Patch % Lines
...or/assembly/KafkaMirrorMaker2AssemblyOperator.java 21.42% 18 Missing and 4 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main   #12735      +/-   ##
============================================
+ Coverage     74.95%   75.05%   +0.10%     
- Complexity     6369     6429      +60     
============================================
  Files           345      346       +1     
  Lines         24126    24272     +146     
  Branches       3090     3108      +18     
============================================
+ Hits          18083    18217     +134     
- Misses         4811     4822      +11     
- Partials       1232     1233       +1     
Files with missing lines Coverage Δ
...zi/operator/cluster/model/AuthenticationUtils.java 79.31% <ø> (-2.97%) ⬇️
...zi/operator/cluster/model/KafkaConnectCluster.java 95.12% <100.00%> (+0.65%) ⬆️
...luster/model/KafkaConnectConfigurationBuilder.java 93.90% <100.00%> (ø)
...erator/cluster/model/KafkaMirrorMaker2Cluster.java 97.33% <100.00%> (+1.60%) ⬆️
...tor/cluster/model/KafkaMirrorMaker2Connectors.java 92.59% <100.00%> (+0.21%) ⬆️
...ter/operator/assembly/AbstractConnectOperator.java 87.30% <100.00%> (ø)
...or/assembly/KafkaMirrorMaker2AssemblyOperator.java 76.30% <21.42%> (-8.40%) ⬇️

... and 24 files with indirect coverage changes

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

@tinaselenge
Copy link
Copy Markdown
Contributor Author

/azp run regression

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@tinaselenge
Copy link
Copy Markdown
Contributor Author

/gha run pipeline=regression

@tinaselenge tinaselenge marked this pull request as ready for review May 13, 2026 10:14
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 13, 2026

⏳ System test verification started: link

The following 6 job(s) will be executed:

  • regression-brokers-and-security-amd64 (oracle-vm-8cpu-32gb-x86-64)
  • regression-operators-amd64 (oracle-vm-8cpu-32gb-x86-64)
  • regression-operands-amd64 (oracle-vm-8cpu-32gb-x86-64)
  • regression-brokers-and-security-arm64 (oracle-vm-8cpu-32gb-arm64)
  • regression-operators-arm64 (oracle-vm-8cpu-32gb-arm64)
  • regression-operands-arm64 (oracle-vm-8cpu-32gb-arm64)

Tests will start after successful build completion.

@tinaselenge
Copy link
Copy Markdown
Contributor Author

All regression tests passed but image build step failed with some error. Kicking them off again to get green build.

@tinaselenge tinaselenge requested review from ppatierno and scholzj May 13, 2026 11:54
@github-actions
Copy link
Copy Markdown

🎉 System test verification passed: link

@scholzj scholzj added this to the 1.1.0 milestone May 13, 2026
Comment thread docker-images/kafka-based/kafka/scripts/kafka_connect_run.sh
Comment on lines +198 to +208
if (mirrorMaker2Cluster.getTls() != null && mirrorMaker2Cluster.getTls().getTrustedCertificates() != null) {
allTrustedCertificates.addAll(mirrorMaker2Cluster.getTls().getTrustedCertificates());
}

if (mirrorMaker2Cluster instanceof KafkaMirrorMaker2Cluster mm2Cluster) {
for (KafkaMirrorMaker2ClusterSpec cluster : mm2Cluster.clusters()) {
if (cluster.getTls() != null && cluster.getTls().getTrustedCertificates() != null) {
allTrustedCertificates.addAll(cluster.getTls().getTrustedCertificates());
}
}
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

  • Do we need to worry about uniqueness?
  • I think it is fine to collect them into a single Secret. But it is not fine to collect them into a single ca.crt file. That would be a CVE as you would trust certificates you should not trust, or?
    (E.g. mirror A trusts CA X and mirror B trusts CA Y. If you mix them into a single file, mirror A would now trust also CA Y and so on.)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I agree with Jakub I guess we should distinguish the two trusting.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point, I have now updated the method to use cluser alias as the key.

Comment on lines +210 to +229
if (!allTrustedCertificates.isEmpty()) {
return ReconcilerUtils.trustedCertificates(reconciliation, secretOperations, allTrustedCertificates)
.compose(certificates -> {
if (certificates != null) {
return secretOperations.reconcile(
reconciliation,
namespace,
KafkaConnectResources.internalTlsTrustedCertsSecretName(mirrorMaker2Cluster.getCluster()),
mirrorMaker2Cluster.generateTlsTrustedCertsSecret(
Map.of("ca.crt", Util.encodeToBase64(certificates)),
KafkaConnectResources.internalTlsTrustedCertsSecretName(mirrorMaker2Cluster.getCluster())
))
.mapEmpty();
} else {
return Future.succeededFuture();
}
});
} else {
return Future.succeededFuture();
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should there be some cleanup in the else branch? E.g. deleting the Secret or something?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That's good point. so if user has removed the TLS configuration, the internal secret is not left behind. This is something I should fix for KafkaConnect and KafkaBridge in another PR.

@snyk-io
Copy link
Copy Markdown

snyk-io Bot commented May 26, 2026

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

Signed-off-by: Gantigmaa Selenge <tina.selenge@gmail.com>
@tinaselenge tinaselenge force-pushed the mirror-connect-pem branch from 5ac600d to 6e1440d Compare May 26, 2026 16:29
Signed-off-by: Gantigmaa Selenge <tina.selenge@gmail.com>
Signed-off-by: Gantigmaa Selenge <tina.selenge@gmail.com>
@scholzj
Copy link
Copy Markdown
Member

scholzj commented May 27, 2026

/gha run pipeline=regression

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 27, 2026

⏳ System test verification started: link

The following 6 job(s) will be executed:

  • regression-brokers-and-security-amd64 (cncf-ubuntu-8-32-x86)
  • regression-operators-amd64 (cncf-ubuntu-8-32-x86)
  • regression-operands-amd64 (cncf-ubuntu-8-32-x86)
  • regression-brokers-and-security-arm64 (cncf-ubuntu-8-32-arm)
  • regression-operators-arm64 (cncf-ubuntu-8-32-arm)
  • regression-operands-arm64 (cncf-ubuntu-8-32-arm)

Tests will start after successful build completion.

@github-actions
Copy link
Copy Markdown

❌ System test verification failed: link

@ppatierno
Copy link
Copy Markdown
Member

/gha run pipeline=regression

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 28, 2026

⏳ System test verification started: link

The following 6 job(s) will be executed:

  • regression-brokers-and-security-amd64 (cncf-ubuntu-8-32-x86)
  • regression-operators-amd64 (cncf-ubuntu-8-32-x86)
  • regression-operands-amd64 (cncf-ubuntu-8-32-x86)
  • regression-brokers-and-security-arm64 (cncf-ubuntu-8-32-arm)
  • regression-operators-arm64 (cncf-ubuntu-8-32-arm)
  • regression-operands-arm64 (cncf-ubuntu-8-32-arm)

Tests will start after successful build completion.

@github-actions
Copy link
Copy Markdown

❌ System test verification failed: link

@ppatierno
Copy link
Copy Markdown
Member

@tinaselenge some regression tests are failing and they could be related to your changes. I didn't look into them but it seems related to TLS within MM2.

@tinaselenge
Copy link
Copy Markdown
Contributor Author

I will take a look, thanks @ppatierno

Signed-off-by: Gantigmaa Selenge <tina.selenge@gmail.com>
@tinaselenge tinaselenge force-pushed the mirror-connect-pem branch from 769a96a to d1553d2 Compare May 29, 2026 12:50
@tinaselenge
Copy link
Copy Markdown
Contributor Author

/gha run pipeline=regression

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 29, 2026

⏳ System test verification started: link

The following 6 job(s) will be executed:

  • regression-brokers-and-security-amd64 (cncf-ubuntu-8-32-x86)
  • regression-operators-amd64 (cncf-ubuntu-8-32-x86)
  • regression-operands-amd64 (cncf-ubuntu-8-32-x86)
  • regression-brokers-and-security-arm64 (cncf-ubuntu-8-32-arm)
  • regression-operators-arm64 (cncf-ubuntu-8-32-arm)
  • regression-operands-arm64 (cncf-ubuntu-8-32-arm)

Tests will start after successful build completion.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mirror Maker 2 should use PEM files directly instead of using PKCS12 files

3 participants