:_mod-docs-content-type: ASSEMBLY
[id="dev-app-cli"]
= Tutorial: Deploying an application by using the CLI
include::_attributes/common-attributes.adoc[]
:context: dev-app-cli

toc::[]

[role="_abstract"]
To learn how to stand up an application on {product-title} by using the {oc-first}, 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:

. xref:../tutorials/dev-app-cli.adoc#getting-started-cli-creating-new-project_dev-app-cli[Create a project for the application].
+
This step allows your application to be isolated from other cluster user's workloads.

. xref:../tutorials/dev-app-cli.adoc#getting-started-cli-granting-permissions_dev-app-cli[Grant view permissions].
+
This step grants `view` permissions to interact with the OpenShift API to help discover services and other resources running within the project.

. xref:../tutorials/dev-app-cli.adoc#getting-started-cli-deploying-first-image_dev-app-cli[Deploy the front-end application].
+
This step deploys the `parksmap` front-end application, exposes it externally, and scales it up to two instances.

. xref:../tutorials/dev-app-cli.adoc#getting-started-cli-deploying-python-app_dev-app-cli[Deploy the back-end application].
+
This step deploys the `nationalparks` back-end application and exposes it externally.

. xref:../tutorials/dev-app-cli.adoc#getting-started-cli-connecting-database_dev-app-cli[Deploy the database application].
+
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 xref:../tutorials/dev-app-cli.adoc#getting-started-cli-view_dev-app-cli[view the national parks application in a web browser].

[id="prerequisites_{context}"]
== Prerequisites

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

* You have installed the xref:../cli_reference/openshift_cli/getting-started-cli.adoc#installing-openshift-cli[{oc-first}].
* You have access to a test {product-title} cluster.
+
If your organization does not have a cluster to test on, you can request access to the link:https://developers.redhat.com/developer-sandbox[Developer Sandbox] to get a trial of {product-title}.

* You have the appropriate permissions, such as the `cluster-admin` xref:../authentication/using-rbac.adoc#viewing-cluster-roles_using-rbac[cluster role], 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 xref:../cli_reference/openshift_cli/getting-started-cli.adoc#cli-logging-in_cli-developer-commands[logged in to your cluster by using the {oc-first}].

// Creating a new project
include::modules/getting-started-cli-creating-new-project.adoc[leveloffset=+1]

[role="_additional-resources"]
.Additional resources
* xref:../cli_reference/openshift_cli/developer-cli-commands.adoc#oc-new-project[oc new-project]

// Granting view permissions
include::modules/getting-started-cli-granting-permissions.adoc[leveloffset=+1]

[role="_additional-resources"]
.Additional resources
* xref:../authentication/using-rbac.adoc#authorization-overview_using-rbac[RBAC overview]
* xref:../cli_reference/openshift_cli/administrator-cli-commands.adoc#oc-adm-policy-add-role-to-user[oc adm policy add-role-to-user]

// Deploying the front-end application
include::modules/getting-started-cli-deploying-first-image.adoc[leveloffset=+1]

[role="_additional-resources"]
.Additional resources
* xref:../cli_reference/openshift_cli/developer-cli-commands.adoc#oc-new-app[oc new-app]

// Exposing the front-end service
include::modules/getting-started-cli-creating-route.adoc[leveloffset=+2]

[role="_additional-resources"]
.Additional resources
* xref:../cli_reference/openshift_cli/developer-cli-commands.adoc#oc-create-route-edge[oc create route edge]
* xref:../cli_reference/openshift_cli/developer-cli-commands.adoc#oc-get[oc get]

// Viewing pod details
include::modules/getting-started-cli-examining-pod.adoc[leveloffset=+2]

[role="_additional-resources"]
.Additional resources
* xref:../cli_reference/openshift_cli/developer-cli-commands.adoc#oc-describe[oc describe]
* xref:../cli_reference/openshift_cli/developer-cli-commands.adoc#oc-get[oc get]
* xref:../cli_reference/openshift_cli/getting-started-cli.adoc#viewing-pods[Viewing pods]
* xref:../cli_reference/openshift_cli/getting-started-cli.adoc#viewing-pod-logs[Viewing pod logs]

// Scaling up the deployment
include::modules/getting-started-cli-scaling-app.adoc[leveloffset=+2]

[role="_additional-resources"]
.Additional resources
* xref:../cli_reference/openshift_cli/developer-cli-commands.adoc#oc-scale[oc scale]

// Deploying the back-end application
include::modules/getting-started-cli-deploying-python-app.adoc[leveloffset=+1]

// Exposing the back-end service
include::modules/getting-started-cli-creating-route-backend.adoc[leveloffset=+2]

[role="_additional-resources"]
.Additional resources
* xref:../cli_reference/openshift_cli/developer-cli-commands.adoc#oc-label[oc label]

// Deploying the database application
include::modules/getting-started-cli-connecting-a-database.adoc[leveloffset=+1]

// Providing access to the database by creating a secret
include::modules/getting-started-cli-creating-secret.adoc[leveloffset=+2]

[role="_additional-resources"]
.Additional resources
* xref:../nodes/pods/nodes-pods-secrets.adoc#nodes-pods-secrets-about_nodes-pods-secrets[Understanding secrets]
* xref:../cli_reference/openshift_cli/developer-cli-commands.adoc#oc-create-secret-generic[oc create secret generic]
* xref:../cli_reference/openshift_cli/developer-cli-commands.adoc#oc-set-env[oc set env]
* xref:../cli_reference/openshift_cli/developer-cli-commands.adoc#oc-rollout-status[oc rollout status]

// Loading data into the database
include::modules/getting-started-cli-load-data-output.adoc[leveloffset=+2]

[role="_additional-resources"]
.Additional resources
* xref:../cli_reference/openshift_cli/developer-cli-commands.adoc#oc-exec[oc exec]

// Viewing the application in a web browser
include::modules/getting-started-cli-view.adoc[leveloffset=+1]

// TODO: consider whether to pull down the optional sections (viewing pod, scaling) into a separate bucket below
////
== Optional: Continuing to explore

// Investigating more
// Continuing to explore
// not just exploring. you're messing w/ it, testing. doing things.

Now that your application is successfully running, you can continue exploring the following aspects:

// TODO: xrefs

* Viewing pod details for your deployments
* Scaling up your deployments

// Viewing pod details
include::modules/getting-started-cli-examining-pod.adoc[leveloffset=+2]

[role="_additional-resources"]
.Additional resources
* xref:../cli_reference/openshift_cli/developer-cli-commands.adoc#oc-describe[oc describe]
* xref:../cli_reference/openshift_cli/developer-cli-commands.adoc#oc-get[oc get]
* xref:../cli_reference/openshift_cli/getting-started-cli.adoc#viewing-pods[Viewing pods]
* xref:../cli_reference/openshift_cli/getting-started-cli.adoc#viewing-pod-logs[Viewing pod logs]

// Scaling up the deployment
include::modules/getting-started-cli-scaling-app.adoc[leveloffset=+2]

[role="_additional-resources"]
.Additional resources
* xref:../cli_reference/openshift_cli/developer-cli-commands.adoc#oc-scale[oc scale]

////
