Have you ever been daunted by the idea of working with Red Hat OpenShift Dev Spaces? Or, is the thought of developing your own applications using this amazing functionality by Red Hat a bit too much for you? Well, this blog might help you overcome your fears! Follow along as I walk you through a step-by-step process for installing OpenShift Dev Spaces on the Red Hat OpenShift Container Platform on IBM Power. You will also learn how to install OpenShift Dev Spaces operator and start a .NET based workspace.
What is OpenShift Dev Spaces?
First things first! OpenShift Dev Spaces (Formerly known as Red Hat CodeReady Workspaces) uses Kubernetes and containers to provide any member of the development or IT team with a consistent, secure, and zero configuration development environment. It is often referred as, “The OpenShift native developer workspace server and Integrated Developer Environment (IDE)”. OpenShift Dev Spaces allows you to create workspaces that can be used to code, build, test, run and debug applications. Isn’t that wonderful? For more information, see Red Hat OpenShift Dev Spaces.
OpenShift Dev Spaces consists of the CheCluster custom resource and various components such as devworkspace, cheServer, pluginRegistry, devfileRegistry, database, dashboard, and imagePuller. If you want to check out more details about these components, see OpenShift Dev Spaces Components.
The CheCluster custom resource is a Kubernetes object that can be configured by editing the CheCluster Custom Resource YAML file. The YAML file contains sections to configure each component. The CheCluster custom resource is created during installation of OpenShift Dev Spaces and is used to setup the OpenShift Dev Spaces components.
Each component of an OpenShift Dev Spaces workspace is managed by OpenShift pods. A pod can be defined as a collection of containers that are stored inside the node of an OpenShift cluster. This implies that everything that is running on OpenShift Dev Spaces is running within a container making OpenShift Dev Spaces highly portable. For more details about OpenShift Pods, see Pods and Services.
Using OpenShift Dev Spaces, you can create developer workspaces with different language support. A workspace is a containerized instance of a development environment that you can use to write, build, run, or debug the code. The supported languages are C++, Python, Java, Gradle, Nodejs, PHP and C#. For additional details on workspaces, see The Inner Loop with OpenShift Dev Spaces.
Furthermore, developer workspace supports extensions to add languages, debuggers, and other tools. The Visual Studio Code binary that is included in the pluginRegistry component of OpenShift Dev Spaces is preconfigured to use the Open VSX Registry which contains thousands of extensions and is owned by Eclipse Foundation. We have explained this in detail in the “Starting Workspace on OpenShift Dev Spaces” section of this blog.
Some of the features that are provided by OpenShift Dev Spaces include:
OpenShift Native Development: OpenShift Dev Spaces is included in the OpenShift subscription and is available from version 4.10 onwards. The application and development environment are containerized and run on OpenShift. Thus, you can focus on coding without worrying about the intricate details of Kubernetes.
In-browser Integrated Developer Environment (IDE): OpenShift Dev Spaces allows you to develop code using multiple IDEs which includes Visual Studio Code and the deprecated (and soon to be removed) Theia-ide. You only need a system with a web browser to code, build, test, and run on OpenShift Dev Spaces.
Near-instant onboarding: Anyone with a browser can contribute to the project within 2 minutes!
What is Visual Studio code (VS code)?
Install OpenShift Dev Spaces
Let’s get started! Check out the prerequisites to know what all you’ll need before you begin.
- A fully functional Red Hat OpenShift cluster.
- An OpenShift command-line interface (oc) installed.
The following steps guide you through installing OpenShift Dev Spaces on an OpenShift cluster.
Step 1: Install DevWorkspace operator on the OpenShift cluster
DevWorkspace operator functions as a standalone operator and is required as a dependency for OpenShift Dev Spaces. For more information, refer to Devfile v2 and the DevWorkspace Operator.
Perform the following steps to install DevWorkspace operator:
- Create a Subscription object YAML file to subscribe a namespace to an operator.
- Create a Subscription object using Command Line Interface (CLI).
oc create -f dwoSubscription.yaml
Click Installed Operators and on the Installed Operators page, notice that DevWorkspace Operator is now displayed, as shown below. This means you installed it successfully!
Login to the OpenShift console with administrator privileges. Click OperatorHub under the Operators menu and then click Red Hat OpenShift Dev Spaces catalog.
After OpenShift Dev Spaces is installed, you will notice that Red Hat OpenShift Spaces is displayed under Installed Operators. To create a CheCluster instance, go to the Red Hat OpenShift Dev Spaces instance Specification tab and click Create CheCluster.
Retain default values for all fields and click create.
After the instance deploys successfully, you can view the OpenShift Dev Spaces URL in the CheCluster details page as shown in figure 6 in the next section.
Step 3. Start .NET workspace with OpenShift Dev Spaces
Follow these steps to start a .NET workspace with OpenShift Dev Spaces.
Click the Red Hat OpenShift Dev Spaces URL that was generated in the overview section of CheCluster instance (shown in Figure 6). This will open the OpenShift Dev Spaces Dashboard as shown in Figure 7 below.
Click .NET to start the .NET workspace.
When you start a workspace, pods are created which contain the details of the workspace as shown below:
Your workspace is now started! You will see the IDE with the sample .NET project, as shown in Figure 10 below. The IDE consists of:
- The Explorer which lists the files from the sample project or a git repository.
- The Search option that can be used to find a particular line of code from the sample project or a repository.
- The Source control section that can be used to perform git operations (push, pull, commit etc)
- The Run and Debug section that can be used for debugging the application.
- Numerous extensions can be installed from the Extensions section. These extensions provide language, tools, and debugging support to the workspace.
- Some of the language support features include code completion, error syntax highlighting and code navigation.
- Tools such as ‘Dependency Analytics’ provides vulnerability detection capabilities to the workspace.
- Extensions can also be used for debugging the projects added to the workspace.
For more Information, see Extensions for Microsoft Visual Studio Code - Open Source.
Note: For .NET, debugging and language support is currently not supported on IBM Power, since the extension is incompatible.
- You can run the dotnet commands from the workspace terminal. To create a new terminal in the workspace click, Menu>Terminal>New Terminal or use the keyboard shortcut Ctrl+Shift+'
Click Open in New Tab to open the .NET application after you enter the run command.
Step 4. Start .NET workspace using Git repository
If you do not want to use a sample project, you can import your own project using a Git repository.
Click Create Workspace to start a workspace, add your Git URL in the Git Repo URL section, and then click Create & Open.
After the workspace starts, you can perform Git operations such as commit, pull, fetch, push, rebase and etc.
That brings us to the end of this blog! We hope you are feeling more confident now that you've learned how to install OpenShift Dev Spaces on Red Hat OpenShift Cluster Platform on Power. You can now try your hand at starting a sample workspace for .NET using the OpenShift Dev Spaces dashboard. You should also be able to start a workspace using a public repository from GitHub.
If you do start a workspace using one of the sample projects on the dashboard or by using the Git URL from git providers like GitHub, Bitbucket, or Gitlab, do tell us about your experience!