Skip to content

Commit

Permalink
Add 4.2 getting started content and version content.
Browse files Browse the repository at this point in the history
  • Loading branch information
jankleinert authored and BenHall committed Nov 14, 2019
1 parent bc5257d commit 6a928fa
Show file tree
Hide file tree
Showing 73 changed files with 751 additions and 0 deletions.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 46 additions & 0 deletions introduction/getting-started-311/1explore-cli.md
@@ -0,0 +1,46 @@
The OpenShift CLI is accessed using the command _oc_. From here, you can administrate the entire OpenShift cluster and deploy new applications.

The CLI exposes the underlying Kubernetes orchestration system with the enhancements made by OpenShift. Users familiar with Kubernetes will be able to adapt to OpenShift quickly. The CLI is ideal in situations where you are:

1) Working directly with project source code

2) Scripting OpenShift operations

3) Restricted by bandwidth resources and cannot use the web console

For this section, our task is going to be creating our first project.

## What is a project? Why does it matter?
The goal of this section is to get a project created and running, which you'll be doing with the **web console** in the next section.

OpenShift is often referred to as a container application platform in that it is a platform designed for the development and deployment of containers.

To contain your application, we use projects. The reason for having a project to contain your application is to allow for controlled access and quotas for developers or teams.

More technically, it's a visualization of the Kubernetes namespace based on the developer access controls.

## Command Line Interface (CLI)
In this course, we're not focusing on the OpenShift CLI, but we want you to be aware of it in case using the command line is your thing. You can check out our other courses that go into the use of the CLI in more depth. Now, we're just going to practice logging in so you can get some experience with how the CLI works.

## Task
Let's get started by logging in. Your task is to enter the following into the console:

`oc login`{{execute}}

When prompted, enter the following username and password:

**Username:** `developer`{{execute}}

**Password:** `developer`{{execute}}

Next, you can check if it was successful:

`oc whoami`{{execute}}

`oc whoami` should return a response of:

`developer`

That's it!

In the next step, we'll get started with creating your first project using the **web console**.
34 changes: 34 additions & 0 deletions introduction/getting-started-311/2explore-console.md
@@ -0,0 +1,34 @@
While the command line tool is awesome, for this course we are going to focus on the web console, which is equally awesome.

## Task 1
To begin, click on the **Dashboard** tab on your screen. This will open the web console on your browser.

You should see an **OKD** window with **Username** and **Password** forms as shown below:

![OKD Web Console](../../assets/introduction/getting-started-311/ocp-login.png)

For this scenario, log in by entering the following:

**Username:** `developer`{{copy}}

**Password:** `developer`{{copy}}

After logging in to the web console, you'll see a blue button labeled *Create Project* in the top right corner of your screen that is shown below. Click this button to get started.

![Create Project Button](../../assets/introduction/getting-started-311/2create-project-button.png)

You should now see a page for creating your first project in the web console. Fill in the _Name_ field as `myproject`{{copy}}.

![Create Project](../../assets/introduction/getting-started-311/2create-project.png)

The rest of the form is optional and up to you to fill in or ignore. Click *Create* to continue.

After your project is created, your project will appear under **My Projects**, and you can click on `myproject` to access your newly created project.

## Task 2

Notice the menu on the left. You're now currently on the **Overview** screen. The tools that you'll need for building and deploying your application can also be found here on the left.

Take a quick look around these, clicking on **Applications**, **Builds**, and **Resources** to see more options. There won't be much there for now as we have nothing in our project.

We'll get into those in future sections, but go ahead and explore to see what's possible! Don't spend too much time on these now as you will get to use a lot of these features in the upcoming sections.
27 changes: 27 additions & 0 deletions introduction/getting-started-311/3deploy-docker.md
@@ -0,0 +1,27 @@
In this section, you are going to deploy the front end component of an application called **parksmap**. The web application will display an interactive map, which will be used to display the location of major national parks from all over the world.

# Exercise: Deploying your first Image

The simplest way to deploy an application in OpenShift is to take an existing Docker-formatted image and run it. We are going to use the OpenShift web console to do this, so ensure you have the OpenShift web console open and that you are in the project called `myproject`.

The OpenShift web console provides various options to deploy an application to a project. For this section, we are going to use the *Deploy Image* method. As the project is empty at this point, the *Overview* page should display the following options: *Browse Catalog*, *Deploy Image*, *Import YAML/JSON*, and *Select from Project*. Choose the *Deploy Image* button.

