Find the Best Cosmetic Hospitals

Explore trusted cosmetic hospitals and make a confident choice for your transformation.

โ€œInvest in yourself โ€” your confidence is always worth it.โ€

Explore Cosmetic Hospitals

Start your journey today โ€” compare options in one place.

Openshift: Top OC Commands with Examples


0. First: audit your local oc

Run this first on your machine:

oc version
oc help
oc adm -h
oc api-resources
oc api-versions

For any command:

oc <command> --help
oc adm <command> --help
Code language: HTML, XML (xml)

Use this style for labs:

oc get pods -n myproject
oc get pods -o wide
oc get pods -o yaml
oc get pods -o json
Code language: JavaScript (javascript)

Most useful global patterns:

PatternWhy use itExample
-n <namespace>Run command in a specific namespace/projectoc get pods -n myproject
-A / --all-namespacesQuery across namespacesoc get pods -A
-o wideShow extra columnsoc get pods -o wide
-o yamlExport full YAMLoc get deployment web -o yaml
-o jsonExport full JSONoc get pod web -o json
--dry-run=client -o yamlGenerate YAML without creatingoc create deployment web --image=nginx --dry-run=client -o yaml
-l key=valueSelect by labeloc get pods -l app=web
--watchWatch changes liveoc get pods --watch
--as <user>Test as another user, if permittedoc auth can-i get pods --as alice

1. Core OpenShift workflow

This is the daily flow for almost every lab:

oc login https://api.crc.testing:6443 -u developer -p developer
oc whoami
oc new-project demo
oc new-app python:3.9~https://github.com/openshift-instruqt/blog-django-py --name=blog
oc status
oc get all
oc logs -f deployment/blog
oc expose service/blog
oc get route
oc delete all -l app=blog
Code language: JavaScript (javascript)

Expected output shape:

Login successful.

Now using project "demo" on server "https://api.crc.testing:6443".

deployment.apps/blog created
service/blog created
route.route.openshift.io/blog exposed

NAME       HOST/PORT                              PATH   SERVICES   PORT
blog       blog-demo.apps-crc.testing                    blog       8080
Code language: JavaScript (javascript)

Red Hatโ€™s official common-task examples include project creation, app creation, pod listing, log viewing, project switching, and status checking. (Red Hat Documentation)


OC Commands workflow – a complete one.

# ============================================================
# OpenShift oc Top 50 Commands - One Complete Hands-on Flow
# Sample app: Python/Django app from GitHub using OpenShift S2I
# Tested style: OpenShift 4.x / CRC / OpenShift Local friendly
# ============================================================


# ------------------------------------------------------------
# Phase 1: Verify oc client and cluster access
# ------------------------------------------------------------

# 1. Show oc client and OpenShift server version
oc version

# 2. Show all available oc commands
oc help

# 3. Show help for a specific command
oc new-app --help

# 4. List API resources available in the cluster
oc api-resources

# 5. List API versions available in the cluster
oc api-versions

# 6. Explain a Kubernetes/OpenShift resource field
oc explain deployment.spec.replicas


# ------------------------------------------------------------
# Phase 2: Login and identity
# For CRC/OpenShift Local, get credentials using:
# crc console --credentials
# ------------------------------------------------------------

# 7. Log in to OpenShift cluster
oc login https://api.crc.testing:6443 -u developer -p developer

# 8. Show the currently logged-in user
oc whoami

# 9. Show current authentication/session information
oc auth whoami

# 10. Check whether current user can create projects
oc auth can-i create project

# 11. Show current kubeconfig context
oc config current-context

# 12. Show kubeconfig details
oc config view


# ------------------------------------------------------------
# Phase 3: Create and enter a project
# ------------------------------------------------------------

# 13. Create a new project and switch into it
oc new-project oc-top50-demo

# 14. Show current project
oc project

# 15. List all projects you can access
oc projects

# 16. Check whether current user can create pods in this project
oc auth can-i create pods

# 17. Show all resources in the empty project
oc get all


# ------------------------------------------------------------
# Phase 4: Deploy one sample application from GitHub source code
# ------------------------------------------------------------

# 18. Create application from GitHub source using Python 3.9 S2I builder
oc new-app python:3.9~https://github.com/openshift-instruqt/blog-django-py --name=blog

# 19. Show high-level application status
oc status

# 20. List all main resources created by new-app
oc get all

# 21. Watch pods while build and deployment happen
oc get pods --watch

# Press Ctrl+C after the pod becomes Running


# ------------------------------------------------------------
# Phase 5: Inspect build, deployment, pods, service
# ------------------------------------------------------------

# 22. List builds
oc get builds

# 23. List build configs
oc get buildconfig

# 24. Follow logs from the latest build
oc logs -f bc/blog

# 25. List deployments
oc get deployment

# 26. List replica sets
oc get replicaset

# 27. List pods with node and IP details
oc get pods -o wide

# 28. Save the first blog pod name into a shell variable
POD=$(oc get pods -l app=blog -o jsonpath='{.items[0].metadata.name}')

# 29. Print selected pod name
echo $POD

# 30. Describe the selected pod for troubleshooting details
oc describe pod/$POD

# 31. Show logs from the selected pod
oc logs pod/$POD

# 32. Follow live logs from the deployment
oc logs -f deployment/blog

# 33. List services
oc get service

# 34. Describe the blog service
oc describe service/blog

# 35. List endpoints behind the service
oc get endpoints blog


# ------------------------------------------------------------
# Phase 6: Expose the application with an OpenShift Route
# ------------------------------------------------------------

# 36. Expose the service as an OpenShift route
oc expose service/blog

# 37. List routes
oc get route

# 38. Show only the route hostname
oc get route blog -o jsonpath='{.spec.host}{"\n"}'

# 39. Test the route from your local terminal
curl -I http://$(oc get route blog -o jsonpath='{.spec.host}')


# ------------------------------------------------------------
# Phase 7: Debug and interact with the running app
# ------------------------------------------------------------

# 40. Execute a simple command inside the pod
oc exec pod/$POD -- pwd

# 41. List files inside the pod
oc exec pod/$POD -- ls -la

# 42. Show environment variables inside the pod
oc exec pod/$POD -- env

# 43. Open an interactive remote shell inside the pod
oc rsh pod/$POD

# Type exit to leave the remote shell:
# exit

# 44. Port-forward local port 8080 to the pod port 8080
oc port-forward pod/$POD 8080:8080

# Open another terminal and test:
# curl -I http://localhost:8080
# Press Ctrl+C to stop port-forward


# ------------------------------------------------------------
# Phase 8: Modify application configuration
# ------------------------------------------------------------

# 45. Add an environment variable to the deployment
oc set env deployment/blog APP_MODE=demo

# 46. Verify the environment variable was added
oc set env deployment/blog --list

# 47. Restart the deployment so changes are applied cleanly
oc rollout restart deployment/blog

# 48. Watch rollout status
oc rollout status deployment/blog

# 49. Scale the application to 2 replicas
oc scale deployment/blog --replicas=2

# 50. Verify pods after scaling
oc get pods -o wide


# ============================================================
# Optional cleanup after finishing the lab
# ============================================================

# Delete all app resources with label app=blog
oc delete all -l app=blog

# Delete the route if it still exists
oc delete route blog

# Delete the project
oc delete project oc-top50-demoCode language: PHP (php)

2. Developer command master table

This table covers the official OpenShift CLI developer command set from the Red Hat 4.22 reference. Red Hat describes this section as commands developers use to create, deploy, and manage applications. (Red Hat Documentation)

CommandWhy / When to UseExampleExpected Output Shape
oc annotateAdd/update/remove annotations on resourcesoc annotate pod/foo description='my frontend'pod/foo annotated
oc api-resourcesList supported API resourcesoc api-resources -o wideTable: NAME SHORTNAMES APIVERSION NAMESPACED KIND
oc api-versionsList supported API groups/versionsoc api-versionsLines like apps/v1, route.openshift.io/v1
oc applyApply declarative YAML/JSONoc apply -f app.yamldeployment.apps/web configured
oc apply edit-last-appliedEdit last-applied config annotationoc apply edit-last-applied deployment/webOpens editor
oc apply set-last-appliedSet last-applied config from fileoc apply set-last-applied -f app.yamldeployment.apps/web configured
oc apply view-last-appliedView last-applied configoc apply view-last-applied deployment/webYAML/JSON manifest
oc attachAttach to running container processoc attach pod/web -c appStreams process output
oc auth can-iCheck RBAC permissionsoc auth can-i create podsyes / no
oc auth reconcileReconcile RBAC objects from fileoc auth reconcile -f rbac.yamlRBAC objects reconciled
oc auth whoamiShow current auth/session infooc auth whoamiCurrent user/session details
oc autoscaleCreate/update HPAoc autoscale deployment/web --min=1 --max=5 --cpu-percent=80horizontalpodautoscaler.autoscaling/web autoscaled
oc cancel-buildCancel running/pending buildoc cancel-build bc/webbuild.build.openshift.io/web-1 cancelled
oc cluster-infoShow cluster endpointsoc cluster-infoAPI/control plane endpoint summary
oc cluster-info dumpDump cluster info for troubleshootingoc cluster-info dumpLarge diagnostic output/files
oc completionGenerate shell completionoc completion zshShell completion script
oc config current-contextShow active kubeconfig contextoc config current-contextContext name
oc config delete-clusterRemove cluster from kubeconfigoc config delete-cluster myclusterdeleted cluster mycluster
oc config delete-contextRemove context from kubeconfigoc config delete-context mycontextdeleted context mycontext
oc config delete-userRemove user from kubeconfigoc config delete-user developerdeleted user developer
oc config get-clustersList kubeconfig clustersoc config get-clustersCluster names
oc config get-contextsList kubeconfig contextsoc config get-contextsContext table
oc config get-usersList kubeconfig usersoc config get-usersUser names
oc config new-admin-kubeconfigCreate admin kubeconfig from certsoc config new-admin-kubeconfigKubeconfig YAML
oc config new-kubelet-bootstrap-kubeconfigCreate kubelet bootstrap kubeconfigoc config new-kubelet-bootstrap-kubeconfigKubeconfig YAML
oc config refresh-ca-bundleRefresh CA bundle in kubeconfigoc config refresh-ca-bundleUpdated kubeconfig
oc config rename-contextRename contextoc config rename-context old newContext renamed
oc config setSet raw kubeconfig propertyoc config set current-context mycontextProperty updated
oc config set-clusterSet cluster entryoc config set-cluster crc --server=https://api.crc.testing:6443Cluster configured
oc config set-contextSet context entryoc config set-context demo --namespace=demoContext configured
oc config set-credentialsSet user credentialsoc config set-credentials dev --token=<token>User configured
oc config unsetRemove kubeconfig propertyoc config unset users.dev.tokenProperty unset
oc config use-contextSwitch contextoc config use-context crcSwitched to context "crc"
oc config viewView kubeconfigoc config viewKubeconfig YAML
oc cpCopy files to/from podoc cp pod/web:/tmp/log.txt ./log.txtFile copied
oc createCreate resource from file/stdinoc create -f app.yamlresource/name created
oc create buildCreate build configoc create build docker --name=web --binarybuildconfig.build.openshift.io/web created
oc create clusterresourcequotaCreate cluster-wide quotaoc create clusterresourcequota team-quota --project-label-selector=team=aQuota created
oc create clusterroleCreate ClusterRoleoc create clusterrole pod-reader --verb=get,list --resource=podsClusterRole created
oc create clusterrolebindingBind ClusterRole cluster-wideoc create clusterrolebinding read-pods --clusterrole=pod-reader --user=aliceBinding created
oc create configmapCreate ConfigMapoc create configmap app-config --from-literal=ENV=devConfigMap created
oc create cronjobCreate CronJoboc create cronjob hello --image=busybox --schedule='*/5 * * * *' -- echo hiCronJob created
oc create deploymentCreate Deploymentoc create deployment web --image=nginxDeployment created
oc create deploymentconfigCreate OpenShift DeploymentConfigoc create deploymentconfig web --image=nginxDeploymentConfig created
oc create identityCreate identity objectoc create identity htpasswd:aliceIdentity created
oc create imagestreamCreate ImageStreamoc create imagestream nginxImageStream created
oc create imagestreamtagCreate ImageStreamTagoc create imagestreamtag nginx:latest --from-image=nginx:latestImageStreamTag created
oc create ingressCreate Ingressoc create ingress web --rule='web.example.com/*=web:80'Ingress created
oc create jobCreate Joboc create job pi --image=perl -- perl -Mbignum=bpi -wle 'print bpi(20)'Job created
oc create namespaceCreate namespaceoc create namespace demoNamespace created
oc create poddisruptionbudgetCreate PDBoc create poddisruptionbudget web-pdb --selector=app=web --min-available=1PDB created
oc create priorityclassCreate PriorityClassoc create priorityclass high --value=1000PriorityClass created
oc create quotaCreate ResourceQuotaoc create quota compute --hard=pods=10,cpu=4,memory=8GiQuota created
oc create roleCreate Roleoc create role pod-reader --verb=get,list --resource=podsRole created
oc create rolebindingBind Roleoc create rolebinding read-pods --role=pod-reader --user=aliceRoleBinding created
oc create route edgeCreate edge TLS routeoc create route edge web --service=webRoute created
oc create route passthroughCreate passthrough TLS routeoc create route passthrough web --service=webRoute created
oc create route reencryptCreate re-encrypt TLS routeoc create route reencrypt web --service=webRoute created
oc create secret docker-registryCreate registry pull secretoc create secret docker-registry regcred --docker-server=quay.io --docker-username=u --docker-password=pSecret created
oc create secret genericCreate generic secretoc create secret generic db --from-literal=password=secretSecret created
oc create secret tlsCreate TLS secretoc create secret tls web-tls --cert=tls.crt --key=tls.keySecret created
oc create service clusteripCreate ClusterIP Serviceoc create service clusterip web --tcp=8080:8080Service created
oc create service externalnameCreate ExternalName Serviceoc create service externalname ext --external-name=example.comService created
oc create service loadbalancerCreate LoadBalancer Serviceoc create service loadbalancer web --tcp=80:8080Service created
oc create service nodeportCreate NodePort Serviceoc create service nodeport web --tcp=80:8080Service created
oc create serviceaccountCreate ServiceAccountoc create serviceaccount builder-saServiceAccount created
oc create tokenRequest ServiceAccount tokenoc create token builder-saToken string
oc create userCreate User objectoc create user aliceUser created
oc create useridentitymappingMap user to identityoc create useridentitymapping htpasswd:alice aliceMapping created
oc debugDebug pod/node/resourceoc debug deployment/webDebug pod/session created
oc deleteDelete resourcesoc delete pod web-abc123pod "web-abc123" deleted
oc describeDetailed human-readable resource infooc describe pod web-abc123Events, labels, containers, conditions
oc diffPreview server-side changesoc diff -f app.yamlUnix diff output
oc editEdit live resource in editoroc edit deployment/webResource updated or unchanged
oc eventsShow eventsoc eventsEvent table
oc execRun command in containeroc exec deploy/web -- ls /tmpCommand output
oc explainExplain API fieldsoc explain deployment.spec.replicasField docs
oc exposeCreate Service or Route from existing objectoc expose deployment/web --port=8080Service created
oc extractExtract ConfigMap/Secret contentsoc extract secret/db --to=./secretsFiles written
oc getList/read resourcesoc get pods -o wideResource table
oc get-tokenStart OIDC/auth-code token flowoc get-token --client-id=client-id --issuer-url=test.issuer.urlToken/auth output
oc idleScale idlable resources to zerooc idle service/webResources idled
oc image appendAdd layers to imagesoc image append --from mysql:latest --to registry/image:latest layer.tar.gzImage pushed/written
oc image extractCopy files from image to filesystemoc image extract docker.io/library/busybox:latest --path /:/tmp/busyboxFiles extracted
oc image infoInspect image metadataoc image info quay.io/openshift/cli:latestImage metadata
oc image mirrorMirror images between registriesoc image mirror src/image:tag=dest/image:tagImage copied
oc import-imageImport image into ImageStreamoc import-image mystream --from=registry.io/repo/image:latest --confirmImageStreamTag imported
oc kustomizeBuild Kustomize outputoc kustomize ./overlays/devYAML output
oc labelAdd/update/remove labelsoc label pod/foo app=webpod/foo labeled
oc loginAuthenticate to clusteroc login https://api.crc.testing:6443 -u developer -p developerLogin successful
oc logoutEnd current sessionoc logoutLogged out
oc logsView container logsoc logs -f deployment/webLog stream
oc new-appCreate app from source/image/templateoc new-app python:3.9~https://github.com/openshift-instruqt/blog-django-py --name=blogBuildConfig/Deployment/Service created
oc new-buildCreate build configoc new-build python:3.9~https://github.com/user/repo --name=appBuildConfig created
oc new-projectCreate and switch projectoc new-project demoNow using project "demo"
oc observeWatch resources and react with commandoc observe pods -- echo '{name}'Repeated observed output
oc patchPatch resource fieldsoc patch deployment web -p '{"spec":{"replicas":3}}'Resource patched
oc pluginManage/view pluginsoc plugin listCompatible plugin list
oc plugin listList installed pluginsoc plugin listPlugin paths
oc policy add-role-to-userAdd role to user in projectoc policy add-role-to-user view aliceRole added
oc policy scc-reviewReview SCC admission for service accountsoc policy scc-review -f pod.yamlSCC review result
oc policy scc-subject-reviewReview SCC for user/SAoc policy scc-subject-review -f pod.yamlSCC subject review
oc port-forwardForward local port to pod/serviceoc port-forward pod/web 8080:8080Forwarding from 127.0.0.1:8080
oc processProcess templateoc process -f template.yaml -p NAME=demoYAML objects
oc projectSwitch/show current projectoc project demoNow using project "demo"
oc projectsList accessible projectsoc projectsProject list
oc proxyRun local API proxyoc proxy --port=8001Starting to serve on 127.0.0.1:8001
oc registry loginLog local image tools into OpenShift registryoc registry loginRegistry auth configured
oc replaceReplace resource from fileoc replace -f app.yamlResource replaced
oc rollbackRoll back DeploymentConfigoc rollback dc/webRollback created
oc rolloutManage rollout operationsoc rollout status deployment/webRollout status
oc rollout cancelCancel rolloutoc rollout cancel dc/webRollout cancelled
oc rollout historyView rollout historyoc rollout history deployment/webRevision table
oc rollout latestTrigger latest DeploymentConfig rolloutoc rollout latest dc/webRollout started
oc rollout pausePause rolloutoc rollout pause deployment/webDeployment paused
oc rollout restartRestart rolloutoc rollout restart deployment/webDeployment restarted
oc rollout resumeResume paused rolloutoc rollout resume deployment/webDeployment resumed
oc rollout retryRetry failed DeploymentConfig rolloutoc rollout retry dc/webRetry started
oc rollout statusWatch rolloutoc rollout status deployment/websuccessfully rolled out
oc rollout undoRoll back deployment revisionoc rollout undo deployment/webRolled back
oc rshRemote shell into podoc rsh pod/web-abc123Interactive shell
oc rsyncSync files with podoc rsync ./static pod/web:/opt/app/staticFiles synced
oc runRun pod/workload quicklyoc run test --image=busybox -- sleep 3600Pod created
oc scaleScale replicasoc scale deployment/web --replicas=3Deployment scaled
oc secrets linkLink secret to service accountoc secrets link default regcred --for=pullSecret linked
oc secrets unlinkUnlink secret from service accountoc secrets unlink default regcredSecret unlinked
oc set build-hookSet build hooksoc set build-hook bc/web --post-commit --command -- echo okBuildConfig updated
oc set build-secretSet build secretsoc set build-secret --source bc/web mysecretBuildConfig updated
oc set dataSet data in ConfigMap/Secretoc set data configmap/app KEY=valueConfigMap updated
oc set deployment-hookSet DeploymentConfig hooksoc set deployment-hook dc/web --pre -- echo preDeploymentConfig updated
oc set envSet env varsoc set env deployment/web ENV=devDeployment updated
oc set imageUpdate container imageoc set image deployment/web web=nginx:1.25Deployment updated
oc set image-lookupConfigure ImageStream local lookupoc set image-lookup nginxImage lookup updated
oc set probeSet liveness/readiness/startup probesoc set probe deployment/web --readiness --get-url=http://:8080/healthzDeployment updated
oc set resourcesSet CPU/memory requests/limitsoc set resources deployment/web --limits=cpu=500m,memory=512MiDeployment updated
oc set route-backendsSplit route trafficoc set route-backends web a=2 b=1Route updated
oc set selectorSet selector on resourceoc set selector service/web app=webService updated
oc set serviceaccountSet workload service accountoc set serviceaccount deployment web builder-saDeployment updated
oc set subjectUpdate RoleBinding/ClusterRoleBinding subjectsoc set subject rolebinding admin --user=aliceBinding updated
oc set triggersConfigure build/deployment triggersoc set triggers dc/web --manualTriggers updated
oc set volumesAdd/remove/list volumesoc set volume deployment/web --add --name=data --emptydirDeployment updated
oc start-buildStart OpenShift buildoc start-build bc/web --followBuild started + logs
oc statusSummarize project statusoc statusApp/service/route/build summary
oc tagTag images/ImageStreamsoc tag nginx:latest myproject/nginx:prodTag updated
oc versionShow client/server versionsoc versionClient + server version info
oc waitWait for condition/create/deleteoc wait --for=condition=Ready pod/busybox1 --timeout=60scondition met
oc whoamiShow current user/sessionoc whoamiUsername

The official reference confirms the image commands oc image append, extract, info, and mirror, and also shows the set serviceaccount, set subject, and set triggers commands that are easy to miss. (Red Hat Documentation)


3. Administrator command master table

Use these with care. Red Hat explicitly states the admin command reference requires cluster-admin or equivalent permissions. (Red Hat Documentation)

CommandWhy / When to UseExampleExpected Output Shape
oc adm build-chainShow build image dependenciesoc adm build-chain <image-stream>Dependency tree
oc adm catalog mirrorMirror Operator catalogoc adm catalog mirror quay.io/my/image:latest myregistry.comMirror mapping/output
oc adm certificate approveApprove CSRoc adm certificate approve csr-abcCSR approved
oc adm certificate denyDeny CSRoc adm certificate deny csr-abcCSR denied
oc adm copy-to-nodeCopy files to nodeoc adm copy-to-node node/worker-1 ./file /tmp/fileFile copied
oc adm cordonMark node unschedulableoc adm cordon worker-1node/worker-1 cordoned
oc adm create-bootstrap-project-templateGenerate bootstrap project templateoc adm create-bootstrap-project-template -o yamlTemplate YAML
oc adm create-error-templateGenerate error page templateoc adm create-error-template -o yamlTemplate YAML
oc adm create-login-templateGenerate login page templateoc adm create-login-template -o yamlTemplate YAML
oc adm create-provider-selection-templateGenerate provider selection templateoc adm create-provider-selection-template -o yamlTemplate YAML
oc adm drainEvict pods before maintenanceoc adm drain worker-1 --ignore-daemonsets --delete-emptydir-dataNode drained
oc adm groups add-usersAdd users to groupoc adm groups add-users devs alice bobUsers added
oc adm groups newCreate groupoc adm groups new devs alice bobGroup created
oc adm groups pruneRemove old external groupsoc adm groups prune --sync-config=config.yaml --confirmGroups pruned
oc adm groups remove-usersRemove users from groupoc adm groups remove-users devs aliceUser removed
oc adm groups syncSync groups from external provideroc adm groups sync --sync-config=config.yaml --confirmGroups synced
oc adm inspectCollect resource debug dataoc adm inspect ns/demoLocal inspect directory
oc adm migrate icspMigrate ImageContentSourcePolicyoc adm migrate icspMigration output
oc adm migrate template-instancesMigrate template instancesoc adm migrate template-instancesMigration output
oc adm must-gatherCollect cluster diagnosticsoc adm must-gathermust-gather.local.<rand> directory
oc adm new-projectAdmin-created project with optionsoc adm new-project myproject --node-selector='type=user-node'Project created
oc adm node-image createCreate ISO/PXE files for adding nodesoc adm node-image createISO/PXE assets created
oc adm node-image monitorMonitor new nodes being addedoc adm node-image monitor --ip-addresses 192.168.111.83Node add progress
oc adm node-logsView node logsoc adm node-logs worker-1Node log output
oc adm ocp-certificates monitor-certificatesMonitor OCP certificatesoc adm ocp-certificates monitor-certificatesCertificate status
oc adm ocp-certificates regenerate-leafRegenerate leaf certificatesoc adm ocp-certificates regenerate-leafCert regeneration output
oc adm ocp-certificates regenerate-machine-config-server-serving-certRegenerate MCS serving certoc adm ocp-certificates regenerate-machine-config-server-serving-certCert regenerated
oc adm ocp-certificates regenerate-top-levelRegenerate top-level certsoc adm ocp-certificates regenerate-top-levelCert regeneration output
oc adm ocp-certificates remove-old-trustRemove old trust bundlesoc adm ocp-certificates remove-old-trustOld trust removed
oc adm ocp-certificates update-ignition-ca-bundle-for-machine-config-serverUpdate ignition CA bundleoc adm ocp-certificates update-ignition-ca-bundle-for-machine-config-serverSecrets updated
oc adm policy add-cluster-role-to-groupGrant cluster role to groupoc adm policy add-cluster-role-to-group cluster-admin cluster-adminsRole added
oc adm policy add-cluster-role-to-userGrant cluster role to useroc adm policy add-cluster-role-to-user system:build-strategy-docker devuserRole added
oc adm policy add-role-to-userGrant project roleoc adm policy add-role-to-user view user1Role added
oc adm policy add-scc-to-groupGrant SCC to groupoc adm policy add-scc-to-group restricted group1SCC added
oc adm policy add-scc-to-userGrant SCC to user/SAoc adm policy add-scc-to-user privileged -z serviceaccount1SCC added
oc adm policy remove-cluster-role-from-groupRemove cluster role from groupoc adm policy remove-cluster-role-from-group cluster-admin cluster-adminsRole removed
oc adm policy remove-cluster-role-from-userRemove cluster role from useroc adm policy remove-cluster-role-from-user system:build-strategy-docker devuserRole removed
oc adm policy scc-reviewCheck which SA can create podoc adm policy scc-review -z sa1,sa2 -f pod.yamlSCC review
oc adm policy scc-subject-reviewCheck whether user/SA can create podoc adm policy scc-subject-review -f pod.yamlSCC subject review
oc adm prune buildsRemove old buildsoc adm prune builds --confirmBuilds pruned
oc adm prune deploymentsRemove old deploymentsoc adm prune deployments --confirmDeployments pruned
oc adm prune groupsRemove old groupsoc adm prune groups --confirmGroups pruned
oc adm prune imagesRemove unreferenced imagesoc adm prune images --keep-tag-revisions=3 --keep-younger-than=60m --confirmImages pruned
oc adm prune renderedmachineconfigsPrune rendered MachineConfigsoc adm prune renderedmachineconfigs --confirmMachineConfigs pruned
oc adm prune renderedmachineconfigs listList rendered MachineConfigsoc adm prune renderedmachineconfigs list --pool-name=workerMachineConfig list
oc adm reboot-machine-config-poolReboot MachineConfigPoolsoc adm reboot-machine-config-pool mcp/workerReboot initiated
oc adm release extractExtract release payload contentsoc adm release extract --git=DIRFiles extracted
oc adm release infoShow release infooc adm release infoRelease metadata
oc adm release mirrorMirror release payloadoc adm release mirror --from=<release> --to=<registry>Mirror output
oc adm restart-kubeletRestart kubelet on nodesoc adm restart-kubelet nodes/worker-1Kubelet restart requested
oc adm taintAdd/remove node taintsoc adm taint nodes foo dedicated=special-user:NoScheduleNode tainted
oc adm top imagesShow image usage statsoc adm top imagesUsage table
oc adm top imagestreamsShow ImageStream usage statsoc adm top imagestreamsUsage table
oc adm top nodeShow node CPU/memory usageoc adm top nodeNode metrics table
oc adm top persistentvolumeclaimsShow PVC usage statsoc adm top persistentvolumeclaims -APVC usage table
oc adm top podShow pod CPU/memory usageoc adm top pod --containersPod metrics table
oc adm uncordonMark node schedulable againoc adm uncordon worker-1node/worker-1 uncordoned
oc adm upgradeView/change cluster updateoc adm upgradeUpgrade status/available updates
oc adm verify-image-signatureVerify image signatureoc adm verify-image-signature sha256:<digest> --expected-identity=registry/image:v1Verification result
oc adm wait-for-node-rebootWait for node reboot completionoc adm wait-for-node-reboot nodes --allWait progress/completion
oc adm wait-for-stable-clusterWait for cluster operators to stabilizeoc adm wait-for-stable-clusterStable/timeout result

The admin table includes the newer/easy-to-miss entries such as node-image create, node-image monitor, prune renderedmachineconfigs, wait-for-node-reboot, and wait-for-stable-cluster, all visible in the current 4.22 admin reference. (Red Hat Documentation)


4. Command families by real-world use case

Login and identity

TaskCommand
Log inoc login <api-server> -u <user> -p <password>
Show useroc whoami
Show auth detailsoc auth whoami
Check permissionoc auth can-i create pods
Log outoc logout
View configoc config view
Switch contextoc config use-context <context>

Projects and namespaces

TaskCommand
Create projectoc new-project demo
Switch projectoc project demo
List projectsoc projects
Create namespaceoc create namespace demo
Admin create projectoc adm new-project demo

Application deployment

TaskCommand
Deploy from image/sourceoc new-app
Create deploymentoc create deployment
Create serviceoc expose deployment/web --port=8080
Create routeoc expose service/web
Show app summaryoc status
Watch podsoc get pods --watch

Build and image workflow

TaskCommand
Create buildoc new-build
Start buildoc start-build bc/web --follow
Cancel buildoc cancel-build bc/web
Import imageoc import-image
Tag imageoc tag
Inspect imageoc image info
Mirror imageoc image mirror
Extract image filesoc image extract

Troubleshooting

