Catalog / OpenShift Cheat Sheet
OpenShift Cheat Sheet
A comprehensive cheat sheet covering essential OpenShift commands, concepts, and configurations for developers and operators.
Core Concepts & Commands
Basic Concepts
Project (Namespace): A logical grouping of resources, like a Kubernetes namespace. |
Common `oc` Commands
|
Log in to the OpenShift cluster. |
|
Create a new project (namespace). |
|
Switch to a specific project. |
|
List all pods in the current project. |
|
Create resources from a YAML file. |
|
Apply changes to resources defined in a YAML file. |
Resource Management
|
Get detailed information about a resource. |
|
Delete a resource. |
|
Edit a resource directly. |
|
View the logs of a pod. |
|
Execute a command inside a pod. Example: |
Deployments and Services
DeploymentConfig Basics
DeploymentConfigs manage application deployments. They define the desired state (number of replicas, container image, etc.) and automatically roll out updates. Use |
Example creating DeploymentConfig from image:
|
Service Management
|
Create a service to expose a DeploymentConfig. |
|
List services in the current project. |
|
Get details about a service. |
Scaling Applications
|
Scale the number of replicas for a DeploymentConfig. |
|
Configure autoscaling for a DeploymentConfig. |
Rolling Updates
OpenShift supports rolling updates to minimize downtime during deployments. When you update a DeploymentConfig, OpenShift automatically updates the application instances without interrupting service. |
To trigger a new deployment after changing the DeploymentConfig, use:
|
Routes and Networking
Route Configuration
Routes expose services to external traffic. They define the hostnames and paths that external clients use to access your applications. Use
|
Route Management Commands
|
List routes in the current project. |
|
Get details about a specific route. |
|
Delete a route. |
Securing Routes with TLS
You can secure routes using TLS certificates. OpenShift supports edge, passthrough, and re-encrypt TLS termination. To configure TLS, you’ll need to create a secret containing your TLS certificate and key, and then reference that secret in your route definition. |
Example of creating secret:
|
Builds and Image Streams
Build Concepts
Builds transform source code into runnable container images. OpenShift supports different build strategies, including Docker, Source-to-Image (S2I), and custom builds. BuildConfigs define how builds are executed. |
Image Streams
Image Streams manage container image tags and provide a level of indirection between deployments and the underlying images. This allows you to update images without modifying your deployment configurations. When a new image is pushed to the registry, OpenShift can automatically trigger new deployments based on the updated Image Stream tags. |
Common Build Commands
|
Create a new build configuration from a Git repository (S2I). |
|
Start a build. |
|
List builds in the current project. |
|
View the logs of a build. |
Working with Image Streams
|
Import an image from a registry into an Image Stream. |
|
List Image Streams in the current project. |
|
Get details about an Image Stream. |