OpenShift CLI

OpenShift CLI: oc

The OpenShift CLI “oc” can be installed on your computer, see Get Started with the CLI. Before issuing an oc command, you must login to the OpenShift master with oc login. It will ask for an URL to the master (if started for the first time) and for a username and password.

  • oc whoami
    If you can’t remember who you are, this tells it to you.
  • oc project $NAME
    Shows the currently active project to which all commands are run against. If a project ame is added to the command then the currently active project changes.
  • oc get projects
    Displays a list of projects to which the current user has access to
  • oc status
    Status overview of the current project
  • oc describe $TYPE $NAME
    Detailed information about an object.oc describe pod drupal-openshift-1-m3uvx
  • oc get event
    Shows all events in the current project. Very useful for finding out what happened.
  • oc logs [-f] $PODNAME
    Show the logs of a running pod. With -f it tails the log much like tail -f.
  • oc get pod [-w]
    List of pods in the current project. With -w it shows changes in pods. Note: watch oc get pod is a helpful way to watch for pod changes
  • oc rsh $PODNAME
    Start a remote shell in the running pod to execute commands
  • oc exec $PODNAME $COMMAND
    Execute a command in the running pod. The command’s output is sent to your shell.
  • oc delete events –all
    Cleanup all events. Useful if there are a lot of old events. Events are information about what is going on on the API objects and what problems exist (if there are any).
  • oc get builds
    List of builds. A build is a process of creating runnable images to be used on OpenShift.

oc logs build/$BUILDID
Build log of the build with the id “buildid”. This corresponds to the list of builds which are displayed with the command above.

Leave a Reply

Your email address will not be published. Required fields are marked *