OpenShift Quick Start: CLI

David Pitt Microservices, OpenShift Leave a Comment

This post is a continuation of our hands-on OpenShift Quick Start blog series. In the first post we introduced OpenShift, and in part two, you worked to get OpenShift running locally & adding a Container with an API service to a Pod. Make sure you’ve completed that step prior to starting the continued exercise below!

The previous blogs in this series managed OpenShift using the web admin user interface. However, everything that can be done with the user interface can also be done from using the CLI (Command Line Interface). Arguably, developers prefer to interact with text commands, but that’s a generalization.

In this post, we’ll demonstrate common OpenShift commands can be done in the web admin from the command line.

Here are the reasons the CLI might be used over the command line interface.

  • Integrating with programming languages
  • Scripting
  • When bandwidth is constrained

The CLI is used to start up the cluster, which you should have completed in the previous blog as shown below.

oc cluster up

Available CLI commands are displayed using the help option:

oc help 

Available help commands will be displayed:

You can obtain the status of your cluster:

oc cluster up 

Other Example Commands

Here are a couple more example commands.

Cluster projects
$ oc project
Deploy container image to a Pod
     $ oc deploy example-api -n myproject
Scaling up a Pod to 3 replicas
    $ oc scale --replicas dc example-api

There are many commands. Essentially, you can do everything you can do in the web admin from the command line.

The next blog in this OpenShift series will walk through the Continuous Integration / Continuous Delivery (CICD) building and Jenkins 2 Pipeline integration. Stay tuned!

See Also:  Building a Java Cloud Native Spring Microservice Application on Azure, Part 1

Series

  1. Introduction to Managing Docker Containers with OpenShift and Kubernetes
  2. OpenShift Quick Start – Installing OpenShift locally & adding a Container with an API service to a Pod
  3. This Post –> Scaling Pods and Managing Cluster with the Command Line Interface
  4. Continuous Build and Deploy with Jenkins 2 Pipelines
  5. Using a STI (Source to Image) Utility to Create and Deploy Spring Boot Java Image

What Do You Think?