OpenShift

Learning resources

Tools

OpenShit support

Misc

Security

Most common operations

Most recurring operations run using the OpenShift CLI tool: oc

Login to OpenShift using the CLI


oc login https://openshift:4443 --token=token_id

Choose project


oc project project_name

List pods


oc get pods

Search a given pod from the list of running Pods


oc get pods |grep pod_name

List containers in a pod


oc describe pod pod_name -n project_name |grep -A 2 Containers

Delete a pod


oc delete pod pod_name -n project_name --grace-period=0

Monitoring pod restart


watch -n 1 'oc get pods |grep pod_name'

List existing deployments in this project


oc get dc

List details of current and past deployments of a given microservice


oc rollout history dc/pod_name

oc rollout history dc/pod_name --revision=44

Scale down pods


oc scale dc pod_name --replicas=0

Scale up pods


oc scale dc pod_name --replicas=4

Get pod's log


oc logs pod_name


Get pod's metrics


oc describe PodMetrics pod_name

List existing horizontal pod scalers settings


oc get hpa -n project_name

Delete horizontal pod scalers settings for a given Pod


oc delete hpa/pod_name -n project_name


Get pod's log file from a given timestamp

Simple option. From one hour ago:


oc logs --since=1h pod_name

The option --since-time takes a date value following RFC3339 format.

RFC3339:


date --rfc-3339=seconds
date --rfc-3339=seconds | sed 's/ /T/'


oc logs --since-time='YYYY-MM-DDTHH:MM:SS-04:00' pod_name -n project_name


List defined routes


project_name='project_name'

oc project $project_name

oc get routes -n $project_name |grep -v NAME | awk '{ if ($5 ~ /edge/) print "https://"$2; else print "http://"$2 }'

Back to top

Index