Get your Developer Sandbox and Workspace

20 MINUTE EXERCISE

In this lab you will learn about getting your Red hat Developer Sandbox with a Kubernetes-native development platform and getting familiar with the OpenShift CLI, OpenShift Web Console and CodeReady Workspaces.

Getting your Developer Sandbox for OpenShift

The Red Hat Developer Sandbox is a great way to access Red Hat’s products and technologies without setup or configuration, and start developing quicker than ever before with our new sandbox environments for Red Hat OpenShift and CodeReady Workspaces Try your hand at the technologies with our library of activities as well.

Developer Sandbox

The Developer Sandbox for OpenShift is a Kubernetes-native environment for developing software for OpenShift. You need to follow the Get Started process on this web site first, before attempting any of the workshop steps below.

After verifying your email or mobile number you should you get access to your sandbox and be given a link to a login page to access the OpenShift Web Console, which looks like this:-

Developer Sandbox

Log in to the OpenShift Developer Console

OpenShift ships with a web-based console that will allow users to perform various tasks via a browser.

Please login using the credentials provided when requesting the Developer Sandbox.

After you have authenticated to the web console, you will be presented with a list of projects that your user has permission to work with.

Select the 'Developer View' then your "-stage" project to be taken to the project overview page which will list all of the routes, services, deployments, and pods that you have running as part of your project. There’s maybe nothing much there now, but that’s about to change.

OpenShift - Empty Project

What is CodeReady Workspaces?

CodeReady Workspaces

CodeReady Workspaces is a Kubernetes-native IDE and developer collaboration platform.

As an open-source project, the core goals of CodeReady Workspaces are to:

  • Accelerate project and developer onboarding: As a zero-install development environment that runs in your browser, CodeReady Workspaces makes it easy for anyone to join your team and contribute to a project.

  • Remove inconsistency between developer environments: No more: “But it works on my machine.” Your code works exactly the same way in everyone’s environment.

  • Provide built-in security and enterprise readiness: As CodeReady Workspaces becomes a viable replacement for VDI solutions, it must be secure and it must support enterprise requirements, such as role-based access control and the ability to remove all source code from developer machines.

To achieve those core goals, CodeReady Workspaces provides:

  • Workspaces: Container-based developer workspaces providing all the tools and dependencies needed to code, build, test, run, and debug applications.

  • Browser-based IDEs: Bundled browser-based IDEs with language tooling, debuggers, terminal, VCS integration, and much more.

  • Extensible platform: Bring your own IDE. Define, configure, and extend the tools that you need for your application by using plug-ins, which are compatible with Visual Studio Code extensions.

  • Enterprise Integration: Multi-user capabilities, including Keycloak for authentication and integration with LDAP or AD.

Getting your CodeReady Workspace

CodeReady Workspaces will provide you an out-of-box Developer Workspace with all the tools and the dependencies we need to do the job. And with only one single click!

Devfile

CodeReady Workspaces uses Devfiles to automate the provisioning of a specific workspace by defining:

  • projects to clone

  • browser IDE to use

  • preconfigured commands

  • tools that you need

  • application runtime definition

Providing a devfile.yaml file inside a Git source repository signals to CodeReady Workspaces to configure the project and runtime according to this file.

CodeReady Workspaces is integrated into the Developer Sandox and is available from the OpenShift Web Console usng the apps button in the header bar.

Then login and let the magic happens…​

When CodeReady Workspaces starts, enter the following URL into the Git Repo URL field to load the devfile and click Create & Open

https://github.com/florianmoss/cloud-native-workshop.git
Launching the workspace

Once completed, you will have a fully functional Browser-based IDE within the source code already imported and the IDE configured for our workshop tasks. Deploying this workspace can take 2-3 minutes due to the resource constraints on the sandbox.

Che - Workspace

Connect Your Workspace to Your OpenShift Project

Now you need to connect your CodeReady Workspace environment to your OpenShift development area i.e your project or namespace.

First, in the OpenShift Developer console you need to Copy Your Login command which includes your authentication token for OpenShift access. The Copy login command can be found in the top right header bar of the web page under your login name:

Copy Login command

Then you can follow the link to Display the Token:

Copy Login command
Login Token

Now copy the whole oc login command, token and server address:

Switching back to your CodeReady workspace.

Che - RunTask

Open a '>_ workshop_tools' terminal window, click on 'Terminal' → 'Open Terminal in specific container' → 'workshop-tools'

Now paste the oc login command into the terminal window created at the bottom of the browser page and execute.

The output should be as follows:

$ oc login --token=sha256~yv5Y1pcRsrxxxxxxxxxx --server=https://api.sandbox-m2.ll9k.p1.openshiftapps.com:6443
Logged into "https://api.sandbox-m2.ll9k.p1.openshiftapps.com:6443" as "user" using the token provided.

You have access to the following projects and can switch between them with 'oc project <projectname>':

  * florianmoss-dev
    florianmoss-stage

Using project "florianmoss-dev".
Welcome! See 'oc help' to get started.

To make sure the CodeReady development environment is setup for the development tools you will use you need one more terminal command to complete this:-

odo project set ${CHE_WORKSPACE_NAMESPACE}-stage

And this should confirm the action with a response like this:

Switched to project : florianmoss-stage

Make sure to accept the prompt in the bottom right corner of your screen, as seen below:

Accept Git Repo

What is OpenShift Do (odo)?

OpenShift Do (odo)

OpenShift Do (odo) is a CLI tool for creating applications on OpenShift Container Platform and Kubernetes. With odo, you can write, build, and debug applications on a cluster without the need to administer the cluster itself. Creating deployment configurations, build configurations, service routes and other OpenShift Container Platform or Kubernetes elements are all automated by odo.

Existing tools such as OpenShift CLI (oc) are operations-focused and require a deep understanding of Kubernetes and OpenShift Container Platform concepts. odo abstracts away complex Kubernetes and OpenShift Container Platform concepts allowing developers to focus on what is most important to them: code.

Now you are ready to get started with the labs!

Workshop Trouble Shooting Tips

We hope you have a good workshop, but here are a few tips and tricks that may make it run better.

What browser should I be using for this workshop?

The whole workshop runs in your browser environment which allows us to support a variety of developer platforms from Windows, Mac and Linux. We find the best browser for this workshop is Firefox or Chrome browser.

Workshop stops or freezes

Everything here is browser based so might have the odd glitch. The easiets resoltuion to a number of problems is just to refresh the browser, or worse case restart the browser. All you work is stored centrally on our services so you should juts be able to re-attach to your workspace and OpenShift project and continue. If refreshing the browser doesn’t seem to work then try closing the CodeReady browser tab and re-launch it from the OpenShift Web Console usng the apps button in the header bar.

Having problems seeing CodeReady Workspace?

CodeReady Workspaces use secure web sockets for its UI. If you are having problems try this test web site https://websocketstest.com. All results should be green to proceed. If this test fails please check that you a direct access to the internet, i.e disable any VPNs web proxies etc. If you are using a corporate device you may need to switch to a personal computer.

I’ve been logged out or need to restart the workspace

The workshop will take a few hours to complete all the way through, if you use the system continuosly throughout that period you will not see this issue.

Re-login to the Red Hat Your authentication token will need to refresh for security so expect to have login again. You will need you Sandbox credentials daily but they should be cached.

Re-login from CodeReady CodeReady can perform local tasks like builds, but usually needs to connect to your openShift project to deploy. If your CodeReady deployment tasks fail chance are you need to re-login to OpenShift from CodeReady. Use the instruction on this page Connect Your Workspace to Your OpenShift project. Also make sure you check that your -stage project is selected.

Restart CodeReady Workspaces To save resources CodeReady will idle down. You may need to open or start your workspace again. After doing this, please check that you repeat the Connect Your Workspace to Your OpenShift project step.

My OpenShift pods have all gone to idle

If left for a long period (like overnight) your OpenShift project will idle down all its running pods. On the Topology display they will show up with white rings. Normally these rings would be dark blue if the pod is active. You need to select each Deployment or DeploymentConfig that you have created in turn by clicking on the circle, then on the pop-out select the blue (D) or (DC) text. Then using the circle marked as Scaled to 0 increase the Pod count up to 1. The ring should turn blue aftre about 30 seconds.

How do I cleanup after running this workshop?

There is a terminal task included in the workshop to delete all the elements of the Inner Loop workshop.

Click on 'Terminal' → 'Run Task…​' → 'OpenShift - Cleanup'