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. Rather than 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 when the OpenShift OAuth service does not authenticate the CodeReady Workspaces instance" 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.15/html-single/installation_guide/index#installing-che.adoc . 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 Install 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 when the OpenShift OAuth service does not authenticate the CodeReady Workspaces instance This section describes how to authenticate with an OpenShift cluster when the OpenShift OAuth service does not authenticate the CodeReady Workspaces instance. It enables the user to develop and push Components from CodeReady Workspaces to the OpenShift instance that contains CodeReady Workspaces. Note When the OpenShift OAuth service authenticates the CodeReady Workspaces instance, the OpenShift Connector plug-in automatically establishes the authentication with the OpenShift instance containing CodeReady Workspaces. OpenShift Connector offers the following methods for logging in to the OpenShift Cluster from the CodeReady Workspaces instance: Using the notification asking to log in to the OpenShift instance containing CodeReady Workspaces. Using the Log in to the cluster button. Using the Command Palette. Note OpenShift Connector plug-in requires manual connecting to the target cluster. The OpenShift Connector plug-in logs in to the cluster as inClusterUser . If this user does not have manage project permission, this error message appears when creating a project 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 issue: Log out from the local cluster. Log in to OpenShift cluster using the OpenShift user's credentials. Prerequisites A running instance of CodeReady Workspaces. See https://access.redhat.com/documentation/en-us/red_hat_codeready_workspaces/2.15/html-single/installation_guide/index#installing-che.adoc . A CodeReady Workspaces workspace is available. See Chapter 3, Developer workspaces . The OpenShift Connector plug-in is available. See Section 8.2, "Installing OpenShift Connector in CodeReady Workspaces" . The OpenShift OAuth provider is available only for the auto-login to the OpenShift instance containing CodeReady Workspaces. See https://access.redhat.com/documentation/en-us/red_hat_codeready_workspaces/2.15/html-single/administration_guide/index#configuring-openshift-oauth.adoc . Procedure In the left panel, click the OpenShift Application Explorer icon. In the OpenShift Connector panel, 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 . If a You are already logged in a cluster. message appears, click Yes . Select the method to log in to the cluster: Credentials or Token , and follow the login instructions. Note To authenticate with a token, the required token information is in the upper 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 deployable assets 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.15/html-single/installation_guide/index#installing-che.adoc . 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 deployed to the cluster. Use a right-click for selecting additional actions, such as debugging and opening in a browser, which requires the exposure of the port 8080 . 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 using the Add to workspace button. For additional information about cloning Git repository, see: Section 2.2.2, "Accessing a Git repository using HTTPS" .

Commands: