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

add logic to get open shift API URL #1877

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions controllers/multiclusterhub_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,11 @@ func (r *MultiClusterHubReconciler) Reconcile(ctx context.Context, req ctrl.Requ
return result, err
}

result, err = r.openShiftApiUrl(ctx, multiClusterHub)
if err != nil {
return result, err
}

result, err = r.createTrustBundleConfigmap(ctx, multiClusterHub)
if err != nil {
return result, err
Expand Down Expand Up @@ -1455,6 +1460,32 @@ func (r *MultiClusterHubReconciler) ingressDomain(
return ctrl.Result{}, nil
}

// ingressDomain is discovered from Openshift cluster configuration resources
func (r *MultiClusterHubReconciler) openShiftApiUrl(
ctx context.Context,
m *operatorv1.MultiClusterHub,
) (ctrl.Result, error) {
infrastructure := &configv1.Infrastructure{}
err := r.Client.Get(ctx, types.NamespacedName{
Name: "cluster",
}, infrastructure)
if err != nil {
r.Log.Error(err, "Failed to get Infrastructure")

return ctrl.Result{}, err
}

url := infrastructure.Status.APIServerURL
err = os.Setenv("API_URL", url)
if err != nil {
r.Log.Error(err, "Failed to set API_URL environment variable")

return ctrl.Result{}, err
}

return ctrl.Result{}, nil
}

func (r *MultiClusterHubReconciler) finalizeHub(reqLogger logr.Logger, m *operatorv1.MultiClusterHub, ocpConsole,
isSTSEnabled bool) error {
if err := r.cleanupAppSubscriptions(reqLogger, m); err != nil {
Expand Down
3 changes: 3 additions & 0 deletions controllers/multiclusterhub_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ func ApplyPrereqs(k8sClient client.Client) {
By("Creating Ingress")
Expect(k8sClient.Create(ctx, resources.OCPIngress())).Should(Succeed())

// By("Creating Infrastructure")
// Expect(k8sClient.Create(ctx, resources.OCPInfrastructure())).Should(Succeed())

By("Applying Namespace")
Expect(k8sClient.Create(ctx, resources.OCMNamespace())).Should(Succeed())
Expect(k8sClient.Create(ctx, resources.MonitoringNamespace())).Should(Succeed())
Expand Down
6 changes: 6 additions & 0 deletions pkg/rendering/renderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ type HubConfig struct {
OCPVersion string `json:"ocpVersion" structs:"ocpVersion"`
HubVersion string `json:"hubVersion" structs:"hubVersion"`
OCPIngress string `json:"ocpIngress" structs:"ocpIngress"`
APIUrl string `json:"apiUrl" structs:"apiUrl"`
Target string `json:"target" structs:"target"`
Copy link
Contributor

@rawagner rawagner Dec 18, 2024

Choose a reason for hiding this comment

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

could you please move Target to a Global section instead of HubConfig ?

Copy link
Contributor

Choose a reason for hiding this comment

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

@cameronmwall I just realized that since we have sub-charts in our helm chart, the sub-charts wont be able to access HubConfig section. Sub-charts can look only into global or their own specific sections in values.yaml.

we will need you to put APIUrl, Target and OCPIngress into global section

SubscriptionPause string `json:"subscriptionPause" structs:"subscriptionPause"`
}

Expand Down Expand Up @@ -344,6 +346,10 @@ func injectValuesOverrides(values *Values, mch *v1.MultiClusterHub, images map[s

values.HubConfig.OCPIngress = os.Getenv("INGRESS_DOMAIN")

Choose a reason for hiding this comment

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

OCPIngress would be necessary at global level, if we used baseDomain it would require no changes on our side but global.OCPIngress is also ok.

Choose a reason for hiding this comment

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

This is addressed now, thanks.!


values.HubConfig.APIUrl = os.Getenv("API_URL")

values.HubConfig.Target = "acm"

Choose a reason for hiding this comment

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

Those two would be necessary at global level

values.HubConfig.SubscriptionPause = utils.GetDisableClusterImageSets(mch)

values.Org = "open-cluster-management"
Expand Down
Loading