---
title: "Tutorial: Deploying an application by using the web console"
---

# Tutorial: Deploying an application by using the web console {#dev-app-web-console}

To learn how to stand up an application on OpenShift Container Platform by using the web console, follow the provided tutorial. In this tutorial, you will deploy the services that are required for an application that displays a map of national parks across the world.

To complete this tutorial, you will perform the following steps:

1. [Create a project for the application](/openshift-docs-markdown/tutorials/dev-app-web-console#getting-started-web-console-creating-new-project_dev-app-web-console).

   This step allows your application to be isolated from other cluster user’s workloads.
2. [Grant view permissions](/openshift-docs-markdown/tutorials/dev-app-web-console#getting-started-web-console-granting-permissions_dev-app-web-console).

   This step grants `view` permissions to interact with the OpenShift API to help discover services and other resources running within the project.
3. [Deploy the front-end application](/openshift-docs-markdown/tutorials/dev-app-web-console#getting-started-web-console-deploying-first-image_dev-app-web-console).

   This step deploys the `parksmap` front-end application, exposes it externally, and scales it up to two instances.
4. [Deploy the back-end application](/openshift-docs-markdown/tutorials/dev-app-web-console#getting-started-web-console-deploying-python-app_dev-app-web-console).

   This step deploys the `nationalparks` back-end application and exposes it externally.
5. [Deploy the database application](/openshift-docs-markdown/tutorials/dev-app-web-console#getting-started-web-console-connecting-database_dev-app-web-console).

   This step deploys the `mongodb-nationalparks` MongoDB database, loads data into the database, and sets up the necessary credentials to access the database.

After you complete these steps, you can [view the national parks application in a web browser](/openshift-docs-markdown/tutorials/dev-app-web-console#getting-started-web-console-view_dev-app-web-console).

## Prerequisites {#prerequisites_dev-app-web-console}

Before you start this tutorial, ensure that you have the following required prerequisites:

- You have access to a test OpenShift Container Platform cluster.

  If your organization does not have a cluster to test on, you can request access to the [Developer Sandbox](https://developers.redhat.com/developer-sandbox) to get a trial of OpenShift Container Platform.
- You have the appropriate permissions, such as the `cluster-admin` [cluster role](/openshift-docs-markdown/authentication/using-rbac#viewing-cluster-roles_using-rbac), to create a project and applications within it.

  If you do not have the required permissions, contact your cluster administrator. You need the `self-provisioner` role to create a project and the `admin` role on the project to modify resources in that project.

  If you are using Developer Sandbox, a project is created for you with the required permissions.
- You have [logged in to the OpenShift Container Platform web console](/openshift-docs-markdown/web_console/web-console#web-console-overview).

## Creating a project {#getting-started-web-console-creating-new-project_dev-app-web-console}

Create a new project to contain all required resources and application components for the tutorial.

A *project* enables a community of users to organize and manage their content in isolation. Projects are OpenShift Container Platform extensions to Kubernetes namespaces. Projects have additional features that enable user self-provisioning. Each project has its own set of objects, policies, constraints, and service accounts.

Cluster administrators can allow developers to create their own projects. In most cases, you automatically have access to your own projects. Administrators can grant access to other projects as needed.

This procedure creates a new project called `user-getting-started`. You will use this project throughout the rest of this tutorial.

> [!IMPORTANT]
> If you are using Developer Sandbox to complete this tutorial, skip this procedure. A project has already been created for you.

**Prerequisites**

- You have logged in to the OpenShift Container Platform web console.

**Procedure**

1. Navigate to **Home** → **Projects**.
2. Click **Create Project**.
3. In the **Name** field, enter `user-getting-started`.
4. Click **Create**.

**Additional resources**
{._additional-resources}

- [Viewing a project by using the web console](/openshift-docs-markdown/applications/projects/working-with-projects#viewing-a-project-using-the-web-console_projects)

## Granting view permissions {#getting-started-web-console-granting-permissions_dev-app-web-console}

Configure the necessary permissions for the application to access the required cluster resources.

OpenShift Container Platform automatically creates several service accounts in every project. The `default` service account takes responsibility for running the pods. OpenShift Container Platform uses and injects this service account into every pod that launches.

By default, the `default` service account has limited permissions to interact with the OpenShift API.

As a requirement of the application, you must assign the `view` role to the `default` service account to allow it to communicate with the OpenShift API to learn about pods, services, and resources within the project.

**Prerequisites**

- You have `cluster-admin` or project-level `admin` privileges.

**Procedure**

1. Navigate to **User Management** → **RoleBindings**.
2. Click **Create binding**.
3. In the **Name** field, enter `sa-user-account`.
4. In the **Namespace** field, search for and select `user-getting-started`.

   > [!IMPORTANT]
   > If you are using a different project, select the name of your project.
5. In the **Role name** field, search for and select `view`.
6. Under **Subject**, select `ServiceAccount`.
7. In the **Subject namespace** field, search for and select `user-getting-started`.

   > [!IMPORTANT]
   > If you are using a different project, select the name of your project.
8. In the **Subject name** field, enter `default`.
9. Click **Create**.

**Additional resources**
{._additional-resources}

- [RBAC overview](/openshift-docs-markdown/authentication/using-rbac#authorization-overview_using-rbac)

## Deploying the front-end application {#getting-started-web-console-deploying-first-image_dev-app-web-console}

Deploy the front-end application that provides the external-facing web component for the tutorial.

The simplest way to deploy an application in OpenShift Container Platform is to run a provided container image.

The following procedure deploys `parksmap`, which is the front-end component of the `national-parks-app` application. The web application displays an interactive map of the locations of national parks across the world.

**Procedure**

1. From the **Quick create** (![fa-plus-circle](/openshift-docs-markdown/images/fa-plus-circle.png "Quick create menu")) menu in the upper right corner, click **Container images**.
2. Select **Image name from external registry** and enter `quay.io/openshiftroadshow/parksmap:latest`.
3. Scroll to the **General** section.
4. In the **Application name** field, enter `national-parks-app`.
5. In the **Name** field, ensure that the value is `parksmap`.
6. Scroll to the **Deploy** section.
7. In the **Resource type** field, ensure that **Deployment** is selected.
8. In the **Advanced options** section, ensure that **Create a route** is selected.

   By default, services running on OpenShift Container Platform are not accessible externally. You must select this option to create a route so that external clients can access your service.
9. Click the **Labels** hyperlink.

   The application code requires certain labels to be set.
10. Add the following labels to the text area and press Enter after each key/value pair:

    - `app=national-parks-app`
    - `component=parksmap`
    - `role=frontend`
11. Click **Create**.

    You are redirected to the **Topology** page where you can see the `parksmap` deployment in the `national-parks-app` application.

**Additional resources**
{._additional-resources}

- [Viewing the topology of your application](/openshift-docs-markdown/applications/odc-viewing-application-composition-using-topology-view#odc-viewing-application-topology_viewing-application-composition-using-topology-view)

### Viewing pod details {#getting-started-web-console-examining-pod_dev-app-web-console}

Retrieve detailed pod information to confirm the running status and resource configuration of the applications in this tutorial.

OpenShift Container Platform uses the Kubernetes concept of a *pod*, which is one or more containers deployed together on one host, and the smallest compute unit that can be defined, deployed, and managed. Pods are the rough equivalent of a machine instance, physical or virtual, to a container.

The **Overview** panel enables you to access many features of the `parksmap` deployment. The **Details** and **Resources** tabs enable you to scale application pods and check the status of builds, services, and routes.

**Prerequisites**

- You have deployed the `parksmap` front-end application.

**Procedure**

1. Navigate to **Workloads** → **Topology**.
2. Click the `parksmap` deployment in the `national-parks-app` application.

   **Figure 1. Parksmap deployment**

   ![Topology view of parksmap deployment](/openshift-docs-markdown/images/getting-started-examine-pod.png)

   This opens an overview panel with the following tabs:

   - **Details**: View details about your deployment, edit certain settings, and scale your deployment.
   - **Resources**: View details for the pods, services, and routes associated with your deployment.
   - **Observe**: View metrics and events for your deployment.
3. To view the logs for a pod, select the **Resources** tab and click **View logs** next to the `parksmap` pod.

**Additional resources**
{._additional-resources}

- [Interacting with applications and components](/openshift-docs-markdown/applications/odc-viewing-application-composition-using-topology-view#odc-interacting-with-applications-and-components_viewing-application-composition-using-topology-view)
- [Scaling application pods and checking builds and routes](/openshift-docs-markdown/applications/odc-viewing-application-composition-using-topology-view#odc-scaling-application-pods-and-checking-builds-and-routes_viewing-application-composition-using-topology-view)
- [Labels and annotations used for the Topology view](/openshift-docs-markdown/applications/odc-viewing-application-composition-using-topology-view#odc-labels-and-annotations-used-for-topology-view_viewing-application-composition-using-topology-view)

### Scaling up the application {#getting-started-web-console-scaling-app_dev-app-web-console}

Scale the application deployment up or down to meet workload demands.

In Kubernetes, a `Deployment` object defines how an application deploys. In most cases when you deploy an application, OpenShift Container Platform creates the `Pod`, `Service`, `ReplicaSet`, and `Deployment` resources for you.

When you deploy the `parksmap` image, a deployment resource is created. In this example, only one pod is deployed. You might want to scale up your application to keep up with user demand or to ensure that your application is always running even if one pod is down.

The following procedure scales the `parksmap` deployment to use two instances.

**Prerequisites**

- You have deployed the `parksmap` front-end application.

**Procedure**

1. Navigate to **Workloads** → **Topology** and click the `parksmap` deployment.
2. Select the **Details** tab.
3. Use the up arrow to scale the pod to two instances.

   **Figure 2. Scaling application**

   ![Scaling pod to two instances](/openshift-docs-markdown/images/getting-started-scaling-pod.png)

   > [!TIP]
   > You can use the down arrow to scale your deployment back down to one pod instance.

**Additional resources**
{._additional-resources}

- [Recommended practices for scaling the cluster](/openshift-docs-markdown/scalability_and_performance/recommended-performance-scale-practices/recommended-control-plane-practices#recommended-scale-practices_recommended-control-plane-practices)

## Deploying the back-end application {#getting-started-web-console-deploying-python-app_dev-app-web-console}

Deploy the back-end application that provides the service that queries the database to return the national park data required for your application.

The following procedure deploys `nationalparks`, which is the back-end component for the `national-parks-app` application. The Python application performs 2D geo-spatial queries against a MongoDB database to locate and return map coordinates of all national parks in the world.

**Prerequisites**

- You have deployed the `parksmap` front-end application.

**Procedure**

1. From the **Quick create** (![fa-plus-circle](/openshift-docs-markdown/images/fa-plus-circle.png "Quick create menu")) menu in the upper right corner, click **Import from Git**.
2. In the **Git Repo URL** field, enter `https://github.com/openshift-roadshow/nationalparks-py.git`.

   A builder image is automatically detected, but the import strategy defaults to Dockerfile instead of Python.
3. Change the import strategy:

   1. Click **Edit Import Strategy**.
   2. Select **Builder Image**.
   3. Select **Python**.
4. Scroll to the **General** section.
5. In the **Application** field, ensure that the value is `national-parks-app`.
6. In the **Name** field, enter `nationalparks`.
7. Scroll to the **Deploy** section.
8. In the **Resource type** field, ensure that **Deployment** is selected.
9. In the **Advanced options** section, ensure that **Create a route** is selected.

   By default, services running on OpenShift Container Platform are not accessible externally. You must select this option to create a route so that external clients can access your service.
10. Click the **Labels** hyperlink.

    The application code requires certain labels to be set.
11. Add the following labels to the text area and press Enter after each key/value pair:

    - `app=national-parks-app`
    - `component=nationalparks`
    - `role=backend`
    - `type=parksmap-backend`
12. Click **Create**.

    You are redirected to the **Topology** page where you can see the `nationalparks` deployment in the `national-parks-app` application.

**Verification**

1. Navigate to **Workloads** → **Topology**.
2. Click the `nationalparks` deployment in the `national-parks-app` application.
3. Click the **Resources** tab.

   Wait for the build to complete successfully.

**Additional resources**
{._additional-resources}

- [Adding services to your application](/openshift-docs-markdown/applications/odc-viewing-application-composition-using-topology-view#odc-adding-services-to-your-application_viewing-application-composition-using-topology-view)
- [Importing a codebase from Git to create an application](/openshift-docs-markdown/applications/creating_applications/odc-creating-applications-using-developer-perspective#odc-importing-codebase-from-git-to-create-application_odc-creating-applications-using-developer-perspective)

## Deploying the database application {#getting-started-web-console-connecting-database_dev-app-web-console}

Deploy a MongoDB database application to contain the information that your application requires. For this tutorial, you will deploy a database application called `mongodb-nationalparks` that holds the national park location information.

**Prerequisites**

- You have deployed the `parksmap` front-end application.
- You have deployed the `nationalparks` back-end application.

**Procedure**

1. From the **Quick create** (![fa-plus-circle](/openshift-docs-markdown/images/fa-plus-circle.png "Quick create menu")) menu in the upper right corner, click **Container images**.
2. Select **Image name from external registry** and enter `registry.redhat.io/rhmap47/mongodb`.
3. In the **Runtime icon** field, search for and select `mongodb`.
4. Scroll to the **General** section.
5. In the **Application name** field, enter `national-parks-app`.
6. In the **Name** field, enter `mongodb-nationalparks`.
7. Scroll to the **Deploy** section.
8. In the **Resource type** field, ensure that **Deployment** is selected.
9. Click **Show advanced Deployment option**.
10. Under **Environment variables (runtime only)**, add the following names and values:

    **Environment variable names and values**

    | Name | Value |
    | --- | --- |
    | `MONGODB_USER` | `mongodb` |
    | `MONGODB_PASSWORD` | `mongodb` |
    | `MONGODB_DATABASE` | `mongodb` |
    | `MONGODB_ADMIN_PASSWORD` | `mongodb` |

    > [!TIP]
    > Click **Add value** to add each additional environment variable.
11. In the **Advanced options** section, clear **Create a route**.

    The database application does not need to be accessed externally, so a route is not required.
12. Click **Create**.

    You are redirected to the **Topology** page where you can see the `mongodb-nationalparks` deployment in the `national-parks-app` application.

### Providing access to the database by creating a secret {#getting-started-web-console-creating-secret_dev-app-web-console}

Create a `Secret` resource to securely provide the back-end application with the sensitive database connection credentials.

The `nationalparks` application needs information, such as the database name, username, and passwords, to access the MongoDB database. However, because this information is sensitive, you should not store it directly in the pod.

You can use a *secret* to store sensitive information, and share that secret with workloads.

`Secret` objects provide a mechanism to hold sensitive information such as passwords, OpenShift Container Platform client configuration files, and private source repository credentials. Secrets decouple sensitive content from the pods. You can mount secrets into containers by using a volume plugin or by passing the secret in as an environment variable. The system can then use secrets to provide the pod with the sensitive information.

The following procedure creates the `nationalparks-mongodb-parameters` secret and mounts it to the `nationalparks` workload.

**Prerequisites**

- You have deployed the `nationalparks` back-end application.
- You have deployed the `mongodb-nationalparks` database application.

**Procedure**

1. Navigate to **Workloads** → **Secrets**.
2. Click **Create** → **Key/value secret**.
3. In the **Secret name** field, enter `nationalparks-mongodb-parameters`.
4. Enter the following values for **Key** and **Value**:

   **Secret keys and values**

   | Key | Value |
   | --- | --- |
   | `DATABASE_SERVICE_NAME` | `mongodb-nationalparks` |
   | `MONGODB_USER` | `mongodb` |
   | `MONGODB_PASSWORD` | `mongodb` |
   | `MONGODB_DATABASE` | `mongodb` |
   | `MONGODB_ADMIN_PASSWORD` | `mongodb` |

   > [!TIP]
   > Click **Add key/value** to add each additional key/value pair.
5. Click **Create**.
6. Click **Add Secret to workload**.
7. From the **Add this secret to workload** list, select `nationalparks`.
8. Click **Save**.

   This change in configuration triggers a new rollout of the `nationalparks` deployment with the environment variables properly injected.

**Additional resources**
{._additional-resources}

- [Understanding secrets](/openshift-docs-markdown/nodes/pods/nodes-pods-secrets#nodes-pods-secrets-about_nodes-pods-secrets)

### Loading data into the database {#getting-started-web-console-load-data-output_dev-app-web-console}

After you have deployed the `mongodb-nationalparks` database application, load the national park location information into the database.

**Prerequisites**

- You have deployed the `nationalparks` back-end application.
- You have deployed the `mongodb-nationalparks` database application.

**Procedure**

1. Navigate to **Workloads** → **Topology**.
2. Click the `nationalparks` deployment and select the **Resources** tab.
3. Copy the **Location** URL from your route.
4. Paste the URL into your web browser and add the following at the end of the URL:

   ```text
   /ws/data/load
   ```

   For example:

   ```text
   https://nationalparks-user-getting-started.apps.cluster.example.com/ws/data/load
   ```

   ```text {title="Example output"}
   Items inserted in database: 2893
   ```

## Viewing the application in a web browser {#getting-started-web-console-view_dev-app-web-console}

After you have deployed the necessary applications and loaded data into the database, you are now ready view your application through a browser. You can access the application by opening the URL for the front-end application.

**Prerequisites**

- You have deployed the `parksmap` front-end application.
- You have deployed the `nationalparks` back-end application.
- You have deployed the `mongodb-nationalparks` database application.
- You have loaded the data into the `mongodb-nationalparks` database.

**Procedure**

1. Navigate to **Workloads** → **Topology**.
2. Click the **Open URL** link from the `parksmap` deployment.

   **Figure 3. National parks across the world**

   ![Opening the URL for the parksmap deployment](/openshift-docs-markdown/images/getting-started-parksmap-url.png)
3. Verify that your web browser displays a map of the national parks across the world.

   **Figure 4. National parks across the world**

   ![Map of the national parks across the world](/openshift-docs-markdown/images/getting-started-map-national-parks.png)

   If you allow the application to access your location, the map will center on your location.
