CLI
OpenShift is accessible via CLI with a single binary called oc
This binary is downloadable here under the Download OpenShift Client Tools section.
On Mac's with HomeBrew you can run brew install openshift-cli
Once downloaded and extracted you can run oc help or take a look at our common used commands
Commonly used commands
| Command | Info |
|---|---|
oc login https://server.address | Login to the server |
oc projects | List all OpenShift projects you have access to |
oc project *project name* | Switch current context to selected project |
oc version | Prints local client version and version of the server logged in to |
oc status --suggest | Prints out status of a project and suggested fixes or changes |
oc get pods | List all project pods |
oc get -o wide pods | List all project pods with extended details |
oc get -o yaml pod/*podname* | Output the pod configuration as YAML for saving setup |
oc rsh *podname* | Remote shell (login) to a pod |
oc logs -f *podname* | Tail the logs from the pod |
oc describe pod/*podname* | Print out the configuration details |
oc rsync /path/to/localdir *podname*:/remote/dir | Copies local file to remote server (pod) path |
oc rsync *podname*:/remote/dir /path/to/localdir | Copies remote file to local path |
oc port-forward *podname* 3333:3306 | Port forwards local port 3333 to remote pod port 3306 |