Mustafa CavusogluMC

Command Palette

Search for a command to run...

AboutExperiencesProjects
Linux3Docker7Git4Kubernetes7Network2uv1Miniconda1OpenShift4
Back to Home
OpenShift

Essential OpenShift CLI commands for cluster and project management

ocprojectsloginclusterbasic

OpenShift Basics

Essential OpenShift CLI commands for everyday operations.

Login and Connection

# Login to OpenShift cluster
oc login https://api.cluster.example.com:6443

# Login with token
oc login --token=sha256~xxx --server=https://api.cluster.example.com:6443

# Login with username and password
oc login -u developer -p developer

# Check current user
oc whoami

# Show current login details
oc whoami --show-server
oc whoami --show-token

# Logout
oc logout

Project Management

# List projects
oc get projects

# Create a new project
oc new-project my-project

# Switch to a project
oc project my-project

# Show current project
oc project

# Delete a project
oc delete project my-project

# Describe a project
oc describe project my-project

Basic Operations

# Get resources
oc get all
oc get pods
oc get deployments
oc get services
oc get routes

# Get with details
oc get pods -o wide
oc get pods -o yaml

# Describe a resource
oc describe pod my-pod
oc describe deployment my-deployment

# View logs
oc logs my-pod
oc logs my-pod -f
oc logs my-pod -c container-name

# Execute command in pod
oc exec my-pod -- command
oc exec -it my-pod -- bash

# Port forward
oc port-forward my-pod 8080:80

Help and Info

# General help
oc --help

# Command specific help
oc get --help
oc create --help

# Show cluster info
oc cluster-info

# Show API resources
oc api-resources
oc api-resources --api-group=apps