Skip to content

K8SPS-781: Add custom names for orchestrator RBAC resources - #1427

Open
Miracle05 wants to merge 1 commit into
percona:mainfrom
Miracle05:fix-orc-rbac-hardcode
Open

K8SPS-781: Add custom names for orchestrator RBAC resources#1427
Miracle05 wants to merge 1 commit into
percona:mainfrom
Miracle05:fix-orc-rbac-hardcode

Conversation

@Miracle05

@Miracle05 Miracle05 commented Jun 24, 2026

Copy link
Copy Markdown

CHANGE DESCRIPTION

Problem:
When multiple PerconaServerMySQL clusters with Orchestrator enabled are deployed in the same namespace, they conflict over a single set of RBAC resources (ServiceAccount, Role, RoleBinding) named percona-server-mysql-operator-orchestrator. This can cause reconcile errors (controller owner reference conflicts) and prevents running multiple Orchestrator instances in one namespace.

Cause:
spec.orchestrator.serviceAccountName was already supported for Orchestrator pods, but orchestrator.RBAC() always created RBAC objects with a hardcoded name (percona-server-mysql-operator-orchestrator), ignoring the CR value. As a result, all clusters in a namespace shared the same RBAC objects regardless of the configured service account name.
Solution:
Use cr.Spec.Orchestrator.ServiceAccountName (after defaults are applied) as the name for all Orchestrator RBAC resources: ServiceAccount, Role, and RoleBinding. Each cluster can now get an isolated RBAC set by setting a unique spec.orchestrator.serviceAccountName. If the field is not set, the default percona-server-mysql-operator-orchestrator is preserved — existing single-cluster deployments are unaffected.

CHECKLIST

Tests

  • Is an E2E test/test case added for the new feature/change?
    No E2E test — behavior fix for an existing field; covered by unit tests. Can add a multi-orchestrator E2E if the team wants it.
  • Are unit tests added where appropriate?

Config/Logging/Testability

  • Are all needed new/changed options added to default YAML files?
    no new option — spec.orchestrator.serviceAccountName already exists and is documented in deploy/cr.yaml

  • Are all needed new/changed options added to the Helm Chart?
    no Helm changes required — field already exposed

  • Did we add proper logging messages for operator actions?
    not applicable — behavior fix, no new operator actions

  • Did we ensure compatibility with the previous version or cluster upgrade process?

    Backward compatible via crVersion gate:

    • crVersion < 1.3.0 (or empty): legacy default SA name percona-server-mysql-operator-orchestrator is preserved
    • crVersion >= 1.3.0: new per-cluster default {cr.Name}-orchestrator
    • explicit spec.orchestrator.serviceAccountName always overrides defaults

    Upgrade path:

    • After bumping spec.crVersion to 1.3.0, the operator creates new per-cluster RBAC resources
    • Legacy shared SA/Role/RoleBinding can be removed manually if no longer used
  • Does the change support oldest and newest supported PS version?

  • Does the change support oldest and newest supported Kubernetes version?

@CLAassistant

CLAassistant commented Jun 24, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

meta := metav1.ObjectMeta{
Namespace: cr.Namespace,
Name: "percona-server-mysql-operator-orchestrator",
Name: cr.Spec.Orchestrator.ServiceAccountName,

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.

maybe the default orchestrator service account name should be changed as well to include cr.Name, so you don't need to set a custom name for the 2nd cluster

this should be done with a version check and should only apply >=1.3.0

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Good point, thanks. Updated the PR:

  • Added DefaultOrchestratorServiceAccountName() with a version gate:
    • for crVersion >= 1.3.0 the default is now {cr.Name}-orchestrator (aligned with {cr.Name}-clusterset and other per-cluster resources; happy to use percona-{cr.Name}-orchestrator if you prefer a vendor prefix)
    • for crVersion < 1.3.0 the legacy default percona-server-mysql-operator-orchestrator is preserved
  • orchestrator.RBAC() continues to use spec.orchestrator.serviceAccountName, so ServiceAccount, Role, and RoleBinding stay in sync

Upgrade path:

Operator upgrade to 1.3.0 alone does not change behavior for clusters with crVersion < 1.3.0
After bumping spec.crVersion to 1.3.0, the operator creates new per-cluster RBAC resources
The legacy shared SA/Role/RoleBinding can be removed manually if no longer used

@egegunes egegunes added this to the v1.3.0 milestone Jun 25, 2026
@Miracle05
Miracle05 force-pushed the fix-orc-rbac-hardcode branch from a206065 to 33f44cd Compare June 25, 2026 08:22
@pull-request-size pull-request-size Bot added size/M 30-99 lines and removed size/S 10-29 lines labels Jun 25, 2026
@Miracle05
Miracle05 force-pushed the fix-orc-rbac-hardcode branch from 33f44cd to 0d12164 Compare June 25, 2026 08:44
@Miracle05
Miracle05 requested a review from egegunes June 25, 2026 08:58
@egegunes egegunes changed the title Add custom names for orchestrator RBAC resources K8SPS-781: Add custom names for orchestrator RBAC resources Jun 26, 2026
egegunes
egegunes previously approved these changes Jun 26, 2026
gkech
gkech previously approved these changes Jun 29, 2026
@hors

hors commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

@Miracle05, could you please fix the conflicts?

@Miracle05

Copy link
Copy Markdown
Author

@Miracle05, could you please fix the conflicts?

Certainly, i will fix it tomorrow morning

@Miracle05
Miracle05 force-pushed the fix-orc-rbac-hardcode branch from 529d3c6 to af168d1 Compare July 8, 2026 19:31
@Miracle05
Miracle05 dismissed stale reviews from egegunes and gkech via fcf8148 July 8, 2026 20:00
@Miracle05
Miracle05 force-pushed the fix-orc-rbac-hardcode branch from af168d1 to fcf8148 Compare July 8, 2026 20:00
@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:00:00
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:00:00
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:00:00
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 failure 00:02:30
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:24:41
Total Test Time 00:02:30

commit: fcf8148
image: perconalab/percona-server-mysql-operator:PR-1427-fcf81487

@hors hors left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@egegunes @Miracle05 could you please check limits test?

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants