Deploying a Flogo App to Red Hat OpenShift

Before you begin
  • Ensure that you have a Red Hat Openshift account and that the Red Hat OpenShift environment is set up to deploy the app.
  • Ensure that the Red Hat OpenShift CLI is installed on your machine.
  • Ensure that the image of the Flogo app is pushed to the Red Hat Openshift internal registry or any other public registry such as Docker Hub.
    Procedure
  1. Build a docker image for your app. You can build a docker image in one of the following ways.
    Using the UI:
    1. Build a docker image.
    2. Tag the generated docker image from the command line: docker tag <image-id> <app-name>:<version> The app tag must be in the format <app-name>:<app-version>
    From a Linux binary:
    1. Build a Linux binary using the Linux/amd64 option. For more information, see Building the App.
    2. Provide execute permission to the app binary: chmod +x <app-binary>
    3. Create a docker file. For example:
      FROM <OS-version>  # for example, FROM alpine:3.7
      WORKDIR /app
      ADD <app-binary> <path-to-app-in-docker-container> # for example, ADD flogo-rest-linux_amd64 /app/flogo-rest
      CMD ["/app/flogo-rest"]
    4. Build the docker image using the docker file. Run the following command:
      docker build -t <app-tag> -f <path-to-Dockerfile> .
      The app tag must be in the format <app-name>:<app-version>
    From the CLI:
    1. Export your app as a JSON file (for example, flogo-rest.json) by clicking Export app on the flow details page.
    2. Build a Docker image containing the app using the builder command from the CLI. Open a command prompt and change directory to <FLOGO_HOME>/<version>/bin and run:
      builder-<platform>_<arch> build -f <path-to-the.json-file> -docker -n <docker_image_name>:<tag>
      For example:

      builder_linux_amd64 build -f flogo-rest.json -docker -n flogo-rest:v1

      For more information on the builder command, refer to the section, Builder command.

  2. Run the docker image locally to verify that everything is fine:
    docker run -it -p 9999:9999 <app-tag>
  3. Authenticate docker with the container registry where you want to push the docker image.
  4. Tag the docker image. Run:
    docker tag <app-tag> <CONTAINER_REGISTRY_URI>/<app-tag>
    The app tag must be in the format <app-name>:<app-version>
  5. Push the local docker image to the container registry by running the following command:
    docker push <CONTAINER_REGISTRY_URI>/<app-tag>

    Note: Refer to the documentation for your container registry for the exact commands to authenticate docker, tag docker image, and push it to the registry.

  6. Login to Openshift from command line:

    oc login --token=<Your token> --server=https://<host address>:<port>

    For example:

    oc login --token=<Your token> --server=https://api.ca-central-1.starter.openshift-online.com:6443
  7. Create a project in Red Hat OpenShift:

    oc new-project <PROJECT_NAME>

  8. Deploy the app on Red Hat Openshift using a YAML file. For a sample YAML file, see Sample YAML File: Red Hat OpenShift.
    oc create -f <YAML filename>
  9. To get information about pods, run the following command:
    oc get pods

    The following is a sample output of the command:

  10. To get the logs of a particular pod, run the following command:
    oc logs <pod name>

    The following is a sample output of the command:

  11. To access the endpoint of an app, run the following command:

    oc get svc -o wide

    The following is a sample output of the command:

  12. From the output, note the external IP and port. Access the endpoint using the following URL:
    http:<external IP>:<port>/<resource_context_path>