This documentation is for a release that is no longer maintained
See documentation for the latest supported version 3 or the latest supported version 4.1.2. Viewing pods
As an administrator, you can view the pods in your cluster and to determine the health of those pods and the cluster as a whole.
1.2.1. About pods 复制链接链接已复制到粘贴板!
OpenShift Container Platform leverages the Kubernetes concept of a pod, which is one or more containers deployed together on one host, and the smallest compute unit that can be defined, deployed, and managed. Pods are the rough equivalent of a machine instance (physical or virtual) to a container.
You can view a list of pods associated with a specific project or view usage statistics about pods.
1.2.2. Viewing pods in a project 复制链接链接已复制到粘贴板!
You can view a list of pods associated with the current project, including the number of replica, the current status, number or restarts and the age of the pod.
Procedure
To view the pods in a project:
Change to the project:
oc project <project-name>
$ oc project <project-name>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Run the following command:
oc get pods
$ oc get pods
Copy to Clipboard Copied! Toggle word wrap Toggle overflow For example:
oc get pods -n openshift-console
$ oc get pods -n openshift-console
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
NAME READY STATUS RESTARTS AGE console-698d866b78-bnshf 1/1 Running 2 165m console-698d866b78-m87pm 1/1 Running 2 165m
NAME READY STATUS RESTARTS AGE console-698d866b78-bnshf 1/1 Running 2 165m console-698d866b78-m87pm 1/1 Running 2 165m
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add the
-o wide
flags to view the pod IP address and the node where the pod is located.oc get pods -o wide
$ oc get pods -o wide
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE console-698d866b78-bnshf 1/1 Running 2 166m 10.128.0.24 ip-10-0-152-71.ec2.internal <none> console-698d866b78-m87pm 1/1 Running 2 166m 10.129.0.23 ip-10-0-173-237.ec2.internal <none>
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE console-698d866b78-bnshf 1/1 Running 2 166m 10.128.0.24 ip-10-0-152-71.ec2.internal <none> console-698d866b78-m87pm 1/1 Running 2 166m 10.129.0.23 ip-10-0-173-237.ec2.internal <none>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
1.2.3. Viewing pod usage statistics 复制链接链接已复制到粘贴板!
You can display usage statistics about pods, which provide the runtime environments for containers. These usage statistics include CPU, memory, and storage consumption.
Prerequisites
-
You must have
cluster-reader
permission to view the usage statistics. - Metrics must be installed to view the usage statistics.
Procedure
To view the usage statistics:
Run the following command:
oc adm top pods
$ oc adm top pods
Copy to Clipboard Copied! Toggle word wrap Toggle overflow For example:
oc adm top pods -n openshift-console
$ oc adm top pods -n openshift-console
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
NAME CPU(cores) MEMORY(bytes) console-7f58c69899-q8c8k 0m 22Mi console-7f58c69899-xhbgg 0m 25Mi downloads-594fcccf94-bcxk8 3m 18Mi downloads-594fcccf94-kv4p6 2m 15Mi
NAME CPU(cores) MEMORY(bytes) console-7f58c69899-q8c8k 0m 22Mi console-7f58c69899-xhbgg 0m 25Mi downloads-594fcccf94-bcxk8 3m 18Mi downloads-594fcccf94-kv4p6 2m 15Mi
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Run the following command to view the usage statistics for pods with labels:
oc adm top pod --selector=''
$ oc adm top pod --selector=''
Copy to Clipboard Copied! Toggle word wrap Toggle overflow You must choose the selector (label query) to filter on. Supports
=
,==
, and!=
.
1.2.4. Viewing resource logs 复制链接链接已复制到粘贴板!
You can view the log for various resources in the OpenShift CLI (oc) and web console. Logs read from the tail, or end, of the log.
Prerequisites
- Access to the OpenShift CLI (oc).
Procedure (UI)
In the OpenShift Container Platform console, navigate to Workloads
Pods or navigate to the pod through the resource you want to investigate. 注意Some resources, such as builds, do not have pods to query directly. In such instances, you can locate the Logs link on the Details page for the resource.
- Select a project from the drop-down menu.
- Click the name of the pod you want to investigate.
- Click Logs.
Procedure (CLI)
View the log for a specific pod:
oc logs -f <pod_name> -c <container_name>
$ oc logs -f <pod_name> -c <container_name>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow where:
-f
- Optional: Specifies that the output follows what is being written into the logs.
<pod_name>
- Specifies the name of the pod.
<container_name>
- Optional: Specifies the name of a container. When a pod has more than one container, you must specify the container name.
For example:
oc logs ruby-58cd97df55-mww7r
$ oc logs ruby-58cd97df55-mww7r
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc logs -f ruby-57f7f4855b-znl92 -c ruby
$ oc logs -f ruby-57f7f4855b-znl92 -c ruby
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The contents of log files are printed out.
View the log for a specific resource:
oc logs <object_type>/<resource_name>
$ oc logs <object_type>/<resource_name>
1 Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Specifies the resource type and name.
For example:
oc logs deployment/ruby
$ oc logs deployment/ruby
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The contents of log files are printed out.