Chapter 8. OpenShift Connector overview


OpenShift Connector, also referred to as Visual Studio Code OpenShift Connector for Red Hat OpenShift, is a plug-in for CodeReady Workspaces that provides a method for interacting with Red Hat OpenShift 3 or 4 clusters.

OpenShift Connector makes it possible to create, build, and debug applications in the CodeReady Workspaces IDE and then deploy the applications directly to a running OpenShift cluster.

OpenShift Connector is a GUI for the OpenShift Do (odo) utility, which aggregates OpenShift CLI (oc) commands into compact units. As such, OpenShift Connector helps new developers who do not have OpenShift background with creating applications and running them on the cloud. Instead of using several oc commands, the user creates a new component or service by selecting a preconfigured template, such as a Project, an Application, or a Service, and then deploys it as an OpenShift Component to their cluster.

This section provides information about installing, enabling, and basic use of the OpenShift Connector plug-in.

8.1. Features of OpenShift Connector

The OpenShift Connector plug-in enables the user create, deploy, and push OpenShift Components to an OpenShift Cluster in a GUI.

When used in CodeReady Workspaces, the OpenShift Connector GUI provides the following benefits to its users:

Cluster management

  • Logging in to clusters using tokens and username and password combinations.
  • Switching contexts between different .kube/config entries directly from the extension view.
  • Viewing and managing OpenShift resources as build and deployment. configurations from the Explorer view.

Development

  • Connecting to a local or hosted OpenShift cluster directly from CodeReady Workspaces.
  • Quickly updating the cluster with your changes.
  • Creating Components, Services, and Routes on the connected cluster.
  • Adding storage directly to a component from the extension itself.

Deployment

  • Deploying to OpenShift clusters with a single click directly from CodeReady Workspaces.
  • Navigating to the multiple Routes, created to access the deployed application.
  • Deploying multiple interlinked Components and Services directly on the cluster.
  • Pushing and watching component changes from the CodeReady Workspaces IDE.
  • Streaming logs directly on the integrated terminal view of CodeReady Workspaces.

Monitoring

  • Working with OpenShift resources directly from the CodeReady Workspaces IDE.
  • Starting and resuming build and deployment configurations.
  • Viewing and following logs for deployments, pods, and containers.

8.2. Installing OpenShift Connector in CodeReady Workspaces

OpenShift Connector is a plug-in designed to create basic OpenShift Components, using CodeReady Workspaces as the editor, and to deploy the Component to an OpenShift cluster. To visually verify that the plug-in is available in your instance, see whether the OpenShift icon is displayed in the CodeReady Workspaces left menu.

To install and enable OpenShift Connector in a CodeReady Workspaces instance, use instructions in this section.

Prerequisites

Procedure

Install OpenShift Connector in CodeReady Workspaces by adding it as an extension in the CodeReady Workspaces Plugins panel.

  1. Open the CodeReady Workspaces Plugins panel by pressing Ctrl+Shift+J or by navigating to View Plugins.
  2. Search for vscode-openshift-connector, and click the Install button.
  3. Restart the workspace for the changes to take effect.
  4. The dedicated OpenShift Application Explorer icon is added to the left panel.

8.3. Authenticating with OpenShift Connector from CodeReady Workspaces

Before the user can develop and push Components from CodeReady Workspaces, they need to authenticate with an OpenShift cluster.

OpenShift Connector offers the following methods for logging in to the OpenShift Cluster from the CodeReady Workspaces instance:

  • Using the notification that asks to log in to the OpenShift cluster where CodeReady Workspaces is deployed to.
  • Using the Log in to the cluster button.
  • Using the Command Palette.
Note

In CodeReady Workspaces 2.4, Openshift Connector plug-in requires manual connecting to the target cluster

By default, the Openshift Connector plug-in logs into the cluster as inClusterUser, which may not have the manage project permission. This causes an error message to be displayed when a new project is being created using Openshift Application Explorer:

Failed to create Project with error 'Error: Command failed: "/tmp/vscode-unpacked/redhat.vscode-openshift -connector.latest.qvkozqtkba.openshift-connector-0.1.4-523.vsix/extension/out/tools/linux/odo" project create test-project ✗ projectrequests.project.openshift.io is forbidden

To work around this temporary issue, log out from the local cluster and relog in to OpenShift cluster using the OpenShift user’s credentials.

When using a local instance of OpenShift (such as CodeReady Containers or Minishift), the user’s credentials are stored in the workspace ~/.kube/config file, and may be used for automatic authentication in subsequent logins. In the context of CodeReady Workspaces, the ~/.kube/config is stored as a part of the plug-in sidecar container.

Prerequisites

Procedure

  1. In the left panel, select the OpenShift Application Explorer icon.

    The OpenShift Connector panel is displayed.

  2. Log in using the OpenShift Application Explorer. Use one of the following methods:

    • Click the Log in to cluster button in the top left corner of the pane.
    • Press F1 to open the Command Palette, or navigate to View Find Command in the top menu.

      Search for OpenShift: Log in to cluster and press Enter.

  3. If a You are already logged in a cluster. message appears, click Yes.

    A selection whether to log in using Credentials or Token is displayed at the top of the screen.

  4. Select the method to log in to the cluster and follow the login instructions.

    Note

    For authenticating with a token, the required token information is in the top right corner of the main OpenShift Container Platform screen, under <User name> Copy Login Command.

8.4. Creating Components with OpenShift Connector in CodeReady Workspaces

In the context of OpenShift, Components and Services are basic structures that need to be stored in Application, which is a part of the OpenShift project that organizes deployables into virtual folders for better readability.

This chapter describes how to create OpenShift Components in the CodeReady Workspaces using the OpenShift Connector plug-in and push them to an OpenShift cluster.

Prerequisites

Procedure

  1. In the OpenShift Connector panel, right-click the row with the red OpenShift icon and select New Project.
  2. Enter a name for your project.
  3. Right-click the created project and select New Component.
  4. When prompted, enter the name for a new OpenShift Application in which the component can be stored.

    The following options of source for your component are displayed:

    1. Git Repository

      This prompts you to specify a Git repository URL and select the intended revision of the runtime.

    2. Binary File

      This prompts you to select a file from the file explorer.

    3. Workspace Directory

      This prompts you to select a folder from the file explorer.

  5. Enter the name for the component.
  6. Select the component type.
  7. Select the component type version.
  8. The component is created. Right-click the component, select New URL, and enter a name of your choice.
  9. The component is ready to be pushed to the OpenShift cluster. To do so, right-click the component and select Push.

    The component is now deployed to the cluster. Right-click for selecting additional actions, such as debugging and opening in a browser (requires port 8080 to be exposed).

8.5. Connecting source code from GitHub to an OpenShift Component using OpenShift Connector

When the user has a Git-stored source code that is wanted for further development, it is more efficient to deploy it directly from the Git repository into the OpenShift Connector Component.

This chapter describes how to obtain the content from the Git repository and connect it with a CodeReady Workspaces-developed OpenShift Component.

Prerequisites

  • Have a running CodeReady Workspaces workspace.
  • Be logged in to the OpenShift cluster using the OpenShift Connector.

Procedure

To make changes to your GitHub component, clone the repository into CodeReady Workspaces to obtain this source code:

  1. In the CodeReady Workspaces main screen, open the Command Palette by pressing F1.
  2. Type the Git Clone command in the Command Palette and press Enter.
  3. Provide the GitHub URL and select the destination for the deployment.
  4. Add source-code files to your Project by clicking the Add to workspace button.

For additional information about cloning Git repository, see: Accessing a Git repository via HTTPS.

Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.