Skip to content

[Bug]: Pooler ServiceAccount missing imagePullSecret when created #9426

Description

@mnencia

Is there an existing issue already for this bug?

  • I have searched for an existing issue, and could not find anything. I believe this is a new bug.

I have read the troubleshooting guide

  • I have read the troubleshooting guide and I think this is a new bug.

I am running a supported version of CloudNativePG

  • I have read the troubleshooting guide and I think this is a new bug.

Contact Details

No response

Version

1.28 (latest patch)

What version of Kubernetes are you using?

1.34

What is your Kubernetes environment?

Self-managed: kind (evaluation)

How did you install the operator?

YAML manifest

What happened?

When creating a new Pooler resource, the ServiceAccount is created without the default imagePullSecret, causing pooler pod failures when pulling images from private registries.

Root Cause

In internal/controller/pooler_update.go at line 238, when creating a new ServiceAccount, the code incorrectly passes resources.ServiceAccount (which is nil) instead of the local serviceAccount variable to ensureServiceAccountHaveImagePullSecret():

if resources.ServiceAccount == nil {
    serviceAccount := pgbouncer.ServiceAccount(pooler)
    ensureServiceAccountHaveImagePullSecret(resources.ServiceAccount, pullSecretName)  // BUG: passing nil
    contextLog.Info("Creating service account")
    // ...
}

Since ensureServiceAccountHaveImagePullSecret has a nil check that returns early:

func ensureServiceAccountHaveImagePullSecret(serviceAccount *corev1.ServiceAccount, pullSecretName string) {
    if serviceAccount == nil || pullSecretName == "" {
        return  // Returns immediately when serviceAccount is nil
    }
    // ... never reached
}

The pull secret is never added to the ServiceAccount.

Cluster resource

Relevant log output

Code of Conduct

  • I agree to follow this project's Code of Conduct

Activity

  1. self-assigned this
    on Dec 13, 2025
  2. added theissue type on Dec 13, 2025
  3. dosubot commented on Dec 13, 2025

    @dosubot

    You're correct—this is a real bug in the current code. When a new ServiceAccount is created for a Pooler, the code mistakenly passes resources.ServiceAccount (which is nil) to ensureServiceAccountHaveImagePullSecret, so the imagePullSecret is never added. This matches your analysis and is confirmed in the codebase.

    This issue is already being tracked upstream as issue #5300, and a maintainer has acknowledged that imagePullSecrets should be set on the ServiceAccount, not directly on the Pod. There's also a proposed fix in PR #5344 to address this behavior.

    Until a fix is released, you can work around this by manually patching the ServiceAccount after it's created to add the required imagePullSecret, or by editing the operator code to pass the correct variable. Keep an eye on the upstream PR and issue for resolution and update once a fix is merged and released.

    References:

    To reply, just mention @dosu.


    Docs are dead. Just use Dosu.

    Leave Feedback Ask Dosu about cloudnative-pg Share Dosu with your team

  4. added a commit that references this issue on Dec 15, 2025
    ecad176
  5. added 3 commits that reference this issue on Dec 15, 2025
    186653d
    a84be05
    e8f418d
  6. added a commit that references this issue on Dec 15, 2025
    2abbb31
  7. added a commit that references this issue on Jan 20, 2026
    c3d4930
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

triagePending triage

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions