$ oc <command>
With the OpenShift Dedicated command-line interface (CLI), you can create applications and manage OpenShift Dedicated projects from a terminal. The CLI is ideal in situations where you:
Work directly with project source code.
Script OpenShift Dedicated operations.
Are restricted by bandwidth resources and can not use the web console.
You can install the CLI in order to interact with OpenShift Dedicated using a command-line interface.
From the OpenShift Infrastructure Providers page, click Download Command-line Tools.
Click the folder for your operating system and architecture and click the compressed file.
Save the file to your file system.
Extract the compressed file.
Place it in a directory that is on your
After you install the CLI, it is available using the
$ oc <command>
You can log in to the
oc CLI to access and manage your cluster.
You must have access to an OpenShift Dedicated cluster.
You must have installed the CLI.
Log in to the CLI using the
oc login command and enter the required
information when prompted.
$ oc login Server [https://localhost:8443]: https://openshift.example.com:6443 (1) The server uses a certificate signed by an unknown authority. You can bypass the certificate check, but any data you send to the server could be intercepted by others. Use insecure connections? (y/n): y (2) Authentication required for https://openshift.example.com:6443 (openshift) Username: user1 (3) Password: (4) Login successful. You don't have any projects. You can try to create a new project, by running oc new-project <projectname> Welcome! See 'oc help' to get started.
|1||Enter the OpenShift Dedicated server URL.|
|2||Enter whether to use insecure connections.|
|3||Enter the user name to log in as.|
|4||Enter the user’s password.|
You can now create a project or issue other commands for managing your cluster.
Review the following sections to learn how to complete common tasks using the CLI.
oc new-project command to create a new project.
$ oc new-project my-project Now using project "my-project" on server "https://openshift.example.com:6443".
oc new-app command to create a new application.
$ oc new-app https://github.com/sclorg/cakephp-ex --> Found image 40de956 (9 days old) in imagestream "openshift/php" under tag "7.2" for "php" ... Run 'oc status' to view your app.
oc get pods command to view the pods for the current project.
$ oc get pods -o wide NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE cakephp-ex-1-build 0/1 Completed 0 5m45s 10.131.0.10 ip-10-0-141-74.ec2.internal <none> cakephp-ex-1-deploy 0/1 Completed 0 3m44s 10.129.2.9 ip-10-0-147-65.ec2.internal <none> cakephp-ex-1-ktz97 1/1 Running 0 3m33s 10.128.2.11 ip-10-0-168-105.ec2.internal <none>
oc logs command to view logs for a particular pod.
$ oc logs cakephp-ex-1-deploy --> Scaling cakephp-ex-1 to 1 --> Success
oc project command to view the current project.
$ oc project Using project "my-project" on server "https://openshift.example.com:6443".
oc status command to view information about the current project, such
as Services, DeploymentConfigs, and BuildConfigs.
$ oc status In project my-project on server https://openshift.example.com:6443 svc/cakephp-ex - 172.30.236.80 ports 8080, 8443 dc/cakephp-ex deploys istag/cakephp-ex:latest <- bc/cakephp-ex source builds https://github.com/sclorg/cakephp-ex on openshift/php:7.2 deployment #1 deployed 2 minutes ago - 1 pod 3 infos identified, use 'oc status --suggest' to see details.
You can get help with CLI commands and OpenShift Dedicated resources in the following ways.
oc help to get a list and description of all available CLI commands:
$ oc help OpenShift Client This client helps you develop, build, deploy, and run your applications on any OpenShift or Kubernetes compatible platform. It also includes the administrative commands for managing a cluster under the 'adm' subcommand. Usage: oc [flags] Basic Commands: login Log in to a server new-project Request a new project new-app Create a new application ...
--help flag to get help about a specific CLI command:
$ oc create --help Create a resource by filename or stdin JSON and YAML formats are accepted. Usage: oc create -f FILENAME [flags] ...
oc explain command to view the description and fields for a
$ oc explain pods KIND: Pod VERSION: v1 DESCRIPTION: Pod is a collection of containers that can run on a host. This resource is created by clients and scheduled onto hosts. FIELDS: apiVersion <string> APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources ...