Skip to content

K8SPS-649 support ClusterIssuer#1421

Merged
oksana-grishchenko merged 23 commits into
mainfrom
K8SPS-649-support-clusterissuer
Jul 7, 2026
Merged

K8SPS-649 support ClusterIssuer#1421
oksana-grishchenko merged 23 commits into
mainfrom
K8SPS-649-support-clusterissuer

Conversation

@oksana-grishchenko

@oksana-grishchenko oksana-grishchenko commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

K8SPS-649 support ClusterIssuer

Problem:
Operator does not support using ClusterIssuer although it's stated in docs

Cause:
In the codebase we check explicitly if the Issuer exists in the cluster. However the ClusterIssuer is a different kind so it failed the check

Solution:
Check the kind of the resource referenced in .spec.tls and get the resource accordingly. Ignore RBAC-denied errors and let cert-manager handle issuer resolution. In case the configured ClusterIssuer does not exist indeed, the Certificate that references it will stay not ready, the waitForCert() eventually times out and returns reconciliation error timeout: tls certificate from certmanager is not ready

Update e2e tests to check if ClusterIssuer works.

We can mention it in docs that in order to use ClusterIssuer you need additionally to apply matching RBAC.

CHECKLIST

Jira

  • Is the Jira ticket created and referenced properly?
  • Does the Jira ticket have the proper statuses for documentation (Needs Doc) and QA (Needs QA)?
  • Does the Jira ticket link to the proper milestone (Fix Version field)?

Tests

  • Is an E2E test/test case added for the new feature/change?
  • Are unit tests added where appropriate?

Config/Logging/Testability

  • Are all needed new/changed options added to default YAML files?
  • Are all needed new/changed options added to the Helm Chart?
  • Did we add proper logging messages for operator actions?
  • Did we ensure compatibility with the previous version or cluster upgrade process?
  • Does the change support oldest and newest supported PS version?
  • Does the change support oldest and newest supported Kubernetes version?

Signed-off-by: Oksana Grishchenko <oksana.grishchenko@percona.com>
Signed-off-by: Oksana Grishchenko <oksana.grishchenko@percona.com>
Signed-off-by: Oksana Grishchenko <oksana.grishchenko@percona.com>
Signed-off-by: Oksana Grishchenko <oksana.grishchenko@percona.com>
Signed-off-by: Oksana Grishchenko <oksana.grishchenko@percona.com>
Signed-off-by: Oksana Grishchenko <oksana.grishchenko@percona.com>
Copilot AI review requested due to automatic review settings June 23, 2026 07:49
@pull-request-size pull-request-size Bot added the size/L 100-499 lines label Jun 23, 2026
@github-actions github-actions Bot added the tests label Jun 23, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds support for cert-manager ClusterIssuer references in .spec.tls.issuerConf, along with RBAC and e2e coverage updates to validate the behavior.

Changes:

  • Update TLS issuer lookup logic to fetch either namespaced Issuer or cluster-scoped ClusterIssuer based on .spec.tls.issuerConf.kind.
  • Add controller/operator RBAC rules for clusterissuers (get/list/watch).
  • Extend unit/e2e tests to exercise ClusterIssuer usage and validate certificates after switching issuer kind.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
pkg/controller/ps/tls.go Adds kind-based lookup to support ClusterIssuer in checkTLSIssuer; uses cert-manager kind constants.
pkg/controller/ps/tls_test.go Adds a unit test intended to validate ClusterIssuer handling (currently has a type issue).
pkg/controller/ps/controller.go Adds kubebuilder RBAC marker for clusterissuers.
e2e-tests/tests/tls-cert-manager/07-switch-to-cluster-issuer.yaml Adds step to grant cluster-wide RBAC + create a ClusterIssuer + patch the CR to use it (namespace handling needs adjustment).
e2e-tests/tests/tls-cert-manager/07-assert-cluster-issuer.yaml Asserts certificate issuerRef fields and cluster readiness after switching to ClusterIssuer.
e2e-tests/tests/tls-cert-manager/08-check-cert-after-cluster-issuer.yaml Verifies certificate SANs after switching issuer kind.
e2e-tests/tests/tls-cert-manager/97-cleanup-cluster-issuer-rbac.yaml Cleans up ClusterIssuer and associated cluster-wide RBAC created by the test.
deploy/rbac.yaml Adds clusterissuers rule to a namespaced Role (does not actually grant access to cluster-scoped resources).
deploy/cw-rbac.yaml Adds clusterissuers rule to the cluster-wide RBAC manifest.
deploy/bundle.yaml Adds clusterissuers rule inside a Role in the standard bundle (won’t authorize cluster-scoped access).
deploy/cw-bundle.yaml Adds clusterissuers rule in the cluster-wide bundle.
config/rbac/role.yaml Adds clusterissuers permissions to the generated ClusterRole.
config/rbac/cluster/role.yaml Adds clusterissuers permissions to the generated cluster-scoped role.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/controller/ps/tls_test.go
Comment thread e2e-tests/tests/tls-cert-manager/07-switch-to-cluster-issuer.yaml Outdated
Comment thread deploy/rbac.yaml Outdated
Comment thread deploy/bundle.yaml Outdated
Signed-off-by: Oksana Grishchenko <oksana.grishchenko@percona.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.

