Welcome!

Playground (OpenShift 3.9)

Difficulty:beginner

Estimated Time:60 minutes

This is a playground for trying out OpenShift 3.9. From here you can play
with OpenShift using the web console or command line.

What are playgrounds?

Playgrounds give you a pre-configured environment to start playing and
exploring using an unstructured learning approach. They are great for
experimenting with OpenShift, including trying to deploy your own
application code.

The playground will be available for 60 minutes after which time it will
be destroyed.

Steps

Playground (OpenShift 3.9)

OpenShift Playground

Before you get started we recommend reading the following tips. They explain
a bit about how the playground environment is setup and what access you have.

Logging in to the Cluster

When the OpenShift playground is created you will be logged in initially as
a cluster admin on the command line. This will allow you to perform
operations which would normally be performed by a cluster admin.

Before creating any applications, it is recommended you login as a distinct
user. This will be required if you want to log in to the web console and
use it.

In order that you can still run commands from the command line as a cluster
admin, the sudoer role has been enabled for the developer account.
To execute a command as a cluster admin use the --as system:admin option
to the command. For example:

oc get projects --as system:admin

Creating your own Project

To create a new project called myproject run the command:

oc new-project myproject

You could instead create the project from the web console. If you do this,
to change to the project from the command line run the command:

oc project myproject

Persistent Volume Claims

Persistent volumes have been pre-created in the playground environment.
These will be used if you make persistent volume claims for an application.
The volume sizes are defined as 100Gi each, however you are limited by how
much disk space the host running the OpenShift environment has, which is
much less.

To view the list of available persistent volumes you can run:

oc get pv --as system:admin

Builder Images and Templates

The playground environment is pre-loaded with Source-to-Image (S2I) builders
for Java (Wildfly), Javascript (Node.JS), Perl, PHP, Python and Ruby.
Templates are also available for MariaDB, MongoDB, MySQL, PostgreSQL and
Redis.

You can see the list of what is available, and what versions, under Add to
Project in the web console, or by running from the command line:

oc new-app -L

Running Images as a Defined User

By default OpenShift prohibits images from running as the root user
or as a specified user. Instead, each project is assigned its own unique
range of user IDs that application images have to run as.

If you attempt to run an arbitrary image from an external image registry
such a Docker Hub, which is not built to best practices, or requires that
it be run as root, it may not work as a result.

In order to run such an image, you will need to grant additional privileges
to the project you create to allow it to run an application image as any
user ID. This can be done by running the command:

Debugging Scenarios

Help

Katacoda offerings an Interactive Learning Environment for Developers. This course uses a command line and a pre-configured sandboxed environment for you to use. Below are useful commands when working with the environment.

cd <directory>

Change directory

ls

List directory

echo 'contents' > <file>

Write contents to a file

cat <file>

Output contents of file

Vim

In the case of certain exercises you will be required to edit files or text. The best approach is with Vim. Vim has two different modes, one for entering commands (Command Mode) and the other for entering text (Insert Mode). You need to switch between these two modes based on what you want to do. The basic commands are: