Skip to content

ClusterBundle target API rework - #486

Merged
cert-manager-prow[bot] merged 1 commit into
cert-manager:mainfrom
erikgb:cluster-bundle-api
May 30, 2025
Merged

cert-manager-prow[bot] merged 1 commit into
cert-manager:mainfrom
erikgb:cluster-bundle-api

Conversation

@erikgb

@erikgb erikgb commented Nov 24, 2024 •

Copy link
Copy Markdown
Member

After getting feedback on the migration proposal, I believe the proposed (one-way) migration from Bundle to ClusterBundle could represent an opportunity to improve the API of trust-manager. So I did a little experiment and drafted some of the changes I think make sense. Relates to #485.

The proposed changes to the target API will address the following issues:

New features proposed:

Starting with a max target specification with the current API:

target:
  namespaceSelector:
    matchLabels:
      trust.example.com/inject-bundle: "true"
  configMap:
    key: root-certs.pem
    metadata:
      annotations:
        argocd.argoproj.io/sync-wave: "1"
      labels:
        app.kubernetes.io/component: "trust-bundle"
  secret:
    key: root-certs.pem
    metadata:
      annotations:
        argocd.argoproj.io/sync-wave: "1"
      labels:
        app.kubernetes.io/component: "trust-bundle"
  additionalFormats:
    jks:
      key: bundle.jks
      password: jks-password
    pkcs12:
      key: bundle.p12
      password: pkcs12-password
      profile: Modern2023

This will transform into the following with the new target API:

target:
  namespaceSelector:
    matchLabels:
      trust.example.com/inject-bundle: "true"
  configMap:
    data:
      - key: root-certs.pem
      - key: bundle.jks
        format: pkcs12 # JKS format is removed in the new API
        password: jks-password
        profile: LegacyRC2
      - key: bundle.p12
        format: pkcs12
        password: pkcs12-password
        profile: Modern2023
    metadata:
      annotations:
        argocd.argoproj.io/sync-wave: "1"
      labels:
        app.kubernetes.io/component: "trust-bundle"
  secret:
    data:
      - key: root-certs.pem
      - key: bundle.jks
        format: pkcs12 # JKS format is removed in the new API
        password: jks-password
        profile: LegacyRC2
      - key: bundle.p12
        format: pkcs12
        password: pkcs12-password
        profile: Modern2023
    metadata:
      annotations:
        argocd.argoproj.io/sync-wave: "1"
      labels:
        app.kubernetes.io/component: "trust-bundle"

Which is a bit more verbose but more flexible. It is verbose mainly because additionalFormats applies to all targets, which is one of the issues I'm trying to solve here.

The format field could potentially be omitted, but that will make the API less explicit and make validation more complicated. I have also taken inspiration from the upstream union type KEP:

@cert-manager-prow

Copy link
Copy Markdown
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@cert-manager-prow cert-manager-prow Bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Nov 24, 2024
@erikgb
erikgb force-pushed the cluster-bundle-api branch from 6427cfa to 76c03c4 Compare November 24, 2024 21:55
@cert-manager-bot

Copy link
Copy Markdown
Contributor

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
If this issue is safe to close now please do so with /close.
/lifecycle stale

@cert-manager-prow cert-manager-prow Bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Feb 26, 2025
@erikgb

erikgb commented Feb 26, 2025

Copy link
Copy Markdown
Member Author

/remove-lifecycle stale

@cert-manager-prow cert-manager-prow Bot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Feb 26, 2025
@cert-manager-prow cert-manager-prow Bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 8, 2025
@erikgb
erikgb force-pushed the cluster-bundle-api branch from 76c03c4 to c631b6c Compare April 9, 2025 19:18
@cert-manager-prow cert-manager-prow Bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 9, 2025
@erikgb
erikgb force-pushed the cluster-bundle-api branch from c631b6c to ca23104 Compare April 15, 2025 14:56
@cert-manager-prow cert-manager-prow Bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Apr 15, 2025
@erikgb
erikgb force-pushed the cluster-bundle-api branch 2 times, most recently from 0ce14dc to 45844ce Compare April 15, 2025 22:31
@erikgb erikgb changed the title WIP: Proposed API changes for ClusterBundle migration WIP: ClusterBundle target API rework Apr 16, 2025
@erikgb erikgb changed the title WIP: ClusterBundle target API rework ClusterBundle target API rework Apr 16, 2025
@erikgb
erikgb marked this pull request as ready for review April 16, 2025 07:59
@cert-manager-prow cert-manager-prow Bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 16, 2025
@erikgb

erikgb commented Apr 16, 2025

Copy link
Copy Markdown
Member Author

This PR should be ready for review now, but as it contains a massive change to the API, I will put a hold on it to avoid a premature merge.

/hold

@cert-manager-prow cert-manager-prow Bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 16, 2025
@erikgb
erikgb force-pushed the cluster-bundle-api branch from 45844ce to e410c59 Compare April 16, 2025 08:26

@SgtCoDFish SgtCoDFish left a comment

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.

Took an initial look! Thanks for driving this!

out.Password = in.Password
out.Profile = trustv1alpha2.PKCS12Profile(in.Profile)
if out.Profile == "" {
// Default profile changed from LegacyRC2 to LegacyDES in v1alpha2

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.

suggestion: It would be really cool to create an ongoing list of changes we're making so we can more easily document it later. It's great that we have this comment here - maybe we could alos add all these kinds of comments to, say, docs/alphav2-changes.md and keep a list there?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, excellent suggestion. I will add this right away, but keep it simplistic for now, as I don't want to update it for each and every review suggestion. 😅 But listing the changes in behavior is excellent!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I have added docs/alphav2-changes.md. It appears useful and I hope it addresses your suggestion. PTAL!

@erikgb

erikgb commented Apr 16, 2025

Copy link
Copy Markdown
Member Author

If the deprecation of explicit JKS support is accepted, ref. #603, the API proposed in this PR can be simplified.

@cert-manager-prow cert-manager-prow Bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 23, 2025
@erikgb
erikgb force-pushed the cluster-bundle-api branch from 7e4be87 to 338c891 Compare April 23, 2025 21:49
@cert-manager-prow cert-manager-prow Bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 23, 2025
@erikgb erikgb changed the title ClusterBundle target API rework WIP: ClusterBundle target API rework Apr 23, 2025
@cert-manager-prow cert-manager-prow Bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 23, 2025
@erikgb
erikgb force-pushed the cluster-bundle-api branch 4 times, most recently from da586aa to 9c98e02 Compare April 24, 2025 17:17
@cert-manager-prow cert-manager-prow Bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Apr 25, 2025
@erikgb
erikgb force-pushed the cluster-bundle-api branch from aa5bcf3 to 65351fb Compare April 26, 2025 12:21
Signed-off-by: Erik Godding Boye <[email protected]>
@erikgb
erikgb force-pushed the cluster-bundle-api branch from 65351fb to 7ca1766 Compare April 26, 2025 12:56
@erikgb erikgb changed the title WIP: ClusterBundle target API rework ClusterBundle target API rework Apr 26, 2025
@cert-manager-prow cert-manager-prow Bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 26, 2025
@wallrj
wallrj self-requested a review May 13, 2025 09:59

@wallrj wallrj left a comment

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.

@erikgb You asked for more feedback during the cert-manager standup on 13 May 2025, so here are some of my questions and thoughts.

Comment thread docs/alphav2-changes.md
# Version v1alpha2 API changes

In v1alpha2, `ClusterBundle` was introduced as a replacement for v1alpha1 `Bundle`.
This was mainly done to make room for a future namespace-scoped `Bundle`.

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.

Why do we want a namespace-scoped Bundle?

The ClusterBundle design says:

it turns out that the current name somehow blocks introducing an equivalent namespace-scoped resource - for trust bundle management inside namespaces in multi-tenant clusters.

Why wouldn't the application-team just put the CA certificates in a ConfigMap and mount that into their Pod, alongside the ConfigMap containing up-to-date public CAs, that has been published to their tenant namespace by the platform-team, using trust-manager?

Why chose the name ClusterBundle?

The ClusterBundle design says:

In addition, ClusterBundle would be a better name looking at cert-manager having Issuer and ClusterIssuer. The name would also be better aligned with upstream ClusterTrustBundle.

I agree that the name ClusterBundle is more consistent with the name ClusterIssuer in cert-manager.

I do not agree that the name is better aligned with ClusterTrustBundle....I expect it will cause confusion.
ClusterTrustBundle seems to be a cluster-scoped container for CA certificates, which can be mounted into Pods.
ClusterBundle (AFAIU) is a configuration for trust-manager, telling it where to pull CA certificates from, and where to push them to. Ultimately: ConfigMap, Secret, ClusterTrustBundle.
So we will be writing documentation asking users to:

Create a trust-manager Bundle or ClusterBundle to copy CA certificates into a Kubernetes ClusterTrustBundle and then mount that Kubernetes ClusterTrustBundle into your Pod.

Do you agree that this is confusing?
If we're going to change the name, shouldn't we choose something completely different, like TrustManagerClusterMapping and TrustManagerMapping, to differentiate it from the Kubernetes resource.

Why did Kubernetes choose a cluster-scoped Bundle?

I am confused about why Kubernetes chose cluster-scoped ClusterTrustBundle and why they seem to explicitly avoid introducing a namespaced resource. In my mind, this conflicts your aim of making it easier to manage CA bundles in a multi-tenant cluster.
Do you know if they ever talked about how ClusterTrustBundle would work for multiple application teams who share a cluster?

For example: https://github.com/kubernetes/enhancements/tree/master/keps/sig-auth/3257-cluster-trust-bundles#access-control

All ClusterTrustBundle objects are assumed to be publicly-readable within the cluster, due to the fact that the kubelet trustAnchors volume type will allow any pod to mount any ClusterTrustBundle. This will be backed up by a built-in grant of get, list, and watch for ClusterTrustBundle objects to the system:serviceaccounts and system:nodes groups.
For ClusterTrustBundle objects without .spec.signerName specified, no nonstandard access control is applied. Due to the clusterTrustBundle projected volume, any workload in the cluster will be able to load the contents of any ClusterTrustBundle.

Another example: in https://github.com/kubernetes/enhancements/tree/master/keps/sig-auth/3257-cluster-trust-bundles#use-a-configmap-rather-than-defining-a-new-type which says:

Use a ConfigMap rather than defining a new type
ConfigMaps have two problems in this application:
They are namespace-scoped, whereas signers are cluster-scoped.
They have poor human factors. They are not often considered to contain security-critical data, and so may have wide update permissions assigned to them.

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.

Why wouldn't the application-team just put the CA certificates in a ConfigMap and mount that into their Pod, alongside the ConfigMap containing up-to-date public CAs, that has been published to their tenant namespace by the platform-team, using trust-manager?

They could do this but it's super hostile UX in practice. Most programming languages can mount only one trust store, or else make it fiddly to use multiple. This creates a need to combine trust bundles which must generally be available before the application can do anything, which leads to everyone having to write the same code to combine them that we already have in trust-manager, and ensuring that that code runs before their application runs.

I do not agree that the name is better aligned with ClusterTrustBundle....I expect it will cause confusion.
ClusterTrustBundle seems to be a cluster-scoped container for CA certificates, which can be mounted into Pods.

I definitely see there's a risk for confusion here, but I don't think it's a huge risk that really concerns me. In cert-manager we have the CertificateRequest resource which is similar to the CertificateSigningRequest native resource and I don't see people getting confused about it too badly.

The risk is maybe higher for trust-manager but I don't think it's a blocker even so! We could definitely consider a different name, but I prefer ClusterBundle to anything else I've seen so far or anything I can think of right now.

I am confused about why Kubernetes chose cluster-scoped ClusterTrustBundle and why they seem to explicitly avoid introducing a namespaced resource. In my mind, this conflicts your aim of making it easier to manage CA bundles in a multi-tenant cluster.

I'd be interested in learning more about their decisions too, but I think we're solving different problems to what ClusterTrustBundle tries to solve and that's OK!

I don't think ClusterTrustBundle is trying to solve trust bundle distribution for Kubernetes generally - and we are. It's an important differentiator for us to go above and beyond what CTB is trying to do!

@SgtCoDFish SgtCoDFish left a comment

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.

/lgtm
/approve
/hold

I'm a little out of it today, but I can't really see a reason that this shouldn't be merged so I'm adding a quick approval in case that unblocks Erik / allows us to iterate on this. Thank you for this!

@cert-manager-prow cert-manager-prow Bot added the lgtm Indicates that a PR is ready to be merged. label May 16, 2025
@cert-manager-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: SgtCoDFish

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

@cert-manager-prow cert-manager-prow Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 16, 2025
@SgtCoDFish

Copy link
Copy Markdown
Member

This was discussed in standup today, and it was agreed we should unhold so this can move forwards. Thanks for your patience Erik!

/unhold

@cert-manager-prow cert-manager-prow Bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 30, 2025
@cert-manager-prow
cert-manager-prow Bot merged commit 8f7585c into cert-manager:main May 30, 2025
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. dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. lgtm Indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants