diff --git a/config/manager/kustomization.yaml b/config/manager/kustomization.yaml index 55c8015c..1f89c672 100644 --- a/config/manager/kustomization.yaml +++ b/config/manager/kustomization.yaml @@ -14,3 +14,12 @@ images: - name: controller newName: quay.io/cryostat/cryostat-operator newTag: 3.0.0-dev + +# patchesJson6902: +# - path: patches/force_openshift_patch.yaml +# target: +# group: apps +# kind: Deployment +# name: controller-manager +# namespace: system +# version: v1 diff --git a/config/manager/patches/force_openshift_patch.yaml b/config/manager/patches/force_openshift_patch.yaml new file mode 100644 index 00000000..c3d152ed --- /dev/null +++ b/config/manager/patches/force_openshift_patch.yaml @@ -0,0 +1,3 @@ +- op: add + path: /spec/template/spec/containers/0/args/- + value: --force-openshift diff --git a/internal/main.go b/internal/main.go index 51a74676..272f0a6b 100644 --- a/internal/main.go +++ b/internal/main.go @@ -75,6 +75,7 @@ func main() { var probeAddr string var secureMetrics bool var enableHTTP2 bool + var forceOpenShift bool flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.") flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.") flag.BoolVar(&enableLeaderElection, "leader-elect", false, @@ -83,6 +84,7 @@ func main() { flag.BoolVar(&secureMetrics, "metrics-secure", false, "If set the metrics endpoint is served securely") flag.BoolVar(&enableHTTP2, "enable-http2", false, "If HTTP/2 should be enabled for the metrics and webhook servers.") + flag.BoolVar(&forceOpenShift, "force-openshift", false, "Force the controller to consider current platform as OpenShift") opts := zap.Options{ Development: true, } @@ -138,7 +140,7 @@ func main() { os.Exit(1) } - openShift, err := isOpenShift(dc) + openShift, err := isOpenShift(dc, forceOpenShift) if err != nil { setupLog.Error(err, "could not determine whether manager is running on OpenShift") os.Exit(1) @@ -205,7 +207,10 @@ func main() { } } -func isOpenShift(client discovery.DiscoveryInterface) (bool, error) { +func isOpenShift(client discovery.DiscoveryInterface, forceOpenShift bool) (bool, error) { + if forceOpenShift { + return true, nil + } return discovery.IsResourceEnabled(client, routev1.GroupVersion.WithResource("routes")) }