![Add to Project](../../assets/introduction/getting-started-311/3add-to-empty-project.png)

You could also have selected the *Add to Project* drop down menu in the top right corner of the project and selected _Deploy Image_ to go directly to the required tab. We'll use the *Add to Project* option in later sections.

Within the *Deploy Image* page, choose the *Image Name* option. This will be used to reference an existing Docker-formatted image hosted on a Docker Hub Registry. For the name of the image, enter the following:

`openshiftroadshow/parksmap-katacoda:1.2.0`{{copy}}

Press enter or click on the magnifying glass icon to the right of the text entry box to be presented with information about the image:

![Deploy Image](../../assets/introduction/getting-started-311/3deploy-parksmap-image.png)

At this point, OpenShift will pull down and display key information about the image and the pending deployment, as well as populate the *Name* field with `parksmap-katacoda`. This name will be what is used for your application and the various components created that relate to it. Leave this as the generated value as steps given in the upcoming sections will use this name.

You are ready to deploy the existing Docker-formatted image. Hit the blue *Deploy* button at the bottom of the screen, and, in the subsequent page, click the *Continue to the project overview* link. This should bring you back to the *Overview* page where summary information about the application you just deployed will be displayed.

![Console Overview](../../assets/introduction/getting-started-311/3parksmap-overview.png)

These are all the steps you need to run to get a "vanilla" Docker-formatted image deployed on OpenShift. This should work with any Docker-formatted image that follows best practices, such as defining the port any service is exposed on, not needing to run specifically as the *root user* or other dedicated user, and which embeds a default command for running the application.
44 changes: 44 additions & 0 deletions introduction/getting-started-311/4scaling.md
@@ -0,0 +1,44 @@
Let's scale our application up to 2 instances of the pods. You can do this by clicking the "up" arrow next to
the *Pod* in the OpenShift web console on the overview page.

![Scaling using arrows](../../assets/introduction/getting-started-311/4scaling-arrows.png)

To verify that we changed the number of replicas, click the pods number in the circle next to the arrows.
You should see a list with your pods similar to the following by scrolling to the bottom of the web console:

![List of pods](../../assets/introduction/getting-started-311/4scaling-pods.png)

You can see that we now have 2 replicas.

Overall, that's how simple it is to scale an application (*Pods* in a
*Service*). Application scaling can happen extremely quickly because OpenShift
is just launching new instances of an existing image, especially if that image
is already cached on the node.

### Application "Self Healing"

Because OpenShift's *DeploymentConfigs* are constantly monitoring to see that the desired number
of *Pods* is actually running, you might also expect that OpenShift will fix the
situation if it is ever not right. You would be correct!

Since we have two *Pods* running right now, let's see what happens if we
"accidentally" kill one.

On the same page where you viewed the list of pods after scaling to 2 replicas, open one of the pods by clicking its name in the list.

In the top right corner of the page, there is an _Actions_ tab. When opened, there is the _Delete_ action.

![Delete action](../../assets/introduction/getting-started-311/4scaling-actions.png)

Click _Delete_ and confirm the dialog. You will be taken back to the page listing pods, however, this time, there are three pods.

![List of pods](../../assets/introduction/getting-started-311/4scaling-terminating.png)

The pod that we deleted is terminating (i.e., it is being cleaned up). A new pod was created because
OpenShift will always make sure that, if one pod dies, there is going to be new pod created to
fill its place.

### Exercise: Scale Down

Before we continue, go ahead and scale your application down to a single
instance. It's as simple as clicking the down arrow on the _Overview_ page.
47 changes: 47 additions & 0 deletions introduction/getting-started-311/5routes.md
@@ -0,0 +1,47 @@
_Services_ provide internal abstraction and load balancing within an OpenShift
environment, but sometimes clients (users, systems, devices, etc.) **outside**
of OpenShift need to access an application. The way that external clients are able
to access applications running in OpenShift is through the OpenShift routing layer.
The data object behind that layer is a _Route_.

The default OpenShift router (HAProxy) uses the HTTP header of the incoming
request to determine where to proxy the connection. You can optionally define
security, such as TLS, for the _Route_. If you want your _Services_, and, by
extension, your _Pods_, to be accessible to the outside world, you need to
create a _Route_.

## Task: Creating a Route

Fortunately, creating a _Route_ is a pretty straight-forward process. You just click
the *Create Route* link displayed against the application on the _Overview_ page.

![No route](../../assets/introduction/getting-started-311/5no-route.png)

By default, OpenShift is configured to create the _Route_ based on the _Service_ name being exposed and the _Project_ where the application lives, adding a common subdomain configured at the platform level. In our scenario, we have:

**https://[[HOST_SUBDOMAIN]]-8443-[[KATACODA_HOST]].environments.katacoda.com**.

This means that there is no need to change the default settings in the _Route_ creation form.

![Route form](../../assets/introduction/getting-started-311/5create-route.png)

Once you click _Create_, the _Route_ will be created and displayed in the _Overview_ page.

![Route created](../../assets/introduction/getting-started-311/5route-created.png)

We can also get the list of all the existing _Routes_ by clicking the _Applications->Routes_ menu:

![Routes menu](../../assets/introduction/getting-started-311/5routes-menu.png)

Currently the list of _Routes_ will only display the one we just created.

![Routes list](../../assets/introduction/getting-started-311/5routes-list.png)

In this list, we will be able to see the details associated with the route, such as the hostname, the service, the port the route is exposing, and details on the TLS security for the route, if any.

You can always click on the _Route_ name in this list to modify an existing _Route_.

Now that we know how to create a _Route_, let's verify that the application is really available at the URL shown in the
web console. Click the link and you will see:

![Application](../../assets/introduction/getting-started-311/5parksmap-empty.png)
64 changes: 64 additions & 0 deletions introduction/getting-started-311/6s2i.md
@@ -0,0 +1,64 @@
In this section, you are going to deploy a backend service for the ParksMap application. This backend service will provide data, via a REST service API, on major national parks from all over the world. The ParksMap front end web application will query this data and display it on an interactive map in your web browser.

# Background: Source-to-Image (S2I)

