Introduction to Containers, Kubernetes, and Red Hat OpenShift

DO180

Welcome

Course Objectives and Structure

Schedule

Day One Day Two Day Three
Introduction Managing Container Images , continued Deploying Multi-Container Applications , continued
Introducing Container Technology Creating Custom Container Images Troubleshooting Containerized Applications
Creating Containerized Services Deploying Containerized Applications on OpenShift Comprehensive Review
Managing Containers Deploying Multi-Container Applications (Section 1) Appendixes
Managing Container Images (all except the lab)

Orientation to the Classroom Lab Environment

Internationalization

Chapter 1: Introducing Container Technology

Goal: Describe how applications run in containers orchestrated by Red Hat OpenShift Container Platform.


Objectives:

  • Describe the difference between container applications and traditional deployments. Describe the basics of container architecture. Describe the benefits of orchestrating applications and OpenShift Container Platform.

Overview of Container Technology

Containerized Applications

Container versus operating system differences

Quiz: Overview of Container Technology

Overview of Container Architecture

Introducing Container History

Describing Linux Container Architecture

Managing Containers with Podman

Quiz: Overview of Container Architecture

Overview of Kubernetes and OpenShift

Limitations of Containers

Kubernetes Overview

Kubernetes Features

OpenShift Overview

OpenShift Features

Quiz: Describing Kubernetes and OpenShift

Guided Exercise: Configuring the Classroom Environment

Summary

  • Containers are an isolated application runtime created with very little overhead.
  • A container image packages an application with all of its dependencies, making it easier to run the application in different environments.
  • Applications such as Podman create containers using features of the standard Linux kernel.
  • Container image registries are the preferred mechanism for distributing container images to multiple users and hosts.
  • OpenShift orchestrates applications composed of multiple containers using Kubernetes.

Summary (continued)

  • Kubernetes manages load balancing, high availability, and persistent storage for containerized applications.
  • OpenShift adds to Kubernetes multitenancy, security, ease of use, and continuous integration and continuous development features.
  • OpenShift routes enable external access to containerized applications in a manageable way.

Chapter 2: Creating Containerized Services

Goal: Provision a service using container technology.


Objectives:

  • Create a database server from a container image.

Provisioning Containerized Services

Fetching Container Images with Podman

Running Containers

Using the Red Hat Container Catalog

Red Hat Container Catalog home page

Apache httpd 2.4 (rhscl/httpd-24-rhel7) overview image page

Apache httpd 2.4 (rhscl/httpd-24-rhel7) latest image page

Guided Exercise: Creating a MySQL Database Instance

Lab: Creating Containerized Services

Summary

  • Podman allows users to search for and download images from local or remote registries.
  • The podman run command creates and starts a container from a container image.
  • Containers are executed in the background by using the -d flag, or interactively by using the -it flag.
  • Some container images require environment variables that are set using the -e option from the podman run command.
  • Red Hat Container Catalog assists in searching, exploring, and analyzing container images from Red Hat's official container image repository.

Chapter 3: Managing Containers

Goal: Modify prebuilt container images to create and manage containerized services.


Objectives:

  • Manage a container's life cycle from creation to deletion.

  • Save container application data with persistent storage.

  • Describe how to use port forwarding to access a container.

Managing the Life Cycle of Containers

Container Life Cycle Management with Podman

Podman managing subcommands

Podman query subcommands

Creating Containers

Running Commands in a Container

Managing Containers

Guided Exercise: Managing a MySQL Container

Attaching Persistent Storage to Containers

Preparing Permanent Storage Locations

Container layers

Guided Exercise: Persisting a MySQL Database

Accessing Containers

Introducing Networking with Containers

Basic Linux container networking

Mapping Network Ports

Allowing external accesses to Linux containers

Guided Exercise: Loading the Database

Lab: Managing Containers

Summary

  • Podman has subcommands to: create a new container (run), delete a container (rm), list containers (ps), stop a container (stop), and start a process in a container (exec).

Summary (continued)

  • Default container storage is ephemeral, meaning its contents are not present after the container restarts or is removed.
    • Containers can use a folder from the host file system to work with persistent data.
    • Podman mounts volumes in a container with the -v option in the podman run command.
  • The podman exec command starts an additional process inside a running container.
  • Podman maps local ports to container ports by using the -p option in the run subcommand.

Chapter 4: Managing Container Images

Goal: Manage the life cycle of a container image from creation to deletion.


Objectives:

  • Search for and pull images from remote registries. Export, import, and manage container images locally and in a registry.

