Openshift Commands

You might also like

Download as xlsx, pdf, or txt
Download as xlsx, pdf, or txt
You are on page 1of 2

Command

oc get clusterversion

oc describe clusterversion

oc get clusteroperators

oc adm node-logs -u crio my-node-name

oc adm node-logs -u kubelet my-node-name

oc adm node-logs my-node-name

oc debug node/my-node-name
...output omitted...
sh-4.2# chroot /host
sh-4.2# systemctl is-active kubelet
active

oc logs my-pod-name

oc logs my-pod-name -c my-container-name

oc debug deployment/my-deployment-name --as-root


Description

Run oc get clusterversion to retrieve the cluster version. The output lists the version, including minor
releases, the cluster uptime for a given version, and the overall status of the cluster

Run oc describe clusterversion to obtain more detailed information about the cluster status.

Run oc get clusteroperators to retrieve the list of all cluster operators

An OpenShift node based on Red Hat Enterprise Linux CoreOS runs very few local services that would
require direct access to a node to inspect their status. Most of the system services in
Red Hat Enterprise Linux CoreOS run as containers. The main exceptions are the CRI-O container engine
and the Kubelet, which are Systemd units. To view these logs, use the oc adm node-logs command as
shown in the following examples:

Most of the infrastructure components of OpenShift are containers inside pods; you can view their logs
the same way you view logs for any end-user application. Some of these containers are created by the
Kubelet, and thus invisible to most distributions of Kubernetes, but OpenShift cluster operators create
pod resources for them

You can also display all journal logs of a node:

The oc debug node command provides a way to open a shell prompt in any node of your cluster. That
prompt comes from a special-purpose tools container that mounts the node root file system at the
/host folder, and allows you to inspect any files from the node. To run local commands directly from
the node, while in a oc debug node session, you must start a chroot shell in the /host folder. Then you
can inspect the local file systems of the node, the status of its systemd services, and perform other
tasks that would otherwise require a SSH session. The following is an example oc debug node session:

A container that is running, even for a very short time, generates logs. These logs are not discarded
when the container terminates. The oc logs command displays the logs from any container inside a
pod. If the pod contains a single container, then the oc logs command only requires the name of the
pod

If the pod contains multiple containers, then the oc logs command requires the -c option.

A common scenario is creating a pod from a deployment, but running as the root user and thus proving
that the deployment references a container image that was not designed to run under the default
security policies of OpenShift:

You might also like