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 all 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
9 changes: 9 additions & 0 deletions pkg/rendering/renderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ type Global struct {
Source string `json:"source" structs:"source"`
SourceNamespace string `json:"sourceNamespace" structs:"sourceNamespace"`
HubSize v1.HubSize `json:"hubSize" structs:"hubSize" yaml:"hubSize"`
APIUrl string `json:"apiUrl" structs:"apiUrl"`
Target string `json:"target" structs:"target"`
BaseDomain string `json:"baseDomain" structs:"baseDomain"`
}

type HubConfig struct {
Expand Down Expand Up @@ -344,6 +347,12 @@ 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.Global.BaseDomain = os.Getenv("INGRESS_DOMAIN")

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

values.Global.Target = "acm"

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

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