In a previous section, you learned how to deploy an application (the ParksMap front end) from a pre-existing Docker-formatted image. Here you will learn how to deploy an application direct from source code hosted in a remote Git repository. This will be done using the [Source-to-Image (S2I)](https://github.com/openshift/source-to-image) tool.

The documentation for S2I describes itself in the following way:

> Source-to-image (S2I) is a tool for building reproducible Docker images. S2I
produces ready-to-run images by injecting source code into a Docker image and
assembling a new Docker image which incorporates the builder image and built
source. The result is then ready to use with docker run. S2I supports
incremental builds which re-use previously downloaded dependencies, previously
built artifacts, etc.

OpenShift is S2I-enabled and can use S2I as one of its build mechanisms (in addition to building Docker images from Dockerfiles and "custom" builds).

A full discussion of S2I is beyond the scope of this lab. More information about S2I can be found in the [OpenShift S2I documentation](https://docs.openshift.org/latest/creating_images/s2i.html) and the [GitHub project respository for S2I](https://github.com/openshift/source-to-image).

The only key concept you need to remember about S2I is that it's magic.

# Exercise: Deploying the application code

The backend service that you will be deploying in this section is called `nationalparks-katacoda`. This is a Python application that will return map coordinates of major national parks from all over the world as JSON via a REST service API. The source code repository for the application can be found on GitHub at:

* https://github.com/openshift-roadshow/nationalparks-katacoda

To deploy the application you are going to use the *Add to Project* dropdown menu of the OpenShift web console, so ensure you have the OpenShift web console open and that you are in the project called `myproject`. Find and select the *Add to Project* dropdown in the right corner of the project. This time, rather than using *Deploy Image*, you want to use *Browse Catalog*, which will take you to the following page:

![Browse Catalog](../../assets/introduction/getting-started-311/6browse-catalog.png)

Under the **Languages** section, select Python in the list of supported languages. When presented with the options of *Django + Postgres SQL*, *Django + Postgres SQL (Ephemeral)*, and *Python*, select the *Python* option.

![Python Builder](../../assets/introduction/getting-started-311/6python-builder.png)

Upon selecting Python, click the *Next>* button on the bottom right of the screen to continue. Ensure that the Python version is 3.5 by selecting it from the *Version* dropdown menu.

![Create Python](../../assets/introduction/getting-started-311/6python-version.png)

For the the *Name* of the application use:

``nationalparks-katacoda``{{copy}}

For the *Git Repository URL* use:

``https://github.com/openshift-roadshow/nationalparks-katacoda``{{copy}}

The *Name* needs to be ``nationalparks-katacoda`` as the front end for the ParksMap application is expecting the backend service to use that name.

Click on *Create* in the bottom right corner of the screen and then *Continue to the project overview*. In the overview page of the web console, you should now see both the front end web application and the backend web service you just deployed. The build of the backend web service will be collapsed upon returning to the *Overview* page. Click on the arrow to left of the `nationalparks-katacoda` name to expand the pane as shown below:

![Build Running](../../assets/introduction/getting-started-311/6build-running.png)

You will see that initially a build is running for the Python application. This is the step where S2I is run on the application source code from the Git repository to create the image which will then be run. Click on the *View Full Log* link for the build and you can follow along as the S2I builder for Python downloads all the Python packages required to run the application, prepares the application, and creates the image.

![Build Logs](../../assets/introduction/getting-started-311/6build-logs.png)

Head back to the *Overview* page when the build completes to see the image being deployed and the application being started up. The build is complete when you see the following in the build logs: `Push successful`.

![Build Complete](../../assets/introduction/getting-started-311/6build-complete.png)

With the backend service for the ParksMap application now deployed, if you return to the front end in your web browser, you should now be able to see the locations of the national parks displayed.

![ParksMap Front End](../../assets/introduction/getting-started-311/6parksmap-frontend.png)
3 changes: 3 additions & 0 deletions introduction/getting-started-311/env-init.sh
@@ -0,0 +1,3 @@
ssh root@host01 "docker pull centos/python-35-centos7:latest"
ssh root@host01 "docker pull openshiftroadshow/parksmap-katacoda:1.0.0"
ssh root@host01 'for i in {1..200}; do oc policy add-role-to-user system:image-puller system:anonymous && break || sleep 1; done'
17 changes: 17 additions & 0 deletions introduction/getting-started-311/finish.md
@@ -0,0 +1,17 @@
Congratulations! You just finished learning the basics of how to get started with the OpenShift Container Platform. Feels good doesn't it?

## What's next?

At this point you are probably itching to keep working with OpenShift as you have had a glimpse of the power this can bring to your own applications. We are currently working on more advanced tutorials that will be hosted here but in the meantime, you can certainly run your own version of OpenShift or use a hosted model. You are welcome to use one of the following options:

### Minishift

Minishift is a complete OpenShift environment that you can run on your local machine. The project supports Windows, OS X, and the Linux operating system. To find more about minishift, visit https://www.okd.io/minishift/

### OpenShift Online

The OpenShift team provides a hosted environment which includes a free starter plan which you can use to develop and test applications for OpenShift. You can find details for OpenShift Online and sign up at https://www.openshift.com/products/pricing/

### OpenShift Dedicated

You can also let Red Hat host an OpenShift instance for you on a public cloud. This is an ideal scenario for larger teams that doesn't want to deal with the operational aspects or running a full environment. To find out more, visit https://www.openshift.com/products/dedicated/
48 changes: 48 additions & 0 deletions introduction/getting-started-311/index.json
@@ -0,0 +1,48 @@
{
"icon": "fa-openshift",
"title": "Getting Started with OpenShift for Developers",
"description": "",
"pathwayTitle": "OpenShift",
"difficulty": "beginner",
"time": "20-30 minutes",
"backend": {
"imageid": "openshift-3-11",
"port": 8443
},
"environment": {
"showdashboard": true,
"dashboard": "Dashboard",
"uilayout": "terminal-iframe",
"hideintro": false,
"hidefinish": false
},
"details": {
"steps": [{
"title": "Step 1 - Exploring The Command Line",
"text": "1explore-cli.md"
}, {
"title": "Step 2 - Exploring The Web Console",
"text": "2explore-console.md"
}, {
"title": "Step 3 - Deploying a Docker Image",
"text": "3deploy-docker.md"
}, {
"title": "Step 4 - Scaling Your Application",
"text": "4scaling.md"
}, {
"title": "Step 5 - Routing HTTP Requests",
"text": "5routes.md"
}, {
"title": "Step 6 - Building From Source Code",
"text": "6s2i.md"
}],
"intro": {
"courseData": "env-init.sh",
"code": "set-env.sh",
"text": "intro.md"
},
"finish": {
"text": "finish.md"
}
}
}

0 comments on commit 6a928fa

Please sign in to comment.