TaskCommand
Describe resourceoc describe pod/<pod>
Logsoc logs -f deployment/web
Exec commandoc exec deploy/web -- env
Remote shelloc rsh pod/<pod>
Debug pod/deployment/nodeoc debug
Eventsoc events
Cluster info dumpoc cluster-info dump
Must-gatheroc adm must-gather

Scaling and rollout

TaskCommand
Scale manuallyoc scale deployment/web --replicas=3
Autoscaleoc autoscale deployment/web --min=1 --max=5 --cpu-percent=80
Restart deploymentoc rollout restart deployment/web
Watch rolloutoc rollout status deployment/web
Undo rolloutoc rollout undo deployment/web
Pause/resume rolloutoc rollout pause deployment/web / oc rollout resume deployment/web

Config, secrets, and environment

TaskCommand
Create ConfigMapoc create configmap
Create Secretoc create secret generic
Create TLS Secretoc create secret tls
Set environment varsoc set env
Link pull secretoc secrets link
Extract secret/configmapoc extract

RBAC and security

TaskCommand
Create Roleoc create role
Create RoleBindingoc create rolebinding
Check permissionoc auth can-i
Add role to useroc policy add-role-to-user
Admin add cluster roleoc adm policy add-cluster-role-to-user
SCC reviewoc adm policy scc-review
Add SCCoc adm policy add-scc-to-user

Node and cluster administration

TaskCommand
Cordon nodeoc adm cordon
Drain nodeoc adm drain
Uncordon nodeoc adm uncordon
Taint nodeoc adm taint
Node metricsoc adm top node
Pod metricsoc adm top pod
Cluster upgrade statusoc adm upgrade
Wait for stable clusteroc adm wait-for-stable-cluster

5. Expected output patterns

Use these as mental models.

Command TypeExampleTypical Output
Createoc create configmap appconfigmap/app created
Applyoc apply -f app.yamlcreated, configured, or unchanged
Deleteoc delete pod webpod "web" deleted
Getoc get podsTable with NAME READY STATUS RESTARTS AGE
Describeoc describe pod webLong human-readable detail
Logsoc logs -f deployment/webApplication log stream
Patchoc patch deployment web -p ...deployment.apps/web patched
Setoc set env deployment/web A=Bdeployment.apps/web updated
Rollout statusoc rollout status deployment/webdeployment "web" successfully rolled out
Waitoc wait --for=condition=Ready pod/webpod/web condition met
Auth checkoc auth can-i get podsyes or no
Admin metricsoc adm top podCPU/memory usage table

6. Recommended learning order for labs

Use this sequence for students:

Lab StageCommands
Access clusteroc login, oc whoami, oc version
Explore APIsoc api-resources, oc api-versions, oc explain
Work with projectsoc new-project, oc project, oc projects
Deploy appoc new-app, oc status, oc get all
Expose appoc expose, oc get route
Debug appoc logs, oc describe, oc events, oc exec, oc rsh
Modify appoc set env, oc set image, oc scale, oc rollout status
Config/secretsoc create configmap, oc create secret, oc set env
Builds/imagesoc new-build, oc start-build, oc import-image, oc tag
RBACoc auth can-i, oc create role, oc create rolebinding
Cleanupoc delete, oc delete all -l app=<app>
Adminoc adm top, oc adm must-gather, oc adm cordon/drain/uncordon

7. My safest โ€œdo not hallucinateโ€ rule for your course material

For every lab page, include this box:

# Verify exact syntax on your installed client
oc <command> --help

# Verify available resources on your cluster
oc api-resources

# Verify your permissions
oc auth can-i <verb> <resource>
Code language: PHP (php)

This protects the tutorial from version drift, Operator-installed APIs, and permission differences between CRC/OpenShift Local, Developer Sandbox, and full production OpenShift.

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services โ€” all in one place.

Explore Hospitals
Iโ€™m a DevOps/SRE/DevSecOps/Cloud Expert passionate about sharing knowledge and experiences. I have worked at <a href="https://www.cotocus.com/">Cotocus</a>. I share tech blog at <a href="https://www.devopsschool.com/">DevOps School</a>, travel stories at <a href="https://www.holidaylandmark.com/">Holiday Landmark</a>, stock market tips at <a href="https://www.stocksmantra.in/">Stocks Mantra</a>, health and fitness guidance at <a href="https://www.mymedicplus.com/">My Medic Plus</a>, product reviews at <a href="https://www.truereviewnow.com/">TrueReviewNow</a> , and SEO strategies at <a href="https://www.wizbrand.com/">Wizbrand.</a> Do you want to learn <a href="https://www.quantumuting.com/">Quantum Computing</a>? <strong>Please find my social handles as below;</strong> <a href="https://www.rajeshkumar.xyz/">Rajesh Kumar Personal Website</a> <a href="https://www.youtube.com/TheDevOpsSchool">Rajesh Kumar at YOUTUBE</a> <a href="https://www.instagram.com/rajeshkumarin">Rajesh Kumar at INSTAGRAM</a> <a href="https://x.com/RajeshKumarIn">Rajesh Kumar at X</a> <a href="https://www.facebook.com/RajeshKumarLog">Rajesh Kumar at FACEBOOK</a> <a href="https://www.linkedin.com/in/rajeshkumarin/">Rajesh Kumar at LINKEDIN</a> <a href="https://www.wizbrand.com/rajeshkumar">Rajesh Kumar at WIZBRAND</a> <a href="https://www.rajeshkumar.xyz/dailylogs">Rajesh Kumar DailyLogs</a>

Related Posts

Best DevOps Tools in 2024

hereโ€™s a clear, structured breakdown of the Best DevOps Tools (grouped by categories), so you can use it for learning, training, or posts. ๐Ÿš€ Best DevOps Tools…

Read More

OpenShift Tutorial โ€“ Deploy and Access Your First Applications using OpenShift Local

How to install oc? OpenShift: How to Install OpenShift CLI oc How to login? Login to the Openshift using Web Console and CLI using oc Copy the admin…

Read More

OpenShift Lab 14: Setting Up and Using OpenShift Serverless Functions on OpenShift Local

Lab Objective In this lab, you will install and use OpenShift Serverless Functions on OpenShift Local. You will create a simple Node.js serverless function, deploy it to…

Read More

OpenShift Lab 13: Deploy a Java Spring Boot Application with MySQL Using the OpenShift Web Console

Lab Objective In this lab, you will deploy a Java Spring Boot application on OpenShift using the OpenShift web console. You will deploy two components: The Java…

Read More

OpenShift Lab 12: Deploy an Application from an Existing Container Image Using the OpenShift Web Console

Lab Objective In this lab, you will deploy an application on OpenShift from an existing container image. This lab is different from building an application from source…

Read More

OpenShift: How to Install OpenShift CLIย oc

Option – 1 – REDHAT Websites URL – https://access.redhat.com/downloads/content/290/ver=4.18/rhel—9/4.18.11/x86_64/product-software Option – 2 – OKD Websites The OKD (Origin Community Distribution of Kubernetes for OpenShift) is the open-source…

Read More
Subscribe
Notify of
guest
1 Comment
Newest
Oldest Most Voted
Skylar Bennett
Skylar Bennett
18 days ago

The article provides a useful collection of commonly used oc commands, but it could be strengthened by covering how these commands fit into day-to-day operational workflows. In production environments, engineers often rely on scripting, aliases, and service accounts to automate repetitive tasks and reduce manual errors. Including examples of troubleshooting techniques, auditing changes, and safely executing administrative commands across multiple clusters would make the guide more valuable for teams managing OpenShift at scale.

1
0
Would love your thoughts, please comment.x
()
x