Openshift Container Platform – Understand and use the command line

OpenShift Container Platform (OCP) organizes entities in the OpenShift cluster as objects. These objects are managed by the master node. Objects are known as resources. Some resources are:

  • Nodes
  • Services
  • Pods
  • Projects (namespaces)
  • Deployment Configuration (DC)
  • Users

OpenShift command line tools provide a consistent way to update, modify, delete and query the resources.

OCP install a command line tool – oc. The oc command line tools provides the ability to modify and manage resources throughout the life cycle and software development life cycle of a project.

Install the oc command line tool
RHEL subscription based OS installs the oc command line tool on alll master and node machines. To install on a separate server you will need valid subscription for RHEL systems

$ sudo yum install atomic-OpenShift-clients

For other Linux distributions, the OpenShift Origin (https://www.okd.io/) is the implementation of Red Hat OpenShift.

Once the oc CLI tool has been installed, the oc help command display help info. Some oc subcommands are used for login, logout, creating/deleting projects, creating routes/applications/deployment configurations, scaling applications, starting new builds and checking logs.

Bash completion is installed but not enabled by default for the oc CLI. To use bash completion for the oc CLI, source the /etc/bash_completion/oc file .

$source /etc/bash_completion/oc
$oc
adm autoscale create explain import-image new-project process rollout set
annotate cancel-build debug expose label observe project rsh start-build
…

The login subcommand will interactively prompt you for the server name, user name, and password or include the information on the command line

$ oc login https://localhost:8443 -u developer -p password

Once you login, OpenShift save the authorization token in the users’s home folder under the .kube folder.