in container

OpenShift Command oc Cheat Sheat

The content is based on OpenShift 3.9

  • Log in to OpenShift cluster and save the session token for subsequent use
    • oc login <server>
    • oc login --username <username>
    • oc login --username <username> --password <password>
    • oc login --token <token>

  • Show the status of the user for the current login session.
    • oc whoami
    • oc whoami --show-token
    • oc whoami --show-server
    • oc whoami --show-context
  • Show a list of all OpenShift clusters ever logged in to
    • oc config get-clusters
  • Show a list of contexts for all sessions ever created. For each context listed, this will include details about the project, server and name of user, in that order
    • oc config get-contexts
  • Add another user to a project such that they are effecively a joint owner of the project and have administration rights over it, including the ability to delete the project
    • oc adm policy add-role-to-user admin <username> -n <project>
  • List all pods and show more details about project
    • oc get all -owide
  • Scale out replication/deployment controller name ‘foo’ to 3
    • oc scale --replicas=3 replicationcontrollers foo
    • oc scale --replicas=3 dc foo
  • Monitor event continuity from OpenShift cluster in the console
    • oc get event -w