Skip to content
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

Enable k8s client cache for Secrets and ConfigMaps in the single namespace mode #3825

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tfujiwar
Copy link
Contributor

@tfujiwar tfujiwar commented Nov 27, 2024

WHAT

  • Allow the controller to watch Secrets / ConfigMaps in the single namespace mode.
  • Enable the k8s API client cache for Secrets / ConfigMaps in the single namespace mode.

WHY

To reduce latency of runner pod creation (#3276).

The EphemeralRunnerReconciler retrieves a JITConfig Secret for every reconciliation once the Secret is created. It can be a performance bottleneck because the k8s API client cache is disabled for Secrets.

The cache has been disabled for Secrets because it requires cluster-wide list/watch permissions in the default mode. But in the single namespace mode, we can narrow down the permissions only to the single namespace and the controller namespace, which would be acceptable.

This change is aligned with ADR 2023-04-11: Limit Permissions for Service Accounts in Actions-Runner-Controller.

In this mode, you will end up with a manager Role that has all Get/List/Create/Delete/Update/Patch/Watch permissions on resources we need, and a RoleBinding to bind the Role with the controller ServiceAccount in the watched single namespace and the controller namespace

TESTING

We have tested the change with a controller that manages 300-400 EphemeralRunners at peak times. We confirmed that the duration of getting k8s Secrets from the EphemeralRunnerReconciler has decreased due to the caching.

Screenshot 2024-11-27 at 12 06 56

We also confirmed that the number of Pending EphemeralRunners has decreased because they are reconciled faster.

Before

Screenshot 2024-11-27 at 12 23 39

After

Screenshot 2024-11-27 at 12 22 42

@tfujiwar tfujiwar marked this pull request as ready for review November 27, 2024 03:31
@tfujiwar tfujiwar changed the title Allow the controller to watch Secrets / ConfigMaps in the single namespace mode Allow the controller to cache Secrets / ConfigMaps in the single namespace mode Dec 5, 2024
@tfujiwar tfujiwar changed the title Allow the controller to cache Secrets / ConfigMaps in the single namespace mode Enable k8s client cache for Secrets and ConfigMaps in the single namespace mode Dec 5, 2024
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.

1 participant