Start working on exercise 6.

This commit is contained in:
2023-12-07 11:27:40 +13:00
parent 62fbf03aad
commit 6b85837712
10 changed files with 210 additions and 5 deletions

View File

@ -0,0 +1,53 @@
---
title: Deploying an application from source
exercise: 6
date: '2023-12-07'
tags: ['openshift','containers','kubernetes','s2i','shipwright']
draft: false
authors: ['default']
summary: "Exploring alternative deployment approaches."
---
Often as a team supporting applications on OpenShift the decision of which deployment method to use will be out of your hands instead be determined by the vendor, organisation or team producing the application in question.
However, for an interesting scenario let's explore the possibility of what we could do if there is no existing deployment tooling in place and all we are given is a codebase in a git repository.
This is where the concept of **Source to Image** or "s2i" comes in. OpenShift has built in support for building container images using source code from an existing repository. This is accomplished using the [source-to-image](https://github.com/openshift/source-to-image) project.
OpenShift runs the S2I process inside a special **Pod**, called a **Build Pod**, and thus builds are subject to quotas, limits, resource scheduling, and other aspects of OpenShift. A full discussion of S2I is beyond the scope of this class, but you can find more information about it in the [OpenShift S2I documentation](https://docs.openshift.com/container-platform/4.14/openshift_images/create-images.html).
## 6.1 - Starting a source to image build
Deploying an application via an **Source to Image** is straightforward. Let's try it out.
Start in the **+Add** view of the **Developer** perspective.
Click **Import from Git** under the **Git Repository** tile.
**Source to Image** supports a number of popular programming languages as the source. For this example we will use **Python**.
Enter `https://github.com/openshift-roadshow/nationalparks-py.git` for the **Git Repo URL**.
OpenShift will automatically guess the git server type and the programming language used by the source code. You will be now asked to select an **Import Strategy**. You have three options:
- Devfile: this will use Devfile v2 spec to create an application stack. The repo has to contain a file named `devfile.yaml` in the Devfile v2 format.
- Dockerfile: this will create a Container image from an existing Dockerfile.
- Builder Image: this will use a mechanism called Source-to-Image to create automatically a container image directly from the source code.
Select **Builder Image** strategy as we are going to create the container image directly from the source code.
Select **Python** as the **Builder Image** type and **Python 3.8-ubi8** as the **Builder Image Version**.
Scroll down and under the **General** header click the **Application** drop down and select **Create application** entering **workshop** as the name.
Scroll down reviewing the other options then click **Create**.
<Zoom>
|![s2i-build](/ocp-app-delivery-workshop/static/images/s2i-build.gif) |
|:-------------------------------------------------------------------:|
| *Creating a source to image build in OpenShift* |
</Zoom>