A safe wrapper for OpenShift CLI (oc) that only allows read-only commands.
oc- A wrapper script that delegates to the actualocbinary but only allows read-only commandskubectl- A script that instructs users to useocinstead ofkubectl
The oc wrapper only permits the following read-only commands:
get- Display one or many resourcesdescribe- Show details of a specific resourcelogs- Print container logsexplain- Get documentation for a resourceadm top- Display resource usage statistics
Any attempt to run other commands (like apply, delete, edit, etc.) will be blocked.
# These commands will work
oc get pods
oc describe pod my-pod
oc logs my-pod
oc explain deployment
oc adm top nodes
# These commands will be blocked
oc delete pod my-pod
oc apply -f manifest.yaml
oc edit deployment my-deployment- Add this directory to your
PATHbefore the actualocbinary location - Update the
OC_BINARYpath in theocscript to point to your actualocinstallation
Edit the ALLOWED_COMMANDS array in the oc script to customize which commands are permitted:
ALLOWED_COMMANDS=(
"get"
"describe"
"logs"
"explain"
"adm top"
)This wrapper is useful when you want to:
- Prevent accidental modifications to cluster resources
- Provide safe read-only access to OpenShift clusters
- Ensure consistent behavior by only allowing vetted commands
- Reduce the risk of destructive operations