oc Project Examples¶
Introduction¶
Use oc project to view or switch the default namespace for oc commands. This prevents repeated -n flags, but it also means a stale project can send commands to the wrong application.
When You Need This Command¶
Use this command when you need to inspect, change, or verify OpenShift resources from the terminal without relying on the web console.
Syntax¶
oc <command> <resource> [name] -n <project>
Practical Examples¶
oc project
oc projects
oc project app-dev
oc get pods
Example output:
Using project "app-dev" on server "https://api.ocp.example.com:6443".
Verification¶
oc project
oc get pods
oc config view --minify
Common Mistakes¶
- Running destructive commands after forgetting the active project.
- Using oc project when the project does not exist.
- Assuming project names match application names.
Production Notes¶
Run read-only commands first, check the active project, and prefer declarative manifests for repeatable changes.
Quick Checklist¶
- Confirm the active project.
- Inspect the exact object named in the error.
- Read recent events.
- Apply one focused fix.
- Verify status after the change.
Related Guides¶
Summary¶
oc Project Examples is most useful when paired with verification. Check the project, run the command against the intended object, and confirm the resulting OpenShift state.