Introduction to Containers, Kubernetes, and Red Hat OpenShift
DO180
Course Objectives and Structure
Schedule
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
Chapter 1: Introducing Container Technology
Goal: Describe how applications run in containers orchestrated by Red Hat OpenShift Container Platform.
Objectives:
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
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:
Provisioning Containerized Services
Fetching Container Images with Podman
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
Running Commands in a Container
Guided Exercise: Managing a MySQL Container
Attaching Persistent Storage to Containers
Preparing Permanent Storage Locations
Container layers
Guided Exercise: Persisting a MySQL Database
Introducing Networking with Containers
Basic Linux container networking
Allowing external accesses to Linux containers
Guided Exercise: Loading the Database
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:
Configuring Registries in Podman
Quiz: Working With Registries
Manipulating Container Images
Saving and Loading Images
Best Practices for Tagging Images
Publishing Images to a Registry
Guided Exercise: Creating a Custom Apache Container Image
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:
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 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:
Describing Kubernetes and OpenShift Architecture
OpenShift component stack
OpenShift and Kubernetes architecture
Describing Kubernetes Resource Types
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
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
Guided Exercise: Deploying a Database Server on OpenShift
OpenShift routes and Kubernetes services
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
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:
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:
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 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:
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