Creating and deploying a component to the disconnected cluster

After you push the init image to a cluster with a mirrored registry, you must mirror a supported builder image for your application with the oc tool, overwrite the mirror registry using the environment variable, and then create your component.

Prerequisites

Mirroring a supported builder image

To use npm packages for Node.js dependencies and Maven packages for Java dependencies and configure a runtime environment for your application, you must mirror a respective builder image from the mirror registry.

Procedure

  1. Verify that the required images tag is not imported:

    1. $ oc describe is nodejs -n openshift

    Example output

    1. Name: nodejs
    2. Namespace: openshift
    3. [...]
    4. 10
    5. tagged from <mirror-registry>:<port>/rhoar-nodejs/nodejs-10
    6. prefer registry pullthrough when referencing this tag
    7. Build and run Node.js 10 applications on RHEL 7. For more information about using this builder image, including OpenShift considerations, see https://github.com/nodeshift/centos7-s2i-nodejs.
    8. Tags: builder, nodejs, hidden
    9. Example Repo: https://github.com/sclorg/nodejs-ex.git
    10. ! error: Import failed (NotFound): dockerimage.image.openshift.io "<mirror-registry>:<port>/rhoar-nodejs/nodejs-10:latest" not found
    11. About an hour ago
    12. 10-SCL (latest)
    13. tagged from <mirror-registry>:<port>/rhscl/nodejs-10-rhel7
    14. prefer registry pullthrough when referencing this tag
    15. Build and run Node.js 10 applications on RHEL 7. For more information about using this builder image, including OpenShift considerations, see https://github.com/nodeshift/centos7-s2i-nodejs.
    16. Tags: builder, nodejs
    17. Example Repo: https://github.com/sclorg/nodejs-ex.git
    18. ! error: Import failed (NotFound): dockerimage.image.openshift.io "<mirror-registry>:<port>/rhscl/nodejs-10-rhel7:latest" not found
    19. About an hour ago
    20. [...]
  2. Mirror the supported image tag to the private registry:

    1. $ oc image mirror registry.access.redhat.com/rhscl/nodejs-10-rhel7:<tag> <private_registry>/rhscl/nodejs-10-rhel7:<tag>
  3. Import the image:

    1. $ oc tag <mirror-registry>:<port>/rhscl/nodejs-10-rhel7:<tag> nodejs-10-rhel7:latest --scheduled

    You must periodically re-import the image. The --scheduled flag enables automatic re-import of the image.

  4. Verify that the images with the given tag have been imported:

    1. $ oc describe is nodejs -n openshift

    Example output

    1. Name: nodejs
    2. [...]
    3. 10-SCL (latest)
    4. tagged from <mirror-registry>:<port>/rhscl/nodejs-10-rhel7
    5. prefer registry pullthrough when referencing this tag
    6. Build and run Node.js 10 applications on RHEL 7. For more information about using this builder image, including OpenShift considerations, see https://github.com/nodeshift/centos7-s2i-nodejs.
    7. Tags: builder, nodejs
    8. Example Repo: https://github.com/sclorg/nodejs-ex.git
    9. * <mirror-registry>:<port>/rhscl/nodejs-10-rhel7@sha256:d669ecbc11ac88293de50219dae8619832c6a0f5b04883b480e073590fab7c54
    10. 3 minutes ago
    11. [...]

Overwriting the mirror registry

To download npm packages for Node.js dependencies and Maven packages for Java dependencies from a private mirror registry, you must create and configure a mirror npm or Maven registry on the cluster. You can then overwrite the mirror registry on an existing component or when you create a new component.

Procedure

  • To overwrite the mirror registry on an existing component:

    1. $ odo config set --env NPM_MIRROR=<npm_mirror_registry>
  • To overwrite the mirror registry when creating a component:

    1. $ odo component create nodejs --env NPM_MIRROR=<npm_mirror_registry>

Creating a Node.js application with odo

To create a Node.js component, download the Node.js application and push the source code to your cluster with odo.

Procedure

  1. Change the current directory to the directory with your application:

    1. $ cd <directory_name>
  2. Add a component of the type Node.js to your application:

    1. $ odo create nodejs
    By default, the latest image is used. You can also explicitly specify an image version by using odo create openshift/nodejs:8.
  3. Push the initial source code to the component:

    1. $ odo push

    Your component is now deployed to OKD.

  4. Create a URL and add an entry in the local configuration file as follows:

    1. $ odo url create --port 8080
  5. Push the changes. This creates a URL on the cluster.

    1. $ odo push
  6. List the URLs to check the desired URL for the component.

    1. $ odo url list
  7. View your deployed application using the generated URL.

    1. $ curl <url>