Search This Blog

Thursday, 24 March 2022

OC Commands

 

OC Commands


# Login Commands

source /usr/local/etc/ocp4.config 

oc login -u kubeadmin -p ${RHT_OCP4_KUBEADM_PASSWD}  https://api.ocp4.example.com:6443 

# If Auth is configured then you can directly login with that account

oc login -u USER_NAME -p PASSWORD https://api.ocp4.example.com:6443

oc whoami

oc whoami -t     # To get token

# Cluster Commands

oc get clusterversion

oc describe clusterversion

oc get clusteroperators

# Node Commands

oc get nodes

oc adm top node

oc describe node master01

# Project Commands

oc get project  # To get projects 

oc project <PROJECT_NAME> # To connect to a project

oc project openshift-image-registry 

oc status # To check the status of the project

oc get events # To list all events from the connected project

oc get all # To list all about project

# Pod Commands

oc get pod -n <PROJECT_NAME>  # To list pods from specific project

oc get project  # To get projects 

oc get pod -n openshift-image-registry

oc get pod -A    # To list all pods from all projects

oc logs --tail <NO_LOGS_ToDisplay> <PROJECT_NAME> <POD_NAME>

oc logs --tail 3 -n openshift-image-registry  cluster-image-registry-operator-xx

oc logs <POD_NAME> -c <CONTAINER_NAME> # To get logs from container

oc get pod --loglevel 6

oc get pod --loglevel 10

# To get Node & it's services logs 

oc adm node-logs --tail <NO_LOGS_ToDisplay> -u kubelet <NODE_NAME>

oc adm node-logs --tail 1 -u kubelet master01

oc adm node-logs -u crio master01

oc adm node-logs master01

# To start shell session to the node

oc debug node/<NODE_NAME>

oc debug node/master01

chroot /host #To change file system to the node

# To check the services status which are running on host 

systemctl status kubelet

 systemctl status cri-o

crictl ps --name openvswitch # To check openvswitch pod running status


# PODMAN Commands

podman login registry.redhat.io # To login to redhat registry

# SKOPEO Commands

skoppeo inspect <IMAGE_URL>

skoppeo inspect docker://registry.redhat.io/rhel8/postgresql-13:1

# Deployment Commands

oc get deployment

oc edit deployment/<DEPLOYMENT_NAME>

oc edit deployment/psql    # To edit deployment configuration yaml file 

oc debug deployment/my-deployment-name --as-root # To create a test debug deployment pod to troubleshoot the issue

oc rsh POD_NAME # Opens a shell inside a pod to run shell commands interactively and non-interactively. 

oc cp /local/path POD_NAME:/container/path # Copies local files to a location inside a pod. 

oc port-forward POD_NAME local-port:remote-port # Creates a TCP tunnel from local-port on your workstation to local-port on the pod


Ansible_Notes

   ansible -i inventory.ini -m ping all   # inventory.ini it will ping to the hosts which are in inventory # ansible -i inventory.ini -m pin...