diff --git a/src/pixie_cli/pkg/utils/checks.go b/src/pixie_cli/pkg/utils/checks.go index f36d84ec1f7..cfaabed19de 100644 --- a/src/pixie_cli/pkg/utils/checks.go +++ b/src/pixie_cli/pkg/utils/checks.go @@ -65,6 +65,8 @@ const ( ClusterTypeK0s // ClusterTypeK3s is a k3s cluster. ClusterTypeK3s + // ClusterTypeOpenShift is an OpenShift cluster. + ClusterTypeOpenShift ) var allowedClusterTypes = []ClusterType{ @@ -75,6 +77,8 @@ var allowedClusterTypes = []ClusterType{ ClusterTypeMinikubeHyperkit, ClusterTypeK0s, ClusterTypeK3s, + // ClusterTypeOpenShift is omitted because it requires an additional setup (SecurityContextConstraints install). + // This prompts the user to install the SCC instead of blindly failing. } // detectClusterType gets the cluster type of the cluster for the current kube config context. @@ -153,6 +157,12 @@ func detectClusterType() ClusterType { } } + // Check if it is an OpenShift cluster + err = exec.Command("/bin/sh", "-c", "oc status").Run() + if err == nil { + return ClusterTypeOpenShift + } + return ClusterTypeUnknown } @@ -258,6 +268,10 @@ var ( } } + if clusterType == ClusterTypeOpenShift { + return errors.New("openshift cluster detected. Please note that a Security Context Constraint (SCC) is required to run Pixie. Install a SCC in the namespace designated for the Pixie install before continuing. See example on https://docs.px.dev/reference/admin/environment-configs/") + } + return errors.New("Cluster type is not in list of known supported cluster types. Please see: https://docs.px.dev/installing-pixie/requirements/") }) )