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.
- Section 8.1, “Features of OpenShift Connector”
- Section 8.2, “Installing OpenShift Connector in CodeReady Workspaces”
- Section 8.3, “Authenticating with OpenShift Connector from CodeReady Workspaces”
- Section 8.4, “Creating Components with OpenShift Connector in CodeReady Workspaces”
- Section 8.5, “Connecting source code from GitHub to an OpenShift Component using OpenShift Connector”
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:
- Authentication tokens
- Username and password
- Auto-login feature when CodeReady Workspaces is authenticated with the OpenShift OAuth service
-
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
- A running instance of Red Hat CodeReady Workspaces. To install an instance of Red Hat CodeReady Workspaces, see https://access.redhat.com/documentation/en-us/red_hat_codeready_workspaces/2.5/html-single/installation_guide/index#installing-codeready-workspaces_crw.
Procedure
Install OpenShift Connector in CodeReady Workspaces by adding it as an extension in the CodeReady Workspaces Plugins panel.
-
Open the CodeReady Workspaces Plugins panel by pressing Ctrl+Shift+J or by navigating to View
Plugins. - Search for vscode-openshift-connector, and click the button.
- Restart the workspace for the changes to take effect.
- The dedicated OpenShift Application Explorer icon is added to the left panel.
8.3. Authenticating with OpenShift Connector from CodeReady Workspaces
The following section is relevant only when the OpenShift OAuth service does not already authenticate a CodeReady Workspaces instance; otherwise, the OpenShift Connector plug-in automatically establishes the authentication with the Openshift instance where CodeReady Workspaces runs.
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 button.
- Using the Command Palette.
In CodeReady Workspaces 2.5, 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
- A running instance of CodeReady Workspaces. To install an instance of CodeReady Workspaces, see https://access.redhat.com/documentation/en-us/red_hat_codeready_workspaces/2.5/html-single/installation_guide/index#installing-codeready-workspaces_crw.
- A CodeReady Workspaces workspace has been created.
- The OpenShift Connector plug-in is available.
- The OpenShift OAuth provider is configured (only for the auto-login to the OpenShift cluster where CodeReady Workspaces is deployed. See Section 5.2, “Configuring OpenShift OAuth”).
Procedure
In the left panel, select the OpenShift Application Explorer icon.
The OpenShift Connector panel is displayed.
Log in using the OpenShift Application Explorer. Use one of the following methods:
- Click the 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.
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.
Select the method to log in to the cluster and follow the login instructions.
NoteFor 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
- A running instance of CodeReady Workspaces. To install an instance of CodeReady Workspaces, see https://access.redhat.com/documentation/en-us/red_hat_codeready_workspaces/2.5/html-single/installation_guide/index#installing-codeready-workspaces_crw.
- The user is logged in to an OpenShift cluster using the OpenShift Connector plug-in.
Procedure
- In the OpenShift Connector panel, right-click the row with the red OpenShift icon and select New Project.
- Enter a name for your project.
- Right-click the created project and select New Component.
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:
Git Repository
This prompts you to specify a Git repository URL and select the intended revision of the runtime.
Binary File
This prompts you to select a file from the file explorer.
Workspace Directory
This prompts you to select a folder from the file explorer.
- Enter the name for the component.
- Select the component type.
- Select the component type version.
- The component is created. Right-click the component, select New URL, and enter a name of your choice.
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:
- In the CodeReady Workspaces main screen, open the Command Palette by pressing F1.
-
Type the
Git Clone
command in the Command Palette and press Enter. - Provide the GitHub URL and select the destination for the deployment.
- Add source-code files to your Project by clicking the button.
For additional information about cloning Git repository, see: Section 2.2.2, “Accessing a Git repository using HTTPS”.