Openshift Cheat Sheet

0
1736
Redhat Openshift Container Platform
OpenShift is Red Hat container application platform. It is based on Kubernetes and to keep things short we are going to call it a PaaS.This is a short cheat sheet of the most important commands to know when working with Openshift.

Login User Management

Authenticate to an Openshift Cluster
oc login
End the current session
oc logout
Show the current user context
oc whoami

Project Management

Show the current project context
oc project
Show all project current login has access to
oc get projects
Show overview of current project resources
oc status
Create a new project in Openshift and change to that context
oc new-project

Resource Management

Create a new application from from source code, container image, or OpenShift template
oc new-app
Create a new build configuration from source code
oc new-build
Add/update/remove labels from an Openshift resource
oc label
Add/update/remove annotations from an Openshift resource
oc annotate
Create a new resource from filename or stdin
oc create
Retrieve a resource (use -o for additional output options)
oc get 
Replace an existing resource from filename or stdin
oc replace
Delete a resource
oc delete 
Modify a resource from text editor
oc edit
Retrieve a resource with details
oc describe

Cluster Management

Administrative functions for an openshift cluster
oc adm
Install a router or registry
oc adm router|registry
Manage role/scc to user/group bindings, as well as additional policy administration
oc adm policy
Run tests/validation against a cluster
oc adm diagnoctics
Unschedule/schedule/drain a node
oc adm cordon/uncordon/drain
Manage groups
oc adm groups
Show usage statistics of resources
oc adm top pods|nodes

Additional resource management

Update fields for a resource with JSON or YAML segments
oc patch
Get configmaps or secrets and save to disk
oc extract
Modify miscellaneous application resources
oc set
Add a readiness/liveness probe on pod template/deployment configuration
oc set probe
Manage volume types on a pod template/deployment configuration
oc set volumes
Set a script/command to execute as part of the build process
oc set build-hook
Set a secret to be included as part of the build process
oc set build-secret
Set environment variables on a pod template/deployment configuration/build configuration
oc set env
Update the image for deployment configurations/ daemonsets
oc set image
Set triggers for deployment configurations/build configurations
oc set triggers

Operational Commands

Retrieve the logs for a resource (build configurations, deployment configurations, and pods)
oc logs
Remote shell into a container
oc rsh
Copy files to or from a container
oc rsync
Execute a command in a container
oc exec
Create a deployment configuration from image
oc run
Scale resources to zero replicas
oc idle

Build-Deploy

Manage deployments from deployment configuration
oc rollout
Start a new deployment with the latest state
oc rollout latest
Perform a rollback operation
oc rollout undo
View historical information for a deployment configuration
oc rollout history
Watch the status of a rollout until complete
oc rollout status
Tag existing images into image streams
oc tag
Start a new build from a build configuration
oc start-build
Cancel a build in progress
oc cancel-build
Pull in images and tags from an external Docker registry
oc import-image
Change the number of pod replicas for a deployment
oc scale

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.