Skip to content

Latest commit

 

History

History
164 lines (108 loc) · 5.01 KB

5.RedHatCodeReadyWorkspaces2.adoc

File metadata and controls

164 lines (108 loc) · 5.01 KB

Deploy Golang App on Red Hat CodeReady Workspaces 2.2

Prerequisites

  • You have access to OpenShift Web Console URL. Ask your workshop coordinator for URL if you don’t have one.

  • You have credentials to login. Ask your workshop coordinator for credentials to log onto the OpenShift cluster

  • You have access to a CodeReady Workspaces URL. Ask your workshop coordinator for URL if you don’t have one.

Introduction

CodeReady Workspaces 2.0 provides developer environments that are Kubernetes pods running on OpenShift. In those sandboxes are the components and tools needed to code on a project: a browser-based editor, the plugins, the tools, and the different runtimes required for your project. Everything is running in containers, providing highly consistent, repeatable, and reproducible developer environments—zero config needed, zero pain.

Everything you need in your developer environment is fully containerized, even the editor and its plugins. CodeReady Workspaces isolates the tools from your application runtime, allowing you to bring your Kubernetes application into your developer sandbox, code on your application, and run it as in production.

Terms

A workspace is a development environment that can be likened to a PC loaded up with an operating system, programming language, tools, editor, and one or more development projects. You can even access a command line running in your browser.

A stack is a combination of operating system, programming language support, tools, and any other bits necessary to create a workspace. A workspace is built using a stack as the starting point. In this lab we wil be using the Go stack.

A factory is the means by which you build and share your workspace(s).

Exercise

CodeReady Workspaces 2 Navigation

Access your code ready workspace with the url provided by the workshop coordinator.

Enter username and password provided by the workshop coordinator.

Allow selected permissions if promoted.

Update account information.

update crw2 accountinfo

Create Golang workspace

  • Select Go stack tile

codeready go tile

CodeReady Workspaces 2 Main Screen

code ready workspaces mainscreen

Import golang application click on Git Clone icon

codeready git clone

Enter the repo address Git Repo: https://github.com/tosin2013/codeready-go-app.git and push ENTER

codeready go git repo

To access your code click on the paper icon on the right hand side of the screen.

codeeready explorer

To access the terminal click on the box icon on the left hand side of the screen click on _New terminal.

codeready terminal

Validate that go path is is in environment.

$ env | grep GOPATH
GOPATH=/go:/projects

Run the application

$ cd /projects/codeready-go-app/
$ go run main.go

Click on Open link

codeready openlink

View the running application in the preview panel

codeready previewpanel

Click on the Open in New Tab icon in the preview preview panel

codeready openinnewtab

Add the following to the end of the url /?name=yourname and press Enter

Go back to terminal and press CTRL+c

OpenShift Deployment

Navigate to the terminal in CodeReady Workspaces 2

Login to OpenShift

Create new project

$ oc new-project codeready-app-userXX
ℹ️
Change userXX to your username provided by your workshop coordinator.

Create new build for Application

$ oc new-build --name goapp-userXX --binary --strategy docker

Upload local code and build it in openshift

$ oc start-build goapp-userXX  --from-dir=.

View the logs from the build

$ oc logs -f build/goapp-userXX-1

Create New app from binary build

$ oc new-app goapp-userXX  --name codeready-app-userXX

Get pod status.

$ oc get pods

Expose route to access the application externally.

$ oc expose svc/codeready-app-userXX

Get route

$ oc get route

Open url in webpage

Add the following to the end of the url /?name=yourname and press Enter

Summary

In this lab we learned the following.
  • Navigate the Red Hat CodeReady Workspaces 2 UI

  • Created an application from a Git Repo

  • Ran the application within Red Hat CodeReady Workspaces

  • How to Deploy an application from CodeReady Workspaces 2 to OpenShift