-
Notifications
You must be signed in to change notification settings - Fork 0
Inject global OpenShift pull-secret for Konflux deployment mode #186
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
base: main
Are you sure you want to change the base?
Changes from all commits
d42f6da
0ef817c
19aff82
bc2bd99
f2e97dd
0974da6
07e05e2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,6 +13,7 @@ import ( | |
| "time" | ||
|
|
||
| "github.com/fatih/color" | ||
| "k8s.io/client-go/kubernetes" | ||
|
|
||
| "github.com/stackrox/roxie/internal/component" | ||
| "github.com/stackrox/roxie/internal/dockerauth" | ||
|
|
@@ -46,6 +47,7 @@ type Deployer struct { | |
| envrcFile string | ||
|
|
||
| kubeContext string | ||
| k8sClient kubernetes.Interface | ||
|
|
||
| config Config | ||
|
|
||
|
|
@@ -263,6 +265,17 @@ func New(log *logger.Logger) (*Deployer, error) { | |
|
|
||
| d.kubeContext = env.GetCurrentContext() | ||
|
|
||
| // 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. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. 🤷 |
||
| if d.kubeContext != "" { | ||
| client, err := k8s.NewClient(d.kubeContext) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("creating new Kubernetes client: %w", err) | ||
| } | ||
| d.k8sClient = client | ||
| } | ||
|
|
||
| log.Success("🚀 ACS Deployer initialized") | ||
|
|
||
| return d, nil | ||
|
|
@@ -306,6 +319,17 @@ func (d *Deployer) Deploy(ctx context.Context, components component.Component) e | |
|
|
||
| d.logger.Infof("Initiating deployment of %s", components) | ||
|
|
||
| if d.config.Roxie.KonfluxImages && d.config.Roxie.ClusterType == types.ClusterTypeOpenShift4 { | ||
| // For deploying Konflux-built images, we need to configure image-rewriting on the cluster at the CRI-O level. | ||
| // But due to https://access.redhat.com/solutions/6540591 the standard pull-secret mechanism doesn't work for the | ||
| // target image references. A workaround is to inject the pull secrets we need into OpenShift's global | ||
| // pull secrets. | ||
| // Infra OpenShift4 clusters already come equipped with this global pull secret. | ||
| if err := d.InjectGlobalOpenShiftPullSecret(ctx); err != nil { | ||
| return fmt.Errorf("injecting global OpenShift pull-secret for Konflux images: %w", err) | ||
| } | ||
| } | ||
|
|
||
| // If only deploying operator, use the operator-only flow. | ||
| if components.IncludesOperatorExplicitly() { | ||
| return d.deployOperatorOnly(ctx) | ||
|
|
||
There was a problem hiding this comment.
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
kubectlinto direct calls to kube API server from Go?If not, where do we draw the line?
There was a problem hiding this comment.
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.