Red Hat OpenShift Cheatsheet

Command Overview

Login/User Management

# Authenticate to an openshift cluster
oc login
# End the current session
oc logout
# Show the current user context
oc whoami

Deployments

Scaling

Scale up/down an Openshift application using the oc CLI tool:

# Scale the deployment
oc scale deployment <APPLICATION> --replicas=<NUMBER_OF_REPLICAS>
# Verify the scaling
oc get deployment -l app=<APPLICATION>

Storage

Ephemeral storage

Ephemeral storage is the storage that is available on the node that the pod is running on (primairy partition). It will be lost if the pod is restarted or moved to another node.

Root

  • Partition with kubelet root directory (shared between user pods, OS and Kubernetes system daemons)
    • /var/lib/kubelet
    • /var/log/

Persistent storage

Change the reclaim policy for a persistent volume:

# List the persistent volumes 
oc get pv
# Choose a persistent volumes and change its reclaim policy
oc patch pv <PV-NAME> -p '{"spec":{"persistentVolumeReclaimPolicy":"<Retain|Delete>"}}'
# Verify the change
oc get pv <PV-NAME> -o yaml | grep reclaimPolicy