Red Hat Container Development Kit

Hello World!

Build Something Today

Let's walk through everything you need to build your first application.

Hello World!

1. Installation and Prerequisites

5 minutes

Body

The prerequisites for running CDK on Red Hat Enterprise Linux are:

  • A Red Hat Developer Program username and password are required to enable the Red Hat Enterprise Linux VM included with the CDK to download and build container images from Red Hat.  Please make sure to accept the terms and conditions.
  • A virtualization platform, either Linux KVM or VirtualBox.  For KVM you should have libvirt permissions to allow you to start and stop a VM using your normal, non-root user ID.
  • 25 GB of free disk space.

All of the commands in this section should be run as the root user.

For more information, see the CDK Gettting Started Guide.

1. Enable the Red Hat Developer Tools software repository

First, you need to enable the Red Hat Developer Tools and Red Hat Software Collections (RHSCL) software repositories using subscription-manager:

$ su -
# subscription-manager repos --enable rhel-7-server-devtools-rpms
# subscription-manager repos --enable rhel-server-rhscl-7-rpms
Note: Change -server- to -workstation- if you aren't using the server variant of Red Hat Enterprise Linux. For developers, we recommend using Red Hat Enterprise Linux Server for access to the widest range of development tools. For developers, a no-cost subscription is available from developers.redhat.com.

Next, add the Red Hat Developer Tools key to your system. This allows yum to verify the integrity of the download packages:

# cd /etc/pki/rpm-gpg
# wget -O RPM-GPG-KEY-redhat-devel https://www.redhat.com/security/data/a5787476.txt
# rpm --import RPM-GPG-KEY-redhat-devel

2. Install the CDK

To install the CDK, run the following command as the root user:

# yum install cdk-minishift docker-machine-kvm

Note: if you intend to use VirtualBox instead of Linux KVM, you can skip the installation of docker-machine-kvm.

2. Setup the CDK

5 minutes

Body

The CDK is a single executable, minishift, which includes a number of bundled components. You use the minishift command to start, stop, and configure the Red Hat Enterprise Linux 7 VM and the Red Hat OpenShift Container Platform single-node cluster running inside of the VM.

The oc command line tool which is used for interacting with OpenShift clusters is downloaded when you run minishift setup-cdk. The oc command must match the version of OpenShift running inside of the VM. The minishift oc-env command provides the statements to add the correct version of oc to your PATH. The output of minishift oc-env is intended to be evaluated by your shell after running minishift start.

The setup steps are:

  1. Run minishift setup-cdk to set up your CDK environment in ~/.minishift
  2. Add your Red Hat Developer Program username to your environment
All of the commands in this section should be run under your normal, non-root user ID.

1. Run minishift setup-cdk

Run minishift setup-cdk to setup the components needed to run CDK on your system. By default, minishift setup-cdk places CDK content in ~/.minishift.

$ minishift setup-cdk
Setting up CDK 3 on host using '/home/user/.minishift' as Minishift's home directory
Copying minishift-rhel7.iso to '/home/user/.minishift/cache/iso/minishift-rhel7.iso'
Copying oc to '/home/user/.minishift/cache/oc/v3.11.43/linux/oc'
Creating configuration file '/home/user/.minishift/config/config.json'
Creating marker file '/home/user/.minishift/cdk'
Default add-ons anyuid, admin-user, xpaas, registry-route, che, htpasswd-identity-provider, eap-cd installed
Default add-ons anyuid, admin-user, xpaas enabled
CDK 3 setup complete.

Note: If you would like to use a different directory see Environment Variables in the CDK Getting Started Guide.

If you delete ~/.minishift, you will need to run this step again.

2. Add your Red Hat Developer Program username to your environment

The VM needs to register with Red Hat to download and build container images. Add your Red Hat Developer Program username to your environment to avoid the need to enter it each time you start minishift. Your password is stored in the system keystore, so after you log in once, the CDK simply retrieves the password from the keystore.

The following command sets the username in the environment of the running shell. When a new command shell is started you will need to enter this command again.

$ export MINISHIFT_USERNAME='<RED_HAT_USERNAME>'

Optional: Permanently storing the username

The following command adds your username to your profile so it will be set on future logins. 

$ echo export MINISHIFT_USERNAME=$MINISHIFT_USERNAME >> ~/.bashrc

3. Build your first app

10 minutes

Body

Start minishift

You are now ready to start the CDK. The minishift start command starts a Red Hat Enterprise Linux VM with an OpenShift cluster running inside.

Note: By this point you should have your hypervisor configured as per the hypervisor prerequisites in step 1:

  • If you are using KVM, make sure you've installed the docker-machine-kvm driver.
  • If you are using VirtualBox, configure minishift to use VirtualBox with minishift config set vm-driver virtualbox

You should have also completed the CDK setup from step 2.

Run minishift start

Start the VM with minishift start:

$ minishift start
-- Starting profile 'minishift'
...
-- Minishift VM will be configured with ...
   Memory:    4 GB
   vCPUs :    2
   Disk size: 20 GB
-- Starting Minishift VM .......................... OK
-- Registering machine using subscription-manager
   Registration in progress ..................... OK [42s]
...
Extracting
Image pull complete
OpenShift server started.

The server is accessible via web console at:
    https://192.168.42.60:8443

You are logged in as:
    User:     developer
    Password: 

To login as administrator:
    oc login -u system:admin
...

After minishift start completes, make a note of:

  • The URL for the OpenShift cluster. Note: the IP address may change when you restart the CDK.
  • The developer username.
  • The admin username and default password.

To check that everything is working and view the OpenShift console use the command:

$ minishift console

This launches the URL listed above (for example: https://192.168.42.60:8443) with your default browser.  You will likely get a security warning from the browser about the certificate being from an unknown certificate authority. This is expected. You need to accept the certificate to proceed.

To open the console in another browser, you can get the URL of the console with the following command:

$ minishift console --url

Login to OpenShift using developer as the username.  Enter any text for the developer password.

Add the directory containing oc to your PATH

After the minishift VM has been started, you need to add oc to your PATH. The oc command must match the version of the OpenShift cluster that is running inside of the Red Hat VM. The following command sets the correct version dynamically by running minishift oc-env and parsing the output.

$ eval $(minishift oc-env)

Stopping minishift and the CDK life-cycle

You can stop the minishift VM with the command:

$ minishift stop

You can restart it again with:

$ minishift start

If necessary, you can delete the VM to start over with a clean VM using:

$ minishift delete

You won't need to run minishift setup-cdk again unless you delete the contents of ~/.minishift. You can learn more in the CDK life-cycle section of the CDK Getting Started Guide.

Build your first app

Follow these instructions to create and deploy a Node.js "Hello, World" application on OpenShift running inside the CDK using the OpenShift Web Console.

Where to go next?

Build Something Today

Let's walk through everything you need to build your first application.

Download