Skip to content

Commit df99a4b

Browse files
authored
[fix]: Add oc check to kubernetes-dev-env script (neuralmagic#90)
Signed-off-by: Kfir Toledo <[email protected]>
1 parent 926d489 commit df99a4b

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

scripts/kubernetes-dev-env.sh

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,12 @@ kubectl create namespace ${NAMESPACE} 2>/dev/null || true
9797
# Hack to deal with KGateways broken OpenShift support
9898
export PROXY_UID=$(kubectl get namespace ${NAMESPACE} -o json | jq -e -r '.metadata.annotations["openshift.io/sa.scc.uid-range"]' | perl -F'/' -lane 'print $F[0]+1');
9999

100+
# Detect if the cluster is OpenShift by checking for the 'route.openshift.io' API group
101+
IS_OPENSHIFT=false
102+
if kubectl api-resources 2>/dev/null | grep -q 'route.openshift.io'; then
103+
IS_OPENSHIFT=true
104+
fi
105+
100106
set -o pipefail
101107

102108
if [[ "$CLEAN" == "true" ]]; then
@@ -105,7 +111,14 @@ if [[ "$CLEAN" == "true" ]]; then
105111
kustomize build deploy/environments/dev/kubernetes-vllm/${VLLM_MODE} | envsubst | kubectl -n "${NAMESPACE}" delete --ignore-not-found=true -f -
106112
else
107113
echo "INFO: Deploying vLLM Environment in namespace ${NAMESPACE}"
108-
oc adm policy add-scc-to-user anyuid -z default -n ${NAMESPACE}
114+
if [[ "${IS_OPENSHIFT}" == "true" ]]; then
115+
if command -v oc &>/dev/null; then
116+
# Grant the 'default' service account permission to run containers as any user (disables UID restrictions)
117+
oc adm policy add-scc-to-user anyuid -z default -n "${NAMESPACE}"
118+
echo "INFO: OpenShift cluster detected – granted 'anyuid' SCC to the 'default' service account in namespace '${NAMESPACE}'."
119+
fi
120+
fi
121+
109122
kustomize build deploy/environments/dev/kubernetes-vllm/${VLLM_MODE} | envsubst | kubectl -n "${NAMESPACE}" apply -f -
110123

111124
echo "INFO: Deploying Gateway Environment in namespace ${NAMESPACE}"

0 commit comments

Comments
 (0)