0% found this document useful (0 votes)
48 views10 pages

OpenShift CLI Essential Commands and Examples

Uploaded by

yosiz0
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views10 pages

OpenShift CLI Essential Commands and Examples

Uploaded by

yosiz0
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 10

OpenShift CLI: Essential

Commands and Examples

Welcome to our comprehensive guide on OpenShift CLI


commands. We'll explore key 'oc' commands, providing
practical examples to enhance your OpenShift expertise.

YZ
by Yossi Z
Introduction to OpenShift
CLI (oc)
Command Line Versatile
Interface Functionality
OpenShift CLI (oc) is a It enables developers
powerful tool for and administrators to
managing OpenShift interact with OpenShift
resources from the clusters efficiently.
terminal.

Cross-Platform Support
Available for Windows, macOS, and Linux, ensuring broad
accessibility.
Exploring the oc Command Structure
Basic Syntax
oc [command] [type] [options]

Common Commands
get, create, delete, describe, edit

Resource Types
pods, services, deployments, routes

Options
-n (namespace), -o (output format), --all-namespaces
Interacting with OpenShift Projects and
Resources
Project Management Resource Retrieval

oc new-project myproject oc get pods

oc project myproject oc get services


Deploying Applications
Using oc new-app

1 Create from Git


oc new-app https://github.com/sclorg/nodejs-ex

2 Specify Image
oc new-app
centos/ruby-25-centos7~https://github.com/sclorg/ru
by-ex

3 Use Template
oc new-app --template=mysql-persistent
Managing Application Builds with oc start-
build
Start New Build Build from Dockerfile Follow Build Logs
oc start-build myapp oc start-build myapp --from- oc start-build myapp --follow
dockerfile=./Dockerfile
Scaling and Managing Application
Pods with oc scale

Scale Up
oc scale deployment myapp --replicas=5

Scale Down
oc scale deployment myapp --replicas=2

Autoscale
oc autoscale deployment myapp --min=2 --max=10 --cpu-percent=80
Monitoring and Troubleshooting with oc logs
and oc describe
View Logs Describe Resources

oc logs pod/myapp-1-xyz123 oc describe pod myapp-1-xyz123

oc logs -f deployment/myapp oc describe service myapp


Advanced Commands: oc
edit, oc annotate, oc label

1 Edit Resources 2 Add Annotations


oc edit deployment myapp
oc annotate service
myapp
nginx.ingress.kubernet
es.io/proxy-body-

Apply Labels size=50m


3
oc label pods my-pod tier=frontend
Automating Tasks with oc process and oc
apply

Define Template
1

2 Process Template

3 Apply Configuration

Example: oc process -f template.yaml | oc apply -f -

You might also like