Accessing Registries

Public Registries

Private Registries

Configuring Registries in Podman

Accessing Registries

Quiz: Working With Registries

Manipulating Container Images

Introduction

Saving and Loading Images

Deleting Images

Deleting all Images

Modifying Images

Tagging Images

Best Practices for Tagging Images

Publishing Images to a Registry

Guided Exercise: Creating a Custom Apache Container Image

Lab: Managing Images

Summary

  • The Red Hat Container Catalog provides tested and certified images at registry.redhat.io.
  • Podman can interact with remote container registries to search, pull, and push container images.
  • Image tags are a mechanism to support multiple releases of a container image.
  • Podman provides commands to manage container images both in local storage and as compressed files.
  • Use the podman commit to create an image from a container.

Chapter 5: Creating Custom Container Images

Goal: Design and code a Dockerfile to build a custom container image.


Objectives:

  • Describe the approaches for creating custom container images. Create a container image using common Dockerfile commands.

Designing Custom Container Images

Reusing Existing Dockerfiles

Working with the Red Hat Software Collections Library

Finding Dockerfiles from the Red Hat Software Collections Library

Container Images in Red Hat Container Catalog (RHCC)

Searching for Images Using Quay.io

Finding Dockerfiles on Docker Hub

Describing How to use the OpenShift Source-to-Image Tool

Quiz: Approaches to Container Image Design

Building Custom Container Images with Dockerfiles

Building Base Containers

CMD and ENTRYPOINT

ADD and COPY

Layering Image

Building Images with Podman

Guided Exercise: Creating a Basic Apache Container Image

Lab: Creating Custom Container Images

Summary

  • A Dockerfile contains instructions that specify how to construct a container image.
  • Container images provided by Red Hat Container Catalog or Quay.io are a good starting point for creating custom images for a specific language or technology.
  • Building an image from a Dockerfile is a three-step process:
  • Create a working directory.
  • Specify the build instructions in a Dockerfile file.
  • Build the image with the podman build command.

Summary (continued)

  • The Source-to-Image (S2I) process provides an alternative to Dockerfiles. S2I implements a standardized container image build process for common technologies from application source code. This allows developers to focus on application development and not Dockerfile development.

Chapter 6: Deploying Containerized Applications on OpenShift

Goal: Deploy single container applications on OpenShift Container Platform.


Objectives:

  • Describe the architecture of Kubernetes and Red Hat OpenShift Container Platform. Create standard Kubernetes resources. Create a route to a service. Build an application using the Source-to-Image facility of OpenShift Container Platform. Create an application using the OpenShift web console.

Describing Kubernetes and OpenShift Architecture

Kubernetes and OpenShift

OpenShift component stack

OpenShift and Kubernetes architecture

New Features in RHOCP 4

Describing Kubernetes Resource Types

OpenShift Resource Types

Networking

Quiz: Describing Kubernetes and OpenShift

Creating Kubernetes Resources

The Red Hat OpenShift Container Platform (RHOCP) Command-line Tool

Describing Pod Resource Definition Syntax

Describing Service Resource Definition Syntax

Basic Kubernetes networking

Kubernetes services networking

Discovering Services

Alternative method for external access to a Kubernetes service

Creating New Applications

Resources created for a new application

Managing OpenShift Resources at the Command Line

Labelling resources

Guided Exercise: Deploying a Database Server on OpenShift

Creating Routes

Working with Routes

OpenShift routes and Kubernetes services

Creating Routes

Guided Exercise: Exposing a Service as a Route

Creating Applications with Source-to-Image

The Source-to-Image (S2I) Process

Deployment Configuration and dependent resources

Describing Image Streams

Building an Application with S2I and the CLI

Relationship Between Build and Deployment Configurations

Guided Exercise: Creating a Containerized Application with Source-to-Image

Creating Applications with the OpenShift Web Console

Accessing the OpenShift Web Console

OpenShift web console home page

Creating New Applications

OpenShift Developer Catalog page

OpenShift build configurations page

Managing Deployed Applications

OpenShift Workloads menu

Other Web Console Features

Guided Exercise: Creating an Application with the Web Console

Lab: Deploying Containerized Applications on OpenShift

