Skip to main contentIBM Garage for Cloud

Deploying an App

Create a sample application and deploy it with a CI pipeline

Overview

The environment supports end-to-end development and deployment of an application. The instructions below will show you how to do it.

You can create a new app using one of the Starter Kits. These have been created to include all the key components, configuration, and frameworks to get you started on creating the code you need for your solutions. The approach for getting started is exactly the same for an environment based on Red Hat OpenShift or Kubernetes.

This video demonstrates how to work through the steps to create an application and use a deployment pipeline to install it into your development cluster.

Play

1. Log into your Development Cluster from the command line

  1. Make sure you have installed all Prerequisites before continuing

  2. Open a terminal

  3. Log in to the development cluster’s CLI (Kubernetes or Red Hat OpenShift)

    To do so, navigate to your cluster in the IBM Cloud console, click on the Access tab, and follow the instructions to log in to the cluster from the command line

  4. You can test that you’re connected to the cluster with the following simple command:

    oc get pods -n tools

2. Create the development namespace

Before getting started, the development namespace/project needs to be created and prepared for the DevOps pipelines. This is something that would typically happen once at the beginning of a project as a development team is formed and assigned to the cluster. This step copies the common secrets and configMaps to your new namespace. This enables the pipelines to reference the values easily for you project.

oc sync {DEV_NAMESPACE} --dev

3. Open the Developer Dashboard

The Developer Dashboard makes it easy for you to navigate to the tools, including a section that allows you to select a set of preconfigured Starter Kits that make seeding your development project very easy.

  1. Open a browser and make sure you are logged into Github

  2. Open the dashboard by running the following command:

    oc dashboard

4. Create your app in Git

  1. From the Developer Dashboard, click on Starter Kits tab

  2. Pick one of the templates that is a good architectural fit for your application and the language and framework that you prefer to work with.

    Click on a Starter Kit Tile to create your app github repository from the template repository selected. You can also click on the Git Icon to browse the source template repository and click on the Template to create the template

  3. Owner: Select a validate GitHub organization that you are authorized to create repositories within or the one you were given for the shared cluster (See warning above)

    Repository name: Enter a valid name for you repo, GitHub will help with showing a green tick if it is valid (See warning above)

    Description: Describe your app

    Press Create repository from template

    Template

The new repository will be created in your selected organization.

5. Clone your code

  1. With the browser open to the newly created repository, click on Clone or download

  2. Copy the clone SSH link, and use the git clone command to clone it to your developer desktop machine.

    git clone git@github.com:{gitid}/stockbffnode.git
  3. Change into the cloned directory

    cd stockbffnode

6. Run the application locally

Most developers like to run the code natively in local development environment. To do so, follow the instructions listed in the README.md file to run the code locally. You may be required to install a specific runtime like Java, Node or Go.

  • If you want to quickly access your git repo you can run a helper command to open the git webpage.
    oc git

7. Set the namespace context

Before running these remainder of the instructions commands it is important to set the namespace/project context. (Notes: The kubernetes command will work for both openshift and kubernetes.)

oc project {DEV_NAMESPACE}

8. Register the App in a DevOps Pipeline

Up to this point you have the code in a GitHub repository and have cloned it to you local development environment. You now need to register the repository with the continuous integration pipeline. The environment supports both Tekton and Jenkins for continuous integration.

  1. Start the process to create a pipeline

    oc pipeline
  2. Select the pipeline type for OpenShift we recommend Tekton as its optimized for Kubernetes based environments.

  3. The first time a pipeline is registered in the namespace, the CLI will ask for a username and Personal Access Token for the Git repository that will be stored in a secret named git-credentials. It will also ask for the branch that should be used for the pipeline.

    Username: Enter your GitHub user id

    Personal Access Token: Paste your GitHub personal access token

    Branch: Press enter for the default git branch or type in another branch you want to register

  4. When registering a Tekton pipeline, you will also be prompted to select which pipeline you want to use for your application. Gradle is for Spring and Node is for Typescript based Starter Kits.

  5. After the pipeline has been created, the command will set up a webhook from the Git host to the pipeline event listener

    Note: If the webhook registration step fails it is likely because the Git credentials are incorrect or do not have enough permission in the repository.

    The pipeline will be registered in your development cluster.

9. View your application pipeline

The steps to view your registered pipeline will vary based on type of pipeline (Jenkins or Tekton) and container platform version.

    1. Open the OpenShift Web Console

      oc console

      OR

      IBM Cloud console
    2. From menu on the left switch to the Developer mode

    3. Select dev project that was used for the application pipeline registration

    4. In the left menu, select Pipelines

    You will see your application dev ops pipeline now starting to build and once completed will look like the image below.

    OpenShift
    1. Open the OpenShift Web Console

      oc console

      OR

      IBM Cloud console
    2. From the left-hand menu, select Builds -> Build Configs

    3. Select your project from the drop-down menu at the top

    4. The registered pipeline should appear in the list

10. Access the running app

Once the pipeline has completed successfully, the app will be deployed into the namespace used when registering the pipeline. To validate the app is running follow these steps:

Note: Be sure the namespace context is set correctly before running the following commands - set the namespace context

  1. Retrieve the app ingress endpoint using commands below in your terminal.

    oc endpoints
  2. From the endpoints listed, select the URL for the repo that was just deployed and press Enter to open that URL in a web browser and validate the application is working as expected

11. Locate the app in the web console

The build pipeline is configured to build the source code from the Git repository into a container image. This image is stored in the Image Registry. After that the image is deployed into the same namespace/project within development cluster where the pipeline ran and validated for its health. The steps below will walk through locating the installed application within the Web Console.

  1. Open the OpenShift web console
    oc console
  2. Change to the Developer view
  3. Click on Topology menu
  4. Click on your application deployment in the topology view
  5. Click on the Overview tab
  6. Increase the number of running pods
  7. Click Resource tab and then on the pod View Logs link
  8. You can see the running state of your application
Pods on OpenShift

Having reached this point, we recommend you repeat the process a few more times using different starter kits templates and explore the environment to get familiar. For more information about the tools used by the pipeline, check out the Guides

This completes the deployment of your app. The next step is to prepare for Continuous Delivery, Code Analysis, and Artifact Management.