Skip to main contentIBM Garage for Cloud

Deploying an App

Create a sample application and deploy it with a CI pipeline

Overview

The Developer 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 Code Patterns. 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 Kubernetes or Red Hat OpenShift.

Note: The instructions provided below lean heavily on the use of the IGC CLI to both show how the CLI works in context and to streamline the process (the reason for creating the CLI in the first place). However, the use of the CLI is in no way required to use the Cloud-Native Toolkit. If you would prefer to work through these instructions without the use of the CLI, we have provided the equivalent manual steps for each command on the Cloud Native Toolkit CLI page.

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:

    kubectl 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.

igc 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 Code Patterns 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:

    igc dashboard

4. Create your app in Git

  1. From the Developer Dashboard, click on Code Patterns 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 Code Pattern 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. Next, clone it to your local machine.
  2. Click on Clone or download
  3. Copy the clone SSH link, and use the git clone command to clone it to your developer desktop machine.
    git clone git@github.com:bwoolf1/stockbffnode.git
  4. 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 Python.

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 Developer Environment supports both Tekton and Jenkins for continuous integration.

  1. Start the process to create a pipeline

    igc pipeline
  2. 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

  3. When registering a Tekton pipeline, you will also be prompted to select which pipeline you want to use for your application

  4. When registering a Jenkins pipeline, the CLI will also set up a webhook with the git host

    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 (IKS, OCP 3.11, or OCP 4.3).

    1. Open the OpenShift Web Console from the Developer Cluster instance

      OpenShift
    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

    1. Open the OpenShift Web Console from the Developer Cluster instance

      OpenShift
    2. From menu on the left switch to the Developer mode

    3. Select dev projectthat 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

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 manspace context

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

    igc 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
  2. Change to the Developer view
  3. Click on Topology menu
  4. Click on your application deployment in the topology view
  5. Click on 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 code pattern templates and explore the environment to get familiar with it. 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.