OpenShift

OpenShift Cheatsheet #

OpenShift is a Kubernetes-based platform that provides a range of tools and services to help developers and IT organizations build, deploy, and manage applications. It offers advanced features like automated updates, integrated CI/CD, and robust security.

Basic Commands #

Command/OptionExampleDescription
oc loginoc login <server>Log in to an OpenShift server
oc new-projectoc new-project <project_name>Create a new project
oc projectoc project <project_name>Switch to a different project
oc getoc get podsList resources (e.g., pods, services, deployments)
oc describeoc describe pod <pod_name>Show detailed information about a resource
oc deleteoc delete pod <pod_name>Delete a resource

Creating and Managing Applications #

Command/OptionExampleDescription
oc new-appoc new-app <source_url>Create a new application from source code, template, or image
oc start-buildoc start-build <build_name>Start a new build for an application
oc get buildsoc get buildsList all builds
oc get buildconfigoc get buildconfigList all build configurations
oc logs -f build/<build_name>oc logs -f build/<build_name>Follow logs for a build

Deployment Management #

Command/OptionExampleDescription
oc rollout statusoc rollout status deployment/<deployment_name>Show the rollout status of a deployment
oc rollout undooc rollout undo deployment/<deployment_name>Undo a deployment
oc scaleoc scale --replicas=3 deployment/<deployment_name>Scale a deployment
oc set imageoc set image deployment/<deployment_name> <container_name>=<image>Update the image for a deployment

Services and Networking #

Command/OptionExampleDescription
oc exposeoc expose deployment/<deployment_name> --port=<port>Expose a deployment as a service
oc get servicesoc get servicesList all services
oc describe service <service_name>oc describe service <service_name>Show detailed information about a service
oc get routesoc get routesList all routes
oc create routeoc create route edge --service=<service_name>Create a new route to a service

Storage Management #

Command/OptionExampleDescription
oc get pvcoc get pvcList all persistent volume claims (PVCs)
oc describe pvc <pvc_name>oc describe pvc <pvc_name>Show detailed information about a PVC
oc create pvcoc create -f <pvc.yaml>Create a PVC from a YAML file
oc delete pvc <pvc_name>oc delete pvc <pvc_name>Delete a PVC

Security and Access Control #

Command/OptionExampleDescription
oc get saoc get saList all service accounts
oc describe sa <sa_name>oc describe sa <sa_name>Show detailed information about a service account
oc create sa <sa_name>oc create sa <sa_name>Create a new service account
oc policy add-role-to-useroc policy add-role-to-user <role> <user>Add a role to a user
oc policy remove-role-from-useroc policy remove-role-from-user <role> <user>Remove a role from a user

Monitoring and Logging #

Command/OptionExampleDescription
oc logsoc logs <pod_name>View logs for a pod
oc logs -f <pod_name>oc logs -f <pod_name>Follow logs for a pod
oc get eventsoc get eventsList all events in the cluster
oc top podoc top podShow resource usage for pods

This cheatsheet covers essential OpenShift commands for managing applications, deployments, services, storage, security, and monitoring. OpenShift extends Kubernetes with additional features and tools, making it a powerful platform for container orchestration and application lifecycle management.

OpenShift

Explore our comprehensive cheatsheets to enhance your knowledge and efficiency. Each cheatsheet provides detailed command options, examples, and descriptions to help you master various tools and technologies.