Oc get: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
 
(49 intermediate revisions by the same user not shown)
Line 24: Line 24:


  oc get ... -l '<i>label_name</i>=<i>label_value</i>'
  oc get ... -l '<i>label_name</i>=<i>label_value</i>'
To get (almost) all object with a specific label from the current project, execute:
oc get all -l '<''label_name''>=<''label_value''>'
Objects that are not displayed:
* [[OpenShift_Concepts#Persistent_Volume_Claim|Persistent volume claims]]


=Output=
=Output=
Line 30: Line 38:


  oc get ... -o json
  oc get ... -o json
==JSONPath Output==
oc get ... -o jsonpath='{.spec.replicas}'


==YAML Output==
==YAML Output==
Line 35: Line 47:
  oc get ... -o yaml
  oc get ... -o yaml


==-o template==
==<span id='#-o_template'></span>-o template, --template==
 
oc get --template '&#123;{.spec.volumeName}}&#123;{"\n"}}' pvc/<''pvc-name''>


  -o template --template '&#123;{.status.podIP}}&#123;{"\n"}}'
  oc get --template '&#123;{.status.podIP}}&#123;{"\n"}}' pods/<''pod-name''>


Example:
Example:


  oc get node infranode1 -o template --template '&#123;{.spec.externalID}}&#123;{"\n"}}'
  oc get node infranode1 --template '&#123;{.spec.externalID}}&#123;{"\n"}}'
  infranode1
  infranode1
=Other Options=
==-w==
Watch for changes: after listing/getting the requested object, watch for changes.


=Subcommands=
=Subcommands=
Line 48: Line 68:
==all==
==all==


  oc get all [-n ''<project-name>'']
  oc [-n ''<project-name>''] get all
 
Displays [[OpenShift_Concepts#DeploymentConfig|DeploymentConfigs]], [[OpenShift_Concepts#Replication_Controller|replication controllers]], [[OpenShift_Concepts#Route|routes]], [[OpenShift Concepts#Service|services]], and [[OpenShift_Concepts#Pod|pods]] for a project:
 
NAME                    REVISION  DESIRED  CURRENT  TRIGGERED BY
dc/logging-curator      1          1        1        config
dc/logging-es-3fs5ghyo  1          1        1        config
dc/logging-kibana        1          1        1        config
NAME                      DESIRED  CURRENT  READY    AGE
rc/logging-curator-1      1        1        1        25d
rc/logging-es-3fs5ghyo-1  1        1        1        25d
rc/logging-kibana-1        1        1        1        25d
NAME                    HOST/PORT                            PATH      SERVICES        PORT      TERMINATION          WILDCARD
routes/logging-kibana  kibana.apps.openshift.novaordis.io            logging-kibana  <all>    reencrypt/Redirect  None
NAME                    CLUSTER-IP      EXTERNAL-IP  PORT(S)    AGE
svc/logging-es          172.30.254.155  <none>        9200/TCP  25d
svc/logging-es-cluster  172.30.148.235  <none>        9300/TCP  25d
svc/logging-kibana      172.30.123.83    <none>        443/TCP    25d
NAME                            READY    STATUS              RESTARTS  AGE
po/logging-curator-1-drmq5      1/1      Running            5532      24d
po/logging-es-3fs5ghyo-1-31p0n  1/1      Running            2          24d
po/logging-fluentd-3kz30        0/1      MatchNodeSelector  0          24d
po/logging-fluentd-d150b        0/1      MatchNodeSelector  0          24d
po/logging-fluentd-ktrc8        0/1      MatchNodeSelector  0          24d
po/logging-fluentd-kv781        0/1      MatchNodeSelector  0          24d
po/logging-fluentd-nl42s        0/1      MatchNodeSelector  0          24d
po/logging-fluentd-x1w4r        1/1      Running            2          24d
po/logging-fluentd-x2z8x        1/1      Running            2          24d
po/logging-kibana-1-d4bw2        2/2      Running            52        24d


==bc==
==bc==
Line 62: Line 114:
returns the specified build config.
returns the specified build config.


==builds==
==build, builds==
<span id='builds'></span>
 
Get the builds and their status.


  oc get builds
  oc get builds
==clusternetwork==
Information about the network plugin and network status.
See {{Internal|OpenShift Network Plugins|OpenShift Network Plugins}}
==deploymentconfig, dc==
<span id='dc'></span>
Lists the [[OpenShift_Concepts#DeploymentConfig|DeploymentConfigs]] of a project:
oc [-n ''<project-name>''] get dc
==ep==
Get information about an endpoint. The following command can be used as a test for when a service comes on-line:
oc get ep postgresql -o yaml | grep "\- addresses:"
==event==


==events==
==events==
Lists [[OpenShift_Concepts#Events|events]].


  oc get events [-n ''<project-name>'']
  oc get events [-n ''<project-name>'']
Line 75: Line 153:


  oc get identity
  oc get identity
==images, image==
{{Internal|OpenShift_Image_and_ImageStream_Operations#List_Images_available_to_the_Cluster|List images available to the Cluster}}
==imagestream, is==
<span id='is'></span>
oc get is
==istag==
oc get istag


==namespaces==
==namespaces==
Line 80: Line 171:
==netnamespaces==
==netnamespaces==


Displays the virtual networks assigned to each project. See [[OpenShift Network Plugins]].
{{Internal|OpenShift_Network_Operations#Information_about_Virtual_Networks_Assigned_to_Each_Project|OpenShift Network Operations - Information about Virtual Networks assigned to Projects}}
 
==node, nodes==
<span id='node'></span><span id='nodes'></span>


<pre>
Displays all nodes:
oc get netnamespaces
</pre>


<pre>
oc get nodes [-n ''<project-name>'']
NAME              NETID
default            0
kube-system        11092823
logging            6208947
management-infra  5562275
openshift          8714409
openshift-infra    13183382
pizzaparty-dev    5721085
playground        7804116
</pre>


==node==
All hosts in a healthy cluster should be visible in this output. The "Ready" status means that master hosts can communicate with node hosts and that the nodes are ready to run pods (excluding the nodes in which scheduling is disabled).


Describes an individual node:
Describes an individual node:
Line 104: Line 186:
  oc get node ''<node-name>''
  oc get node ''<node-name>''


==nodes==
==pod, pods, po==
<span id='pod'></span>
<span id='pods'></span>


Displays all nodes:
Displays the [[OpenShift Concepts#Pod|pods]] of a project.
 
oc [-n ''<project-name>''] get pods
oc [-n ''<project-name>''] get po
oc get pods --all-namespaces


  oc get nodes [-n ''<project-name>'']
  oc get pod ''<pod-name>''


==pods==
==projects==


<pre>
oc get projects
oc get pods --all-namespaces
</pre>


==projects==
For more details see {{Internal|OpenShift_Project_Operations#List_All_Projects|Project Operations}}


==project==
==project==


  oc get project logging -o yaml
  oc get project <''project-name''> -o yaml


==sa==
==sa==
Line 127: Line 213:


  oc get sa
  oc get sa
Also see {{Internal|OpenShift_Security_Operations#Service_Account_Operations|Service Account Operations}}


==scc==
==scc==


  oc get scc
{{Internal|OpenShift_Security_Operations#Security_Context_Constraints_Operations|Security Context Constraints Operations|}}
 
==services, svc==
 
Displays the [[OpenShift Concepts#Service|services]] of a project:
 
  oc [-n ''<project-name>''] get services
oc [-n ''<project-name>''] get svc


==se==
==se==


  oc get se docker-registry
  oc get se docker-registry
==secret==
oc get secret


==status==
==status==
Line 140: Line 239:
  oc get status
  oc get status


==builds==
==quota==
 
Get the builds and their status.


==quota==
{{Internal|OpenShift_Resource_Management_Operations#Get_Quotas_in_a_Project|Quota Operations}}


For the current project:
==replicationcontroller, rc==
<span id='replicationcontroller'></span>


oc get quota
Lists the [[OpenShift_Concepts#Replication_Controller|replication controllers]] of a project:


For an arbitrary project:
oc [-n ''<project-name>''] get rc


oc get quota -n ''<project-name>''
==routes, routes==
<span id='routes'></span>


==routes==
Displays the project's [[OpenShift_Concepts#Route|routes]].


<pre>
oc get routes
oc get routes
</pre>


==pv==
==pv==


==pvc==
==pvc==
==event==
==clusternetwork==
Information about the network plugin and network status.
See {{Internal|OpenShift Network Plugins|OpenShift Network Plugins}}


==users==
==users==

Latest revision as of 18:05, 7 February 2018

External

Internal

Overview

Gets all resources of a certain type or a single resource of a certain type if specified by name.

Namespace Selection

Generic oc namespace selection applies.

Additionally, to specify all projects, use:

oc get --all-namespaces ...

Selectors

Selectors can be applied with the "-l" option:

oc get ... -l 'label_name=label_value'

To get (almost) all object with a specific label from the current project, execute:

oc get all -l '<label_name>=<label_value>'

Objects that are not displayed:

Output

JSON Output

oc get ... -o json

JSONPath Output

oc get ... -o jsonpath='{.spec.replicas}'

YAML Output

oc get ... -o yaml

-o template, --template

oc get --template '{{.spec.volumeName}}{{"\n"}}' pvc/<pvc-name>
oc get --template '{{.status.podIP}}{{"\n"}}' pods/<pod-name>

Example:

oc get node infranode1 --template '{{.spec.externalID}}{{"\n"}}'
infranode1

Other Options

-w

Watch for changes: after listing/getting the requested object, watch for changes.

Subcommands

all

oc [-n <project-name>] get all 

Displays DeploymentConfigs, replication controllers, routes, services, and pods for a project:

NAME                     REVISION   DESIRED   CURRENT   TRIGGERED BY
dc/logging-curator       1          1         1         config
dc/logging-es-3fs5ghyo   1          1         1         config
dc/logging-kibana        1          1         1         config

NAME                       DESIRED   CURRENT   READY     AGE
rc/logging-curator-1       1         1         1         25d
rc/logging-es-3fs5ghyo-1   1         1         1         25d
rc/logging-kibana-1        1         1         1         25d

NAME                    HOST/PORT                            PATH      SERVICES         PORT      TERMINATION          WILDCARD
routes/logging-kibana   kibana.apps.openshift.novaordis.io             logging-kibana   <all>     reencrypt/Redirect   None

NAME                     CLUSTER-IP       EXTERNAL-IP   PORT(S)    AGE
svc/logging-es           172.30.254.155   <none>        9200/TCP   25d
svc/logging-es-cluster   172.30.148.235   <none>        9300/TCP   25d
svc/logging-kibana       172.30.123.83    <none>        443/TCP    25d

NAME                             READY     STATUS              RESTARTS   AGE
po/logging-curator-1-drmq5       1/1       Running             5532       24d
po/logging-es-3fs5ghyo-1-31p0n   1/1       Running             2          24d
po/logging-fluentd-3kz30         0/1       MatchNodeSelector   0          24d
po/logging-fluentd-d150b         0/1       MatchNodeSelector   0          24d
po/logging-fluentd-ktrc8         0/1       MatchNodeSelector   0          24d
po/logging-fluentd-kv781         0/1       MatchNodeSelector   0          24d
po/logging-fluentd-nl42s         0/1       MatchNodeSelector   0          24d
po/logging-fluentd-x1w4r         1/1       Running             2          24d
po/logging-fluentd-x2z8x         1/1       Running             2          24d
po/logging-kibana-1-d4bw2        2/2       Running             52         24d

bc

Returns the Build Config.

oc get bc

returns all build configs from the current project.

oc get bc my-build-config

returns the specified build config.

build, builds

Get the builds and their status.

oc get builds

clusternetwork

Information about the network plugin and network status.

See

OpenShift Network Plugins

deploymentconfig, dc

Lists the DeploymentConfigs of a project:

oc [-n <project-name>] get dc

ep

Get information about an endpoint. The following command can be used as a test for when a service comes on-line:

oc get ep postgresql -o yaml | grep "\- addresses:"

event

events

Lists events.

oc get events [-n <project-name>]

identity

Returns information about user identity.

oc get identity

images, image

List images available to the Cluster

imagestream, is

oc get is

istag

oc get istag

namespaces

netnamespaces

OpenShift Network Operations - Information about Virtual Networks assigned to Projects

node, nodes

Displays all nodes:

oc get nodes [-n <project-name>]

All hosts in a healthy cluster should be visible in this output. The "Ready" status means that master hosts can communicate with node hosts and that the nodes are ready to run pods (excluding the nodes in which scheduling is disabled).

Describes an individual node:

oc get node <node-name>

pod, pods, po

Displays the pods of a project.

oc [-n <project-name>] get pods
oc [-n <project-name>] get po
oc get pods --all-namespaces
oc get pod <pod-name>

projects

oc get projects

For more details see

Project Operations

project

oc get project <project-name> -o yaml

sa

Returns the service accounts.

oc get sa

Also see

Service Account Operations

scc

Security Context Constraints Operations

services, svc

Displays the services of a project:

oc [-n <project-name>] get services
oc [-n <project-name>] get svc

se

oc get se docker-registry

secret

oc get secret

status

oc get status

quota

Quota Operations

replicationcontroller, rc

Lists the replication controllers of a project:

oc [-n <project-name>] get rc

routes, routes

Displays the project's routes.

oc get routes

pv

pvc

users

Returns the regular users on the system. As "system:admin":

oc get users
NAME      UID                                    FULL NAME   IDENTITIES 
ovidiu    788f943e-610c-11e7-9dee-525400863964               htpasswd_auth:ovidiu