openshift

OpenShift Cheat Sheet

This is intended as a quick reference for OpenShift commands.

OpenShift Cheat Sheet
Login/User management
oc loginauthenticate to an openshift
oc logoutend the current session
oc whoamishow the current user context
oc login -u kubeadmin -p xxx https://api.crc.testing:6443
Project management
oc projectshow the current project context
oc get projectsshow all project current login has access to
oc statusshow overview of current project resources
oc new-projectcreate a new project and change to that context
oc create namespace peewee
oc project peewee
Resource management
oc new-appcreate a new app from source code, image, or template
oc new-buildcreate a new build configuration from source code
oc labeladd/update/remove labels from a resource
oc annotateadd/update/remove annotations from a resource
oc createcreate a new resource from filename or stdin
oc getretrieve a resource
oc replacereplace an existing resource from filename or stdin
oc deletedelete a resource
oc editmodify a resource from text editor
oc describeretrieve a resource with details
oc new-app https://github.com/chefbc/peewee.git
Operational commands
oc logsretrieve the logs for a resource
oc rshremote shell into a container
oc rsynccopy files to or from a container
oc execexecute a command in a container
oc runcreate a deployment configuration from image
oc idlescale resources to zero replicas
oc logs -f peewee-1-build
oc logs -f peewee-

oc get services --namespace=peewee
oc expose svc/peewee
oc get routes
Operational commands
oc rolloutmanage deployments from configuration
oc rollout lateststart a new deployment with the latest state
oc rollout undoperform a rollback operation
oc rollout historyhistorical info for a deployment configuration
oc rollout statuswatch the status of a rollout until complete
oc tagtag existing images into image streams
oc start-buildstart a new build from a build configuration
oc cancel-buildcancel a build in progress
oc import-imagepull in images and tags from an external Docker registry
oc scalechange the number of pod replicas for a deployment
oc start-build peewee