Summary

  • OpenShift Container Platform stores definitions of each OpenShift or Kubernetes resource instance as an object in the cluster's distributed database service, etcd. Common resource types are: Pod, Persistent Volume (PV), Persistent Volume Claim (PVC), Service (SVC), Route, Deployment Configuration (DC), and Build Configuration (BC).
  • Use the OpenShift command-line client oc to:
    • Create, change, and delete projects.
    • Create application resources inside a project.
    • Delete, inspect, edit, and export resources inside a project.
    • Check logs from application pods, deployments, and build operations.
  • The oc new-app command can create application pods in many different ways: from an existing container image hosted on an image registry, from Dockerfiles, and from source code using the Source-to-Image (S2I) process.

Summary (continued)

  • Source-to-Image (S2I) is a tool that makes it easy to build a container image from application source code. This tool retrieves source code from a Git repository, injects the source code into a selected container image based on a desired language or technology, and produces a new container image that runs the assembled application.
  • A Route connects a public-facing IP address and DNS host name to an internal-facing service IP. While services allow for network access between pods inside an OpenShift instance, routes allow for network access to pods from users and applications outside the OpenShift instance.
  • You can create, build, deploy and monitor applications using the OpenShift web console.

Chapter 7: Deploying Multi-Container Applications

Goal: Deploy applications that are containerized using multiple container images.


Objectives:

  • Describe considerations for containerizing applications with multiple container images. Deploy a multi-container application on OpenShift using a template.

Considerations for Multi-Container Applications

Leveraging Multi-Container Applications

Discovering Services in a Multi-Container Application

A restart breaks three-tiered application links

Comparing Podman and Kubernetes

Describing the To Do List Application

To Do List application logical architecture

The To Do List application

Guided Exercise: Deploying the Web Application and MySQL Containers

Deploying a Multi-Container Application on OpenShift

Examining the Skeleton of a Template

Processing a Template Using the CLI

Configuring Persistent Storage for OpenShift Applications

Guided Exercise: Creating an Application with a Template

Lab: Deploying Multi-Container Applications

Summary

  • Software defined networks enable communication between containers. Containers must be attached to the same software-defined network to communicate.
  • Containerized applications cannot rely on fixed IP addresses or host names to find services.
  • Podman uses Container Network Interface (CNI) to create a software-defined network and attaches all containers on the host to that network. Kubernetes and OpenShift create a software-defined network between all containers in a pod.

Summary (continued)

  • Within the same project, Kubernetes injects a set of variables for each service into all pods.
  • Kubernetes templates automate creating applications consisting of multiple resources. Template parameters allow using the same values when creating multiple resources.

Chapter 8: Troubleshooting Containerized Applications

Goal: Troubleshoot a containerized application deployed on OpenShift.


Objectives:

  • Troubleshoot an application build and deployment on OpenShift. Implement techniques for troubleshooting and debugging containerized applications.

Troubleshooting S2I Builds and Deployments

Introduction to the S2I Process

Build instances of a project

Detailed view of a build instance

Describing Common Problems

Guided Exercise: Troubleshooting an OpenShift Build

Troubleshooting Containerized Applications

Forwarding Ports for Troubleshooting

Enabling Remote Debugging with Port Forwarding

Accessing Container Logs

OpenShift Events

Accessing Running Containers

Overriding Container Binaries

Transferring Files To and Out of Containers

Guided Exercise: Configuring Apache Container Logs for Debugging

Lab: Troubleshooting Containerized Applications

Summary

  • Applications typically log activity, such as events, warnings and errors, to aid the analysis of application behavior.
  • Container applications should print log data to standard output, instead of to a file, to enable easy access to logs.
  • To review the logs for a container deployed locally with Podman, use the podman logs command.
  • Use the oc logs command to access logs for BuildConfig and DeploymentConfig objects, as well as individual pods within an OpenShift project.

Summary (continued)

  • The -f option allows you to monitor the log output in near real-time for both the podman logs and oc logs commands.
  • Use the oc port-forward command to connect directly to a port on an application pod. You should only leverage this technique on non-production pods, because interactions can alter the behavior of the pod.

Chapter 9: Comprehensive Review

Goal: Review tasks from Introduction to Containers, Kubernetes, and Red Hat OpenShift


Objectives:

  • Review tasks from Introduction to Containers, Kubernetes, and Red Hat OpenShift

Comprehensive Review

Reviewing Introduction to Containers, Kubernetes, and Red Hat OpenShift

General Container, Kubernetes, and OpenShift Hints

Lab: Containerizing and Deploying a Software Application

Appendix: Implementing Microservices Architecture

Appendix: Creating a GitHub Account

Appendix: Creating a Quay Account

Appendix: Useful Git Commands

DO180-O4.2-en-1-20191031