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

Update cli to detect OpenShift and provide notice to install SCC #2048

Merged
Merged
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
14 changes: 14 additions & 0 deletions src/pixie_cli/pkg/utils/checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ const (
ClusterTypeK0s
// ClusterTypeK3s is a k3s cluster.
ClusterTypeK3s
// ClusterTypeOpenShift is an OpenShift cluster.
ClusterTypeOpenShift
)

var allowedClusterTypes = []ClusterType{
Expand All @@ -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.
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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/")
}
Comment on lines +271 to +273
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't we allow the installation to go through after they install the SCC? won't this always block the install?

Copy link
Member Author

@ddelnano ddelnano Nov 25, 2024

Choose a reason for hiding this comment

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

Errors returned from these "cluster checks" causes the cli to print a warning and prompt the user to continue:

Some cluster checks failed. Pixie may not work properly on your cluster. Continue with deploy? (y/n) [y] :

The message contained in this error struct will be printed on the line before that message (see Test plan output).


return errors.New("Cluster type is not in list of known supported cluster types. Please see: https://docs.px.dev/installing-pixie/requirements/")
})
)
Expand Down
Loading