---
title: Getting familiar with OpenShift
exercise: 1
date: '2023-12-04'
tags: ['openshift','containers','kubernetes']
draft: false
authors: ['default']
summary: "In this first exercise we'll get familiar with OpenShift."
---

Red Hat [OpenShift](https://www.redhat.com/en/technologies/cloud-computing/openshift) is a unified platform to build, modernize, and deploy applications at scale. In this first excercise we'll get logged into our cluster and familarise ourselves with the OpenShift web console and web terminal.

The OpenShift Container Platform web console is a feature-rich web console with both an Administrator perspective and a Developer perspective accessible through any modern web browser. You can use the web console to visualize, browse, and manage your OpenShift cluster and the applications running on it.

In addition to the web console, OpenShift includes command line tools to provide users with a nice interface to work with applications deployed to the platform. The `oc` command line tool is available for Linux, macOS or Windows.

**Let's get started!**

## 1.1 - Login to lab environment

An OpenShift `4.14` cluster has already been provisioned for you to complete these excercises. Open your web browser and navigate to the workshop login page https://demo.redhat.com/workshop/vq5abz.

Once the page loads you can login with the details provided by your workshop facilitator.

<Zoom>
|![workshop](/ocp-app-delivery-workshop/static/images/workshop.png)             | 
|:-----------------------------------------------------------------------------:|
| *Workshop login page*                                                         |
</Zoom>


## 1.2 - Login to the cluster web console

Once you're logged into the lab environnment we can open up the OpenShift web console and login with the credentials provided. 

When first logging in you will be prompted to take a tour of the **Developer** console view, let's do that now. 

<Zoom>
| ![tour](/ocp-app-delivery-workshop/static/images/tour.gif)                    | 
|:-----------------------------------------------------------------------------:|
| *Developer perspective web console tour*                                      |
</Zoom>


## 1.3 - Understanding projects

Projects are a logical boundary to help you organize your applications. An OpenShift project allows a community of users (or a single user) to organize and manage their work in isolation from other projects. 

Each project has its own resources, role based access control (who can or cannot perform actions), and constraints (quotas and limits on resources, etc). 

Projects act as a "wrapper" around all the application services you (or your teams) are using for your work.

In this lab environment, you already have access to single project: `userX` (Where X is the number of your user allocted for the workshop.)

Let's click into our `Project` from the left hand panel of the **Developer** web console perspective. We should be able to see that our project has no `Deployments` and there are no compute cpu or memory resources currently being consumed.

<Zoom>
|![project](/ocp-app-delivery-workshop/static/images/project.png)               | 
|:-----------------------------------------------------------------------------:|
| *Developer perspective project view*                                          |
</Zoom>


## 1.4 - Switching between perspectives

Different roles have different needs when it comes to viewing details within the OpenShift web console. At the top of the left navigation menu, you can toggle between the Administrator perspective and the Developer perspective.

Select **Administrator** to switch to the Administrator perspective. 

Once the Administrator perspective loads, you should be in the "Home" view and see a wider array of menu sections in the left hand navigation panel.

Switch back to the **Developer** perspective. Once the Developer perspective loads, select the **Topology** view.

Right now, there are no applications or components to view in your `userX`  project, but once you begin working on the lab, you’ll be able to visualize and interact with the components in your application here.

<Zoom>
|![perspectives](/ocp-app-delivery-workshop/static/images/perspectives.gif)     | 
|:-----------------------------------------------------------------------------:|
| *Switching web console perspectives*                                          |
</Zoom>



## 1.5 - Launching a web terminal

While web interfaces are comfortable and easy to use, sometimes we want to quickly run commands to get things done. That is where the `oc` command line utility comes in.

One handy feature of the OpenShift web console is we can launch a web terminal that will create a browser based terminal that already has the `oc` command logged in and ready to use.

Let's launch a web terminal now by clicking the terminal button in the top right hand corner and then clicking **Start** with our `userX` project selected.

<Zoom>
|![web-terminal](/ocp-app-delivery-workshop/static/images/web-terminal.gif)     | 
|:-----------------------------------------------------------------------------:|
| *Launching your web terminal*                                                 |
</Zoom>


## 1.6 - Running oc commands

The [`oc` command line utility](https://docs.openshift.com/container-platform/4.14/cli_reference/openshift_cli/getting-started-cli.html#creating-a-new-app) is a superset of the upstream kubernetes `kubectl` command line utility. This means it can do everything that `kubectl` can do, plus some additional OpenShift specific commands.

Let's try a few commands now:


### Checking our current project

Most actions we take in OpenShift will be in relation to a particular project. We can check which project we are currently actively using by running the `oc project` command.

We should see output similar to below showing we are currently using our `userX` project:

```bash
bash-4.4 ~ $ oc project
Using project "user1" from context named "user1-context" on server "https://172.31.0.1:443".
```

### Getting help and explaining concepts

As with any command line utility, there can be complexity that quickly surfaces. Thankfully the `oc` command line utility has excellent built in help. 

Let's take a look at that now.

To get an understanding of all the options available, try running `oc help`. You should see options similar to the below sample:

```text
bash-4.4 ~ $ oc help
OpenShift Client

This client helps you develop, build, deploy, and run your applications on any
OpenShift or Kubernetes cluster. It also includes the administrative
commands for managing a cluster under the 'adm' subcommand.

Basic Commands:
  login             Log in to a server
  new-project       Request a new project
  new-app           Create a new application
  status            Show an overview of the current project
  project           Switch to another project
  projects          Display existing projects
  explain           Get documentation for a resource

Build and Deploy Commands:
  rollout           Manage a Kubernetes deployment or OpenShift deployment config
  rollback          Revert part of an application back to a previous deployment
  new-build         Create a new build configuration
  start-build       Start a new build
  cancel-build      Cancel running, pending, or new builds
  import-image      Import images from a container image registry
  tag               Tag existing images into image streams

```


To get a more detailed explanataion about a specific concept we can use the `oc explain` command.

Let's run `oc explain project` now to learn more about the concept of a project we introduced earlier:

```text
bash-4.4 ~ $ oc explain project
KIND:     Project
VERSION:  project.openshift.io/v1

DESCRIPTION:
     Projects are the unit of isolation and collaboration in OpenShift. A
     project has one or more members, a quota on the resources that the project
     may consume, and the security controls on the resources in the project.
     Within a project, members may have different roles - project administrators
     can set membership, editors can create and manage the resources, and
     viewers can see but not access running containers. In a normal cluster
     project administrators are not able to alter their quotas - that is
     restricted to cluster administrators.

     Listing or watching projects will return only projects the user has the
     reader role on.

     An OpenShift project is an alternative representation of a Kubernetes
     namespace. Projects are exposed as editable to end users while namespaces
     are not. Direct creation of a project is typically restricted to
     administrators, while end users should use the requestproject resource.
```


That's a quick introduction to the `oc` command line utility. Let's close our web terminal now so we can move on to the next excercise.

<Zoom>
|![close-terminal](/ocp-app-delivery-workshop/static/images/close-terminal.gif) | 
|:-----------------------------------------------------------------------------:|
| *Closing your web terminal*                                                   |
</Zoom>

Well done, you've finished exercise 1! 🎉
