Skip to content

Instantly share code, notes, and snippets.

@AasSuhendar
Last active July 8, 2020 09:24
Show Gist options
  • Save AasSuhendar/9d86ade172cf51d825d11f120c67a271 to your computer and use it in GitHub Desktop.
Save AasSuhendar/9d86ade172cf51d825d11f120c67a271 to your computer and use it in GitHub Desktop.
Daily Commands on OpenShift

Daily Commands on OpenShift

Client

Initial Client Setup

oc login [url of console openshift]
Authentication required for https://console.example.id:443 (openshift)
Username: admin
Password:

Basic Node

Get List of Node

oc get node
NAME                STATUS                     AGE       VERSION
node1.example.id    Ready                      1y        v1.7.6+a08f5eeb62
node2.example.id    Ready                      1y        v1.7.6+a08f5eeb62

Describe of Node

oc describe node node1.example.id 

Basic Project

Get List of Project

oc get project

Describe of Project

oc describe project [name project]

Switch context to some project

oc project [name project]

Basic Deploymentconfig

Get list of DC

oc get dc
oc get dc -o wide
oc get dc -n [name project]

Describe of some DC

oc describe dc [name dc]

Basic Pods

Get list of Pods

oc get pod
oc get pod -o wide
oc get pod -n [name project]

Describe of some Pod

oc describe pod [name pod]

Basic Service

Get list of Service

oc get svc
oc get svc -o wide
oc get svc -n [name project]

Describe of some Service

oc describe svc [name service]

Cluster Admin

Basic Node

Get Stats Top Node

oc adm top node
oc adm top node --selector [selector=value]

Mark Node Unschedulable

oc adm cordon [name node]

Mark Node schedulable

oc adm uncordon [name node]

Evacuates all pod and Drain node in preparation for maintenance

oc adm drain [name node] --force --delete-local-data --grace-period=0

Add clusterrole to user

oc adm policy add-cluster-role-to-user [role] [user name]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment