A JBoss Project
Red Hat

How To:

Using the IDE’s Container Development Kit Tooling

About Using the Container Development Kit with the IDE

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

Following are the two ways to install CDK with DevStudio:

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

Installing CDK and DevStudio Using the Red Hat Development Suite Installer

Use the Red Hat Development Suite (DevSuite) Installer to install CDK, DevStudio, and other relevant components. The Installer automatically configures these components for use together. This option is currently available for Windows, macOS, and RHEL 7. For instructions about using the DevSuite Installer, see Red Hat Development Suite Installation Guide.

The installation configures CDK tooling (creates the CDK server adapter, passes user credentials for the access.redhat.com domain used in the Installer). This makes the CDK tooling ready for use in the IDE. After the installation is complete, run DevStudio directly from the Installer, open the Servers view and start the Container Development Environment server adapter. This will start CDK and create OpenShift Container Platform and Docker connections. Note that if you close the Installer window and then run DevStudio, your user credentials will not be passed automatically and you must enter your user credentials manually.

Installing CDK and the IDE as Separate Products

You can download and install CDK and the IDE separately. This option requires some additional configuration steps before the two can be used together.

Prerequisites

Ensure that the following are installed on your system:

  • Ensure that hardware virtualization is enabled on your system

  • Ensure that the following are installed on your system:

    • Hypervisor such as VirtualBox, Linux KVM/libvirt, xhyve (macOS) or hyper-V (Windows) is installed and configured

    • CDK 3.1

    • DevStudio 11.0

  • Ensure that you have a Red Hat Developer account. For a new account, visit https://developers.redhat.com/.

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

Set Up the CDK Connection in the IDE

To set up the CDK connection 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.

  6. Click Next to continue.

    Selecting Red Hat Container Development Kit 3
    Figure 1. Selecting Red Hat Container Development Kit 3
  7. In the New Server Red Hat Container Development Environment window, add the security information and your access.redhat.com credentials:

    1. In the Domain field, ensure that access.redhat.com appears.

    2. In the Username field, ensure that your username appears.

    3. In the Hypervisor field, ensure that the relevant virtualization system for your operating system appears.

    4. In the Minishift Binary field, ensure that the location of the directory where minishift is installed appears.

  8. Click Finish.

    Entering User Credentials
    Figure 2. Entering User Credentials
  9. If it appears, in the Secure Storage Password window, Password field, type your password and click OK.

  10. Open the Servers view, and right-click the Container Development Environment server adapter and click Start.

  11. The Console view is the view in focus showing the progress of starting the Container Development Environment.

  12. If it appears, in the Untrusted SSL Certificate dialog box, click Yes.

Result: The Starting local OpenSHift cluster using ‘kvm’ hypervisor message appears in the Console view of the IDE.

In case you are not signed in to your OpenShift Container Platform account, the New OpenShift Connection wizard appears. Either create a new connection or sign in to your existing account using the Basic or OAuth protocol.

0pen the OpenShift Explorer view to see the IP address and the port of the OpenShift Container Platform that you have connected to: developer {connection_IP} (example, developer 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 DevStudio or view instructions for Container-based Development with DevStudio.

Using the Docker Tooling

After starting the CDK server in the IDE, you can follow one of two container development workflows:

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 bar and from the results, select Java Project and click Next to continue.

    3. In the Project name field, type 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 that you created.

      2. In the File name field, type Dockerfile and click Finish.

    6. Edit the Dockerfile as desired and then save it. For example, copy and paste the following content in the dockerfile and then save the file:

          # Use latest jboss/base-jdk:8 image as the base
      FROM jboss/base-jdk:8
      
      # Set the WILDFLY_VERSION env variable
      ENV WILDFLY_VERSION 10.1.0.Final
      ENV WILDFLY_SHA1 9ee3c0255e2e6007d502223916cefad2a1a5e333
      ENV JBOSS_HOME /opt/jboss/wildfly
      
      USER root
      
      # Add the WildFly distribution to /opt, and make wildfly the owner of the extracted tar content
      # Make sure the distribution is available from a well-known place
      RUN cd $HOME \
          && curl -O https://download.jboss.org/wildfly/$WILDFLY_VERSION/wildfly-$WILDFLY_VERSION.tar.gz \
          && sha1sum wildfly-$WILDFLY_VERSION.tar.gz | grep $WILDFLY_SHA1 \
          && tar xf wildfly-$WILDFLY_VERSION.tar.gz \
          && mv $HOME/wildfly-$WILDFLY_VERSION $JBOSS_HOME \
          && rm wildfly-$WILDFLY_VERSION.tar.gz \
          && chown -R jboss:0 ${JBOSS_HOME} \
          && chmod -R g+rw ${JBOSS_HOME}
      
          # Ensure signals are forwarded to the JVM process correctly for graceful shutdown
          ENV LAUNCH_JBOSS_IN_BACKGROUND true
      
          USER jboss
      
          # Expose the ports we're interested in
          EXPOSE 8080
      
          # Set the default command to run on boot
          # This will boot WildFly in the standalone mode and bind to all interface
          CMD ["/opt/jboss/wildfly/bin/standalone.sh", "-b", "0.0.0.0"]
      ).

      For additional information about the Dockerfile, see https://docs.docker.com/engine/reference/builder.

Build Docker Image Using the Container Development Environment

To do a Docker image build using the Container Development Environment:

  1. In the Project Explorer view, expand the project and right-click the Dockerfile and select Run As > Docker Image Build.

  2. In the Docker Image Build Configuration dialog box:

    1. In the *Connection field, select your Container Development Environment server adapter.

    2. In the Image 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 is listed in the Docker Explorer view under CDK Docker connection under images and in the Docker Images view. Also, the Console view shows Successfully built <Docker_image_ID> message.

  3. Run a Docker image using the Container Development Environment:

    1. Open the Docker Explorer view by typing Ctrl+3 in the quick access menu or using the Window > Perspective > Open Perspective > Docker Tooling menu option.

    2. Navigate to the Images node under the Docker connection.

    3. Right-click your image and click Run.

    4. In the Run a Docker Image window, fill in the necessary details and click Finish to run your image. The Console view shows the progress of execution of the Docker image. Optionally, give the container a name. This name helps locate the specific container in a list of containers in the future.

    5. In the Docker Explorer view, select the container that you named in the preceding step and expand its node and select the 8080 port and click Show In > Web Browser to access the application deployed in the Docker container. The application opens in the default web browser.

Next Steps for the Docker Tooling

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

Using OpenShift Container Platform Tooling

Use OpenShift Container Platform 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 connection and click New > Project to create a new OpenShift Container Platform project.

      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 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 New OpenShift Application window, 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. In the Import OpenShift Application window, select a Git Clone Location and click Finish.

Next Steps for the OpenShift Tooling

For additional tasks to be performed using the OpenShift Container Platform tooling, see Developing Apps for the Cloud with OpenShift 3.

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

back to top