Skip to content

Inject global OpenShift pull-secret for Konflux deployment mode#186

Open
mclasmeier wants to merge 19 commits into
mc/cluster-type-overwritablefrom
mc/inject-global-pull-secret
Open

Inject global OpenShift pull-secret for Konflux deployment mode#186
mclasmeier wants to merge 19 commits into
mc/cluster-type-overwritablefrom
mc/inject-global-pull-secret

Conversation

@mclasmeier
Copy link
Copy Markdown
Collaborator

@mclasmeier mclasmeier commented May 15, 2026

This PR is based on:
PR #184 (f9ce245)

When deploying Konflux-built images on OpenShift 4, the standard namespace-level pull secret mechanism doesn't work for CRI-O due to a known limitation. This PR works around this by injecting registry credentials for quay.io/rhacs-eng into OpenShift's global pull secret (openshift-config/pull-secret) before deployment.

For reliable patching of an externally-owned resource we use a proper Kubernetes client, allowing for precise retry-in-conflict behavior.

Detailed changes:

  • Add k8s.io/client-go dependency and k8s.NewClient() helper
  • Create the Kubernetes client during deployer initialization
  • Implement create-or-update logic for the global pull secret with retry handling for TOCTOU races, since this not a roxie-owned resource
  • Gate the injection on KonfluxImages && ClusterTypeOpenShift4 (infra clusters already have the secret)
  • Unit tests for injectRegistryCredentialsIntoSecret

@mclasmeier mclasmeier marked this pull request as draft May 15, 2026 09:23
@mclasmeier mclasmeier requested review from AlexVulaj and davdhacs May 15, 2026 09:52
@mclasmeier mclasmeier added the ci-rollout Marks a PR to be a prerequisite for rolling out roxie in stackrox CI. label May 15, 2026
mclasmeier and others added 2 commits May 15, 2026 12:09
Co-authored-by: Moritz Clasmeier <mclasmeier@redhat.com>
Co-authored-by: Moritz Clasmeier <mclasmeier@redhat.com>
Co-authored-by: Misha Sugakov <537715+msugakov@users.noreply.github.com>
@mclasmeier mclasmeier force-pushed the mc/inject-global-pull-secret branch from 8b06e58 to bca8987 Compare May 15, 2026 11:52
Co-authored-by: Moritz Clasmeier <mclasmeier@redhat.com>
@mclasmeier mclasmeier requested a review from porridge May 18, 2026 06:28
@mclasmeier mclasmeier marked this pull request as ready for review May 18, 2026 06:28
Copy link
Copy Markdown
Contributor

@porridge porridge left a comment

Choose a reason for hiding this comment

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

@mclasmeier you say [REVIEW RELATIVE TO https://github.com/stackrox/roxie/commit/44be07b7d65bdd98ab8299e1d19916bc1697568a] but I cannot see this commit in the list...

mclasmeier and others added 16 commits May 18, 2026 11:07
Co-authored-by: Moritz Clasmeier <mclasmeier@redhat.com>
Co-authored-by: Marcin Owsiany <porridge@redhat.com>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Moritz Clasmeier <mclasmeier@redhat.com>
Co-authored-by: Moritz Clasmeier <mclasmeier@redhat.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
@mclasmeier mclasmeier force-pushed the mc/inject-global-pull-secret branch from bca8987 to 446e42b Compare May 18, 2026 17:59
@mclasmeier
Copy link
Copy Markdown
Collaborator Author

@mclasmeier you say [REVIEW RELATIVE TO https://github.com/stackrox/roxie/commit/44be07b7d65bdd98ab8299e1d19916bc1697568a] but I cannot see this commit in the list...

Updated commit in description!

@mclasmeier mclasmeier changed the base branch from main to mc/cluster-type-overwritable May 18, 2026 18:01
@mclasmeier mclasmeier requested a review from porridge May 18, 2026 18:02
Copy link
Copy Markdown
Contributor

@porridge porridge left a comment

Choose a reason for hiding this comment

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

Are you aware that updating the global image pull secret requires a rolling restart of all nodes? Maybe it would be better to integrate with the image prefetcher for speed instead?

d.kubeContext = env.GetCurrentContext()

// Created eagerly (not lazily on first use) because
// 1. we expect to make more extensive use of it
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.

So are we now going to migrate uses of kubectl into direct calls to kube API server from Go?
If not, where do we draw the line?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I think it's something to consider.
But I don't see any urgency in doing so.
For certain new use-cases, like my conflict handling in this PR, i think it makes sense to use client-go.


// Created eagerly (not lazily on first use) because
// 1. we expect to make more extensive use of it
// 2. we need a working connection to the API server anyway.
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.

AFAICT we only need the connection in a very narrow case: downstream images on an OpenShift cluster, and only until https://redhat.atlassian.net/browse/RFE-1956 is shipped (already in dev preview in 4.21 judging by the comments there), so this comment seems like a stretch.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Well, that is currently exactly the use-case I am trying to wrap up. 🤷

@mclasmeier
Copy link
Copy Markdown
Collaborator Author

Are you aware that updating the global image pull secret requires a rolling restart of all nodes? Maybe it would be better to integrate with the image prefetcher for speed instead?

I haven't been aware of this requirement for the nodes.

I haven't run experiments with the image prefetcher as of now.
I hope that it would really allow us to skip the pull-secret patching.

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

Labels

ci-rollout Marks a PR to be a prerequisite for rolling out roxie in stackrox CI.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants