1
0
mirror of https://github.com/openshift/openshift-docs.git synced 2026-02-05 21:46:22 +01:00
Files
openshift-docs/modules/odc-importing-codebase-from-git-to-create-application.adoc
2024-03-05 17:23:02 +00:00

117 lines
8.1 KiB
Plaintext

// Module included in the following assemblies:
//
// * applications/creating_applications/odc-creating-applications-using-developer-perspective.adoc
:_mod-docs-content-type: PROCEDURE
[id="odc-importing-codebase-from-git-to-create-application_{context}"]
= Importing a codebase from Git to create an application
[role="_abstract"]
You can use the *Developer* perspective to create, build, and deploy an application on {product-title} using an existing codebase in GitHub.
The following procedure walks you through the *From Git* option in the *Developer* perspective to create an application.
.Procedure
. In the *+Add* view, click *From Git* in the *Git Repository* tile to see the *Import from git* form.
. In the *Git* section, enter the Git repository URL for the codebase you want to use to create an application. For example, enter the URL of this sample Node.js application `\https://github.com/sclorg/nodejs-ex`. The URL is then validated.
. Optional: You can click *Show Advanced Git Options* to add details such as:
* *Git Reference* to point to code in a specific branch, tag, or commit to be used to build the application.
* *Context Dir* to specify the subdirectory for the application source code you want to use to build the application.
* *Source Secret* to create a *Secret Name* with credentials for pulling your source code from a private repository.
. Optional: You can import a `Devfile`, a `Dockerfile`, `Builder Image`, or a `Serverless Function` through your Git repository to further customize your deployment.
* If your Git repository contains a `Devfile`, a `Dockerfile`, a `Builder Image`, or a `func.yaml`, it is automatically detected and populated on the respective path fields.
* If a `Devfile`, a `Dockerfile`, or a `Builder Image` are detected in the same repository, the `Devfile` is selected by default.
* If `func.yaml` is detected in the Git repository, the *Import Strategy* changes to `Serverless Function`.
* Alternatively, you can create a serverless function by clicking *Create Serverless function* in the *+Add* view using the Git repository URL.
* To edit the file import type and select a different strategy, click *Edit import strategy* option.
* If multiple `Devfiles`, a `Dockerfiles`, or a `Builder Images` are detected, to import a specific instance, specify the respective paths relative to the context directory.
. After the Git URL is validated, the recommended builder image is selected and marked with a star. If the builder image is not auto-detected, select a builder image. For the `https://github.com/sclorg/nodejs-ex` Git URL, by default the Node.js builder image is selected.
.. Optional: Use the *Builder Image Version* drop-down to specify a version.
.. Optional: Use the *Edit import strategy* to select a different strategy.
.. Optional: For the Node.js builder image, use the **Run command** field to override the command to run the application.
. In the *General* section:
.. In the *Application* field, enter a unique name for the application grouping, for example, `myapp`. Ensure that the application name is unique in a namespace.
.. The *Name* field to identify the resources created for this application is automatically populated based on the Git repository URL if there are no existing applications. If there are existing applications, you can choose to deploy the component within an existing application, create a new application, or keep the component unassigned.
+
[NOTE]
====
The resource name must be unique in a namespace. Modify the resource name if you get an error.
====
. In the *Resources* section, select:
* *Deployment*, to create an application in plain Kubernetes style.
* *Deployment Config*, to create an {product-title} style application.
ifndef::openshift-rosa,openshift-dedicated[]
* *Serverless Deployment*, to create a Knative service.
+
[NOTE]
====
To set the default resource preference for importing an application, go to *User Preferences* -> *Applications* -> *Resource type* field. The *Serverless Deployment* option is displayed in the *Import from Git* form only if the {ServerlessOperatorName} is installed in your cluster. The *Resources* section is not available while creating a serverless function. For further details, refer to the {ServerlessProductName} documentation.
====
endif::openshift-rosa,openshift-dedicated[]
. In the *Pipelines* section, select *Add Pipeline*, and then click *Show Pipeline Visualization* to see the pipeline for the application. A default pipeline is selected, but you can choose the pipeline you want from the list of available pipelines for the application.
+
[NOTE]
====
The *Add pipeline* checkbox is checked and *Configure PAC* is selected by default if the following criterias are fulfilled:
* Pipeline operator is installed
* `pipelines-as-code` is enabled
* `.tekton` directory is detected in the Git repository
====
. Add a webhook to your repository. If *Configure PAC* is checked and the GitHub App is set up, you can see the *Use GitHub App* and *Setup a webhook* options. If GitHub App is not set up, you can only see the *Setup a webhook* option:
.. Go to *Settings* -> *Webhooks* and click *Add webhook*.
.. Set the *Payload URL* to the Pipelines as Code controller public URL.
.. Select the content type as *application/json*.
.. Add a webhook secret and note it in an alternate location. With `openssl` installed on your local machine, generate a random secret.
.. Click *Let me select individual events* and select these events: *Commit comments*, *Issue comments*, *Pull request*, and *Pushes*.
.. Click *Add webhook*.
. Optional: In the *Advanced Options* section, the *Target port* and the *Create a route to the application* is selected by default so that you can access your application using a publicly available URL.
+
If your application does not expose its data on the default public port, 80, clear the check box, and set the target port number you want to expose.
. Optional: You can use the following advanced options to further customize your application:
include::snippets/routing-odc.adoc[]
ifndef::openshift-rosa,openshift-dedicated[]
include::snippets/serverless-domain-mapping-odc.adoc[]
endif::openshift-rosa,openshift-dedicated[]
Health Checks::
Click the *Health Checks* link to add Readiness, Liveness, and Startup probes to your application. All the probes have prepopulated default data; you can add the probes with the default data or customize it as required.
+
To customize the health probes:
+
* Click *Add Readiness Probe*, if required, modify the parameters to check if the container is ready to handle requests, and select the check mark to add the probe.
* Click *Add Liveness Probe*, if required, modify the parameters to check if a container is still running, and select the check mark to add the probe.
* Click *Add Startup Probe*, if required, modify the parameters to check if the application within the container has started, and select the check mark to add the probe.
+
For each of the probes, you can specify the request type - *HTTP GET*, *Container Command*, or *TCP Socket*, from the drop-down list. The form changes as per the selected request type. You can then modify the default values for the other parameters, such as the success and failure thresholds for the probe, number of seconds before performing the first probe after the container starts, frequency of the probe, and the timeout value.
Build Configuration and Deployment::
Click the *Build Configuration* and *Deployment* links to see the respective configuration options. Some options are selected by default; you can customize them further by adding the necessary triggers and environment variables.
+
For serverless applications, the *Deployment* option is not displayed as the Knative configuration resource maintains the desired state for your deployment instead of a `DeploymentConfig` resource.
include::snippets/scaling-odc.adoc[]
Resource Limit::
Click the *Resource Limit* link to set the amount of *CPU* and *Memory* resources a container is guaranteed or allowed to use when running.
Labels::
Click the *Labels* link to add custom labels to your application.
. Click *Create* to create the application and a success notification is displayed. You can see the build status of the application in the *Topology* view.