Comment thread deploy/rbac.yaml Outdated
Comment thread deploy/bundle.yaml Outdated
Comment thread config/rbac/role.yaml Outdated
Signed-off-by: Oksana Grishchenko <oksana.grishchenko@percona.com>
Signed-off-by: Oksana Grishchenko <oksana.grishchenko@percona.com>
Copilot AI review requested due to automatic review settings June 24, 2026 11:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Comment thread pkg/controller/ps/tls.go
Comment thread e2e-tests/tests/tls-cert-manager/07-switch-to-cluster-issuer.yaml Outdated
oksana-grishchenko and others added 2 commits June 24, 2026 16:24
Signed-off-by: Oksana Grishchenko <oksana.grishchenko@percona.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 24, 2026 11:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Comment thread pkg/controller/ps/tls.go
Comment on lines +127 to +131
err := r.Get(ctx, nn, obj)
if kind == cm.ClusterIssuerKind && k8serrors.IsForbidden(err) {
// In namespaced installs we may not have cluster-scoped read permissions.
// Ignore only RBAC-denied errors and let cert-manager handle issuer resolution.
return nil
Comment thread pkg/controller/ps/tls_test.go Outdated
Comment on lines +234 to +238
BeforeAll(func() {
_, err := envtest.InstallCRDs(cfg, envtest.CRDInstallOptions{
Paths: []string{filepath.Join("testdata", "cert-manager.yaml")},
})
Expect(err).NotTo(HaveOccurred())

@mayankshah1607 mayankshah1607 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

One thing to check is that the cm.ObjectReference is deprecated, and we can use cm.IssuerReference instead.. (not so important because ObjectReference is internally aliased to IssuerReference anyway)

mayankshah1607
mayankshah1607 previously approved these changes Jun 26, 2026
Signed-off-by: Oksana Grishchenko <oksana.grishchenko@percona.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 8 changed files in this pull request and generated 1 comment.

Files not reviewed (1)
  • api/v1/zz_generated.deepcopy.go: Generated file

Comment thread pkg/controller/ps/tls.go
Comment on lines +127 to +134
err := r.Get(ctx, nn, obj)
if kind == cm.ClusterIssuerKind && k8serrors.IsForbidden(err) {
// In namespaced installs we may not have cluster-scoped read permissions.
// Ignore only RBAC-denied errors and let cert-manager handle issuer resolution.
return nil
}

return err
Comment thread pkg/controller/ps/tls_test.go Outdated
Comment thread pkg/controller/ps/tls_test.go Outdated
Comment thread pkg/controller/ps/tls_test.go
Comment thread pkg/controller/ps/tls_test.go
Signed-off-by: Oksana Grishchenko <oksana.grishchenko@percona.com>
@oksana-grishchenko oksana-grishchenko requested a review from gkech July 1, 2026 13:18
@JNKPercona

Copy link
Copy Markdown
Collaborator
Test Name Result Time
async-ignore-annotations-8-4 passed 00:00:00
async-global-metadata-8-4 passed 00:00:00
async-upgrade-8-0 passed 00:00:00
async-upgrade-8-4 passed 00:00:00
auto-config-8-4 passed 00:00:00
config-8-4 passed 00:00:00
config-router-8-0 passed 00:00:00
config-router-8-4 passed 00:00:00
demand-backup-8-0 passed 00:00:00
demand-backup-8-4 passed 00:00:00
gr-pitr-minio-8-4 passed 00:00:00
gr-pitr-one-pod-8-4 passed 00:00:00
async-pitr-minio-8-4 passed 00:00:00
demand-backup-cloud-8-4 passed 00:00:00
demand-backup-retry-8-4 passed 00:16:31
demand-backup-incremental-8-0 passed 00:00:00
demand-backup-incremental-8-4 passed 00:00:00
async-data-at-rest-encryption-8-0 passed 00:00:00
async-data-at-rest-encryption-8-4 passed 00:00:00
gr-cross-cluster-8-0 passed 00:00:00
gr-cross-cluster-8-4 passed 00:00:00
gr-cross-cluster-backup-8-0 passed 00:16:01
gr-cross-cluster-backup-8-4 passed 00:00:00
gr-global-metadata-8-4 passed 00:00:00
gr-data-at-rest-encryption-8-0 passed 00:00:00
gr-data-at-rest-encryption-8-4 passed 00:00:00
gr-demand-backup-8-4 passed 00:00:00
gr-demand-backup-cloud-8-4 passed 00:00:00
gr-demand-backup-haproxy-8-4 passed 00:00:00
gr-demand-backup-incremental-8-0 passed 00:00:00
gr-demand-backup-incremental-8-4 passed 00:00:00
gr-demand-backup-incremental-compressed-8-0 passed 00:00:00
gr-demand-backup-incremental-compressed-8-4 passed 00:00:00
gr-demand-backup-incremental-encrypted-8-0 passed 00:00:00
gr-demand-backup-incremental-encrypted-8-4 passed 00:00:00
gr-finalizer-8-4 passed 00:00:00
gr-haproxy-8-0 passed 00:00:00
gr-haproxy-8-4 passed 00:00:00
gr-ignore-annotations-8-4 passed 00:00:00
gr-init-deploy-8-0 passed 00:00:00
gr-init-deploy-8-4 passed 00:00:00
gr-one-pod-8-4 passed 00:00:00
gr-recreate-8-4 passed 00:00:00
gr-scaling-8-4 passed 00:00:00
gr-scheduled-backup-8-4 passed 00:00:00
gr-scheduled-backup-incremental-8-4 passed 00:00:00
gr-security-context-8-4 passed 00:00:00
gr-self-healing-8-4 passed 00:24:02
gr-tls-cert-manager-8-4 passed 00:00:00
gr-users-8-4 passed 00:00:00
gr-upgrade-8-0 passed 00:00:00
gr-upgrade-8-4 passed 00:00:00
haproxy-8-0 passed 00:00:00
haproxy-8-4 passed 00:00:00
init-deploy-8-0 passed 00:00:00
init-deploy-8-4 passed 00:00:00
limits-8-4 passed 00:00:00
monitoring-8-4 passed 00:00:00
one-pod-8-0 passed 00:00:00
one-pod-8-4 passed 00:00:00
operator-self-healing-8-4 passed 00:00:00
pvc-auto-resize-8-4 passed 00:00:00
pvc-resize-8-4 passed 00:00:00
recreate-8-4 passed 00:00:00
scaling-8-4 passed 00:00:00
scheduled-backup-8-0 passed 00:00:00
scheduled-backup-8-4 passed 00:00:00
scheduled-backup-incremental-8-0 passed 00:00:00
scheduled-backup-incremental-8-4 passed 00:00:00
service-per-pod-8-4 passed 00:00:00
sidecars-8-4 passed 00:00:00
smart-update-8-4 passed 00:00:00
storage-8-4 passed 00:00:00
telemetry-8-4 passed 00:00:00
tls-cert-manager-8-4 passed 00:00:00
users-8-0 passed 00:00:00
users-8-4 passed 00:00:00
version-service-8-4 passed 00:00:00
Summary Value
Tests Run 78/78
Job Duration 00:54:53
Total Test Time 00:56:35

commit: f21ba3f
image: perconalab/percona-server-mysql-operator:PR-1421-f21ba3f2

@oksana-grishchenko oksana-grishchenko merged commit cdab0b7 into main Jul 7, 2026
16 checks passed
@oksana-grishchenko oksana-grishchenko deleted the K8SPS-649-support-clusterissuer branch July 7, 2026 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/L 100-499 lines tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants