Red Hat Training

A Red Hat training course is available for Red Hat JBoss Developer Studio

Chapter 1. Developing Using Containers and the Cloud

1.1. Using Container Development Kit 2.x Tooling in JBoss Developer Studio 10.x

1.1.1. About Using Red Hat Container Development Kit with the IDE

Red Hat Container Development Kit is a pre-built container development environment based on Red Hat Enterprise Linux. Red Hat Container Development Kit helps you get started with developing container-based applications quickly. You can easily set up Red Hat Container Development Kit and then use toolings, such as, OpenShift Container Platform and Docker, through JBoss Developer Studio, without spending any additional time in setting up and configuring the supplementary tooling.

There are two ways to install Red Hat Container Development Kit with JBoss Developer Studio:

Once installed, you can use the installed components with the Docker Tooling.

1.1.2. Installing Red Hat Container Development Kit and JBoss Developer Studio Using the Red Hat Development Suite Installer

Use the Red Hat Development Suite Installer to install Red Hat Container Development Kit, JBoss Developer Studio, and other relevant components. The Installer automatically configures these components for use together. This option is currently available for Windows and macOS.

For instructions about using the Red Hat Development Suite Installer, see Red Hat Development Suite Istallation Guide.

After using the Red Hat Development Suite Installer to install Red Hat Container Development Kit and JBoss Developer Studio, manually run the Container Development Environment tooling, which also creates an OpenShift and a Docker connection.

1.1.3. Installing Red Hat Container Development Kit and JBoss Developer Studio as Separate Entities

You can download and install Red Hat Container Development Kit and the JBoss Developer Studio separately. This option requires some additional configuration steps before the two can be used together.

1.1.3.1. Prerequisites

Ensure that the following are installed on your system:

  • A virtualization system such as VirtualBox, VMWare, or Linux KVM/libvirt
  • Vagrant, which is an open source tool to create and distribute portable development environments
  • Red Hat Container Development Kit 2.3
  • JBoss Developer Studio 10.x

For details about installing these prerequisites, see the Red Hat Container Development Kit Installation Guide.

1.1.3.2. Set Up Red Hat Container Development Kit in the IDE

To set up Red Hat Container Development Kit in the IDE:

  1. Start the IDE.
  2. Press Ctrl+3 and in the Quick Access bar, type CDK.
  3. From the results, click Launch Container Development Environment using Red Hat CDK.
  4. If asked, enter your user credentials.
  5. In the New Server dialog box:

    1. Ensure that Red Hat Container Development is selected by default.
    2. In the Server’s host name field, type the desired server host name.
    3. In the Server Name field, type the desired server name.
    4. Click Next to continue.

      Enter Details on the New Server Dialog Box
  6. In the New Server Red Hat Container Development Environment window, add the security information and your access.redhat.com credentials:

    1. In the Username field, click Add to add a new username for the Red Hat Customer Portal or select an existing user from the drop-down menu.
    2. In the Folder field, navigate to the directory that contains your local Vagrantfile. You can also use the Vagrantfile supplied in the cdk.zip file to initialize the Red Hat Container Development Kit box.
  7. Click Finish to conclude setting up the Red Hat Container Development Kit server adapter.

    Vagrantfile Location
  8. Open the Servers view, right-click Container Development Environment and click Start.
  9. If asked, enter the password.
  10. In the Untrusted SSL Certificate dialog box, click Yes.

    SSL Certificate Acceptance
  11. The Servers view shows the server adapter started. To monitor the status of the server adapter, read the log in the built-in terminal.

    Monitor Status of Server Adapter in Built-in Terminal

    You can open the OpenShift Explorer view to see the IP address and the port of the OpenShift Conatiner Platform that you have connected to (example: openshift-dev https://10.1.2.2:8443). Expand the connection to see the sample projects. You can also open the Docker Explorer view to view the Container Development Environment connection and expand the connection to see the Containers and Images.

Choose to continue working with OpenShift Container Platform within JBoss Developer Studio or view instructions for Container-Based Development with JBoss Developer Studio.

1.1.4. Using the Docker Tooling

After starting the Red Hat Container Development Kit server in the IDE, you can follow one of the two container development workflows:

1.1.4.1. Use Docker for Container-based Development

Use Docker for Container-based Development as follows:

  1. Create a new project with your Dockerfile.

    1. Click File > New > Project.
    2. Type java in the search field and from the results, select Java Project and click Next to continue.
    3. Add a name for the new project and click Finish. The Project Explorer view shows the project that you just created.
    4. Click File > New > File.
    5. In the New File window:

      1. In the Enter or select the parent folder field, click the project name that you created.
      2. In the File name field, type Dockerfile and click Finish.
      3. Edit the Dockerfile as desired and then save (for example, by creating a new Docker image to customize a given version of JBoss/WildFly by adding a datasource definition and its associated driver). The Dockerfile may also package your application as a war file via a Maven command, and copy it into the container in the WildFly deployments directory. See https://docs.docker.com/engine/reference/builder for more information about the Dockerfile instructions.

1.1.4.2. Build Docker Using the Container Development Environment

Do a Docker build using the Container Development Environment as follows:

  1. In the Project Explorer view, right-click the Dockerfile and select Run As > Docker Image Build.
  2. In the dialog box:

    1. In the Connection field, select your Container Development Environment server adapter.
    2. In the Repository Name field, enter the desired name for the docker image and click OK. After the build is done, a new image with the given name will be listed in the Docker Explorer view and in the Docker Images view.
  3. Do a Docker run using the Container Development Environment:

    1. Open the Docker Explorer view by typing Ctrl+3 in the quick access menu.
    2. Navigate to the Images node under the Docker connection.
    3. Right-click your image and click Run.
    4. Fill in the necessary details and click Finish to run your image. It is optional to give the container a name, but it is recommended to name it. This name helps locate the specific container in a list of containers in the future.
  4. In the Docker Explorer view, select the container and expand its node and select the 8080 port and click Show In > Web Browser to access the application deployed in the Docker container.
1.1.4.2.1. Next Steps for the Docker Tooling

For further information about the basics of Docker Tooling, see Configure Docker Tooling (Basic).

1.1.5. Using OpenShift Container Platform Tooling

Use OpenShift for Container-based Development as follows:

  1. Create a new OpenShift Container Platform project. These projects are like namespaces for OpenShift applications. They are different from how Eclipse projects relate to Eclipse applications. Additionally, Eclipse projects can be mapped to OpenShift applications.

    1. In the OpenShift Explorer view, right-click the name of the connection and select New > Project to create a new OpenShift Container Platform project.

      Note

      The CDK server adapter creates the OpenShift Container Platform connection when you start the CDK server adapter in the preceding sections.

    2. Add the name and any other relevant details for the new project and click Finish.
  2. Create an application in your OpenShift Container Platform project using the templates:

    1. Right-click your new project name and click New > Application.
    2. In the Select Template dialog box, search box, type the application type required. For example, for a node.js application, type nodejs and from the displayed list, select the relevant nodejs template and click Finish.
    3. Click OK to accept the results of the application creation process.
    4. When prompted, enter a new git location or click Finish in the dialog box to use the listed default git location for your application.
  3. Create a new OpenShift Container Platform server adapter for your project and application:

    1. In the OpenShift Explorer view, expand the connection and then the project.
    2. Right-click the service and click Server Adapter.
    3. In the OpenShift Adapter Settings window:

      1. Ensure that the Eclipse Project field, shows the relevant project or click Browse to locate the project.
      2. In the Services field, select the relevant service.
      3. Click Finish.
  4. Debug the application, if required.

    1. In the Servers view, right-click the server adapter and click Restart in Debug.

1.1.5.1. Next Steps for the OpenShift Tooling

See the Developing for the Cloud with OpenShift 3 section in the index for additional tasks using the OpenShift Container Platform tooling.

1.1.6. Known Issues

  • When the Docker Explorer is first started, attempting to extend the Containers or Images causes the explorer to fail and throw an exception. To work around this issue, restart Eclipse/JBoss Developer Studio. Details are in JBIDE-21983.