Member-only story

openshift command line view

Dheeraj kumar
3 min readNov 2, 2020

Openshift Login and Configuration

#login with a user
oc login https://192.168.99.100:6443 -u developer -p developer
oc login --token=<token> --server=https://192.168.33.10:6443
#login as system admin
oc login -u system:admin
#User Information
oc whoami
oc whoami -t -> get token
#View your configuration
oc config view

Basic Commands

# list all project
oc projects
# using project
oc project <myproject>
#Use specific template
oc new-app https://github.com/name/project --template=<template>

#New app from a different branch
oc new-app --name=node-dev https://github.com/name/project.git#branchname

#Create objects from a file:
oc create -f myobject.yml -n <myproject>
oc process -f myobject.yml | oc create -f -
#Create or merge objects from file
oc apply -f myobject.yaml -n <myproject>

#Update existing object
oc patch svc mysvc --type merge --patch '{"spec":{"ports":[{"port": 8080, "targetPort": 5000 }]}}'

#Monitor Pod status
watch oc get pods

#show labels
oc get pods --show-labels

#Gather information on a project's pod deployment with node information
$ oc get pods -o wide

#Hide inactive Pods
oc get pods --show-all=false

#Display all resources
oc get all,secret,configmap
oc get dc -> to get all deployment config
oc get svc -> to get all services
oc get bc…

--

--

Dheeraj kumar
Dheeraj kumar

Written by Dheeraj kumar

A DevOps/MLOps/GitOps/SecOps who is passionate about Autom@tion.

No responses yet