# DO180 "Introduction to Containers, Kubernetes, and Red Hat OpenShift" notes in the margin
##### tags: `red hat, openshift, docker, containers`
[Course description: DO180 Introduction to Containers, Kubernetes, and Red Hat OpenShift](https://www.redhat.com/en/services/training/do180-introduction-containers-kubernetes-red-hat-openshift)
## :memo: Table of contents
[ToC]
### 1. Getting Started with Container Technology
https://developers.redhat.com/blog/2018/02/22/container-terminology-practical-introduction/
https://access.redhat.com/containers/guide
https://learn.openshift.com/
https://cookbook.openshift.org/
https://blog.nody.cc/posts/container-breakouts-part1/
https://www.redhat.com/en/topics/containers/whats-a-linux-container
[Medium.com Article: Kubernetes Architecture](https://medium.com/@pratyush.mathur/kubernetes-architecture-82e9bc8324f1)
[RedHat KB: Red Hat Container Support Policy](https://access.redhat.com/articles/2726611)
[Youtube Video: Red Hat OpenShift - Much more than Kubernetes](https://www.youtube.com/watch?v=fVD1Z8wn89c)
[Openshift blog: Enterprise Kubernetes with OpenShift (Part one)](https://www.openshift.com/blog/enterprise-kubernetes-with-openshift-part-one)
https://www.redhat.com/sysadmin/podman-windows-wsl
https://developers.redhat.com/blog/2016/03/31/no-cost-rhel-developer-subscription-now-available#
RedHat CodeReady Containers
[Deep Dive into CodeReady Containers Deployment on Linux](https://alesnosek.com/blog/2021/02/28/deep-dive-into-codeready-containers-deployment-on-linux/)
[YouTube Video: Deep Dive into CodeReady Containers Deployment on Linux](https://www.youtube.com/watch?v=JrjLo_fl280)
### 2. Creating Containerized Services
[Register Red Hat Developer Subscription](https://developers.redhat.com/register)
[Getting Red Hat Developer Subscription: What RHEL users need to know](https://developers.redhat.com/articles/getting-red-hat-developer-subscription-what-rhel-users-need-know/)
[Getting Started with Red Hat OpenShift](https://developers.redhat.com/products/openshift/getting-started)
[Deploy Openshift Enterprise and CakePHP with oc cluster up](https://asciinema.org/a/49402)
[Environment variables that are used directly or indirectly by MySQL](https://dev.mysql.com/doc/refman/5.7/en/environment-variables.html)
[OpenShift Linux|MacOSX|Windows Client download link](https://access.redhat.com/downloads/content/290)
[Install OpenShift Container Platform 4 in Azure](https://cloud.redhat.com/openshift/install/azure/installer-provisioned)
https://itnext.io/guide-installing-an-okd-4-5-cluster-508a2631cbee
[Deploying and Managing OpenShift 3.9 on different platforms](https://access.redhat.com/documentation/en-us/reference_architectures/current/)
[Deploy OpenShift Container Platform 3.11 in Azure with AzureRM template](https://docs.microsoft.com/en-us/azure/virtual-machines/linux/openshift-container-platform-3x)
[Redhat Blogs: OpenShift All-in-One (AIO) for Labs and Fun (Openshift 3.11 edition)](https://www.openshift.com/blog/openshift-all-in-one-aio-for-labs-and-fun)
[Redhat Blogs: Revamped OpenShift All-in-One (AIO) for Labs and Fun (Openshift 4.2 edition)](https://www.openshift.com/blog/revamped-openshift-all-in-one-aio-for-labs-and-fun)
https://www.openshift.com/blog/openshift-4-bare-metal-install-quickstart
https://www.richardwalker.dev/ocp-setup.html
[ITNext.io story: OKD 4.5 Single Node Cluster on Windows 10 using Hyper-V](https://itnext.io/okd-4-5-single-node-cluster-on-windows-10-using-hyper-v-3ffb7b369245)
https://www.redhat.com/sysadmin/rootless-podman-makes-sense
https://developers.redhat.com/blog/2020/09/25/rootless-containers-with-podman-the-basics
### 3. Managing Containers
[Learn how to correctly start and stop Docker containers](https://dzone.com/articles/stopping-docker-containers-gracefully-3)
[Docker volumes](https://docs.docker.com/storage/volumes/)
CTRL-C is ignored by mysqld and mariadb
[Mysql container does not catch signals and exit (Ctrl+C)](https://github.com/docker-library/mysql/issues/47)
[Mariadb ignore SIGINT (Ctrl+C). Use SIGQUIT(Control+\\)](https://github.com/docker-library/mariadb/issues/82)
[SIGINT normally is ignored by the Mysql 5.7 Server](https://dev.mysql.com/doc/refman/5.7/en/unix-signal-response.html)
HTTPD catches SIGWINCH window change signal and gracefully stop
[Graceful Stop httpd with WINCH signal](http://httpd.apache.org/docs/current/stopping.html)
[Container Namespaces – Deep Dive into Container Networking](https://platform9.com/blog/container-namespaces-deep-dive-container-networking/)

[habr blog: сеть контейеров это просто](https://m.habr.com/ru/company/timeweb/blog/558612/)
### 4. Managing Container Images
[Red Hat Container Registry Authentication](https://access.redhat.com/RegistryAuthentication)
```console
docker login https://registry.redhat.io
Username: myrhusername
Password: xxxxxxxxxxx
```
/etc/containers/registries.conf
[How to get a list of images on docker registry v2](https://stackoverflow.com/questions/31251356/how-to-get-a-list-of-images-on-docker-registry-v2)
jq is a lightweight and flexible command-line JSON processor.
[jq Download page](https://stedolan.github.io/jq/download/)
```bash
mkdir ~/bin
wget https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 -O ~/bin/jq
chmod +x ~/bin/jq
```
```bash
http://<ip/hostname>:<port>/v2/_catalog
curl -X GET https://myregistry:5000/v2/_catalog
> {"repositories":["redis","ubuntu"]}
curl -X GET https://myregistry:5000/v2/ubuntu/tags/list
> {"name":"ubuntu","tags":["14.04"]}
```
[Docker Registry HTTP API V2](https://docs.docker.com/registry/spec/api/#docker-registry-http-api-v2)
[Docker Registry HTTP API V2 docs](https://github.com/docker/distribution/blob/5cb406d511b7b9163bff9b6439072e4892e5ae3b/docs/spec/api.md)
https://www.docker.com/blog/checking-your-current-docker-pull-rate-limits-and-status/
[bash script to demonstrate auth in registry](
https://github.com/moby/moby/blob/master/contrib/download-frozen-image-v2.sh)
[Listing image tags for Red Hat's Container Registry](https://access.redhat.com/solutions/2215021)
[Docker Registry CLI - Provides search functionality for Docker Registry (UI and CLI)](https://github.com/vivekjuneja/docker_registry_cli)
[Official rhscl/httpd-24-rhel7 docker image](https://access.redhat.com/containers/#/registry.access.redhat.com/rhscl/httpd-24-rhel7)
[USING RED HAT SOFTWARE COLLECTIONS 3 CONTAINER IMAGES](https://access.redhat.com/documentation/en-us/red_hat_software_collections/3/html/using_red_hat_software_collections_container_images/index)
[USING RED HAT SOFTWARE COLLECTIONS 2.4 CONTAINER IMAGES](https://access.redhat.com/documentation/en-us/red_hat_software_collections/2/html-single/using_red_hat_software_collections_container_images/index)
[Docker Registry This is **DEPRECATED**! Please go to https://github.com/docker/distribution ](https://github.com/docker-archive/docker-registry)
[Docker Distribution: The Docker toolset to pack, ship, store, and deliver content](https://github.com/docker/distribution)
[propose registry search functionality #206](https://github.com/docker/distribution/issues/206)
[Docker Registry User Interface](https://github.com/Joxit/docker-registry-ui)
Using in-home Registry without authentication is a Security Problem
[Anatomy of a hack: Docker Registry](https://www.notsosecure.com/anatomy-of-a-hack-docker-registry/)
[[RFP] replace catalog API functionality](https://github.com/opencontainers/distribution-spec/issues/22#)
https://access.redhat.com/RegistryAuthentication
https://access.redhat.com/terms-based-registry/#
### 5. Creating Custom Container Images
https://docs.docker.com/storage/storagedriver/overlayfs-driver/
https://developers.redhat.com/products/rhel/ubi/
https://www.redhat.com/en/blog/introducing-red-hat-universal-base-image
https://habr.com/ru/company/redhatrussia/blog/451090/
[Dockerfile reference](https://docs.docker.com/engine/reference/builder/)
[Best practices for writing Dockerfiles](https://docs.docker.com/develop/develop-images/dockerfile_best-practices/)
[Understand how CMD and ENTRYPOINT interact](https://docs.docker.com/engine/reference/builder/#understand-how-cmd-and-entrypoint-interact)
Both CMD and ENTRYPOINT instructions define what command gets executed when running a container. There are few rules that describe their co-operation.
1. Dockerfile should specify at least one of CMD or ENTRYPOINT commands
2. ENTRYPOINT should be defined when using the container as an executable
3. CMD should be used as a way of defining default arguments for an ENTRYPOINT command or for executing an ad-hoc command in a container
4. CMD will be overridden when running the container with alternative arguments
The table below shows what command is executed for different ENTRYPOINT / CMD combinations:
| | No ENTRYPOINT | ENTRYPOINT exec_entry p1_entry | ENTRYPOINT [“exec_entry”, “p1_entry”] |
| -------------------------- | ------------------------------ | ------------------------------ | --------------------------------------------------- |
| No CMD | error, not allowed | /bin/sh -c exec_entry p1_entry | exec_entry p1_entry |
| CMD [“exec_cmd”, “p1_cmd”] | exec_cmd p1_cmd | /bin/sh -c exec_entry p1_entry | exec_entry p1_entry exec_cmd p1_cmd |
| CMD [“p1_cmd”, “p2_cmd”] | p1_cmd p2_cmd | /bin/sh -c exec_entry p1_entry | exec_entry p1_entry p1_cmd p2_cmd |
| CMD exec_cmd p1_cmd | /bin/sh -c exec_cmd p1_cmd | /bin/sh -c exec_entry p1_entry | exec_entry p1_entry /bin/sh -c exec_cmd p1_cmd |
If CMD is defined from the base image, setting ENTRYPOINT will reset CMD to an empty value. In this scenario, CMD must be defined in the current image to have a value.
[Gracefully Stopping Docker Containers](https://www.ctl.io/developers/blog/post/gracefully-stopping-docker-containers)
[Gracefully Shutdown Docker Container](https://kkc.github.io/2018/06/06/gracefully-shutdown-docker-container/)
https://12factor.net/ru/
https://medium.com/@ruslanfg/12-%D1%84%D0%B0%D0%BA%D1%82%D0%BE%D1%80%D0%BE%D0%B2-%D0%B4%D0%BB%D1%8F-%D1%80%D0%B0%D0%B7%D1%80%D0%B0%D0%B1%D0%BE%D1%82%D0%BA%D0%B8-%D0%BF%D0%BE-a8585aaaf252
[RedHatRussia Habr Blog: Red Hat Universal Base Image (UBI) строить и жить помогает](https://habr.com/ru/company/redhatrussia/blog/451090/)
[Where’s The Red Hat Universal Base Image Dockerfile](http://crunchtools.com/ubi-build/)
[RedHat Developers blog: Red Hat Universal Base Image and Docker Hub: Why should developers care?](https://developers.redhat.com/books/red-hat-universal-base-images-ubi)
[RedHat free Ebook: Red Hat Universal Base Images (UBI)](https://developers.redhat.com/books/red-hat-universal-base-images-ubi)
[Crunchtools blog: All You Need To Know About Red Hat Universal Base Image](http://crunchtools.com/all-you-need-to-know-about-red-hat-universal-base-image/)
[Explaining Docker Image IDs ](https://windsock.io/explaining-docker-image-ids/)
SHA256 Digests of images only compute in manifest when you push them on Docker Registry with V2 API
```
[student@workstation test]$ cat Dockerfile
FROM rhel7
CMD echo test
[student@workstation test]$ docker build .
Sending build context to Docker daemon 2.048 kB
Step 1 : FROM rhel7
Trying to pull repository registry.lab.example.com:5000/rhel7 ...
latest: Pulling from registry.lab.example.com:5000/rhel7
b25889d27310: Already exists
9161239f9b22: Already exists
Digest: sha256:50e10c089959be7803c0b6dfe3de5b717c3fb4f8584bd38a90b5504f55a98821
---> 93bb76ddeb7a
Step 2 : CMD echo test
---> Running in fc7aea11aad8
---> b14d1cce99ee
Removing intermediate container fc7aea11aad8
Successfully built b14d1cce99ee
[student@workstation test]$ docker images --digests
REPOSITORY TAG DIGEST IMAGE ID CREATED SIZE
<none> <none> <none> b14d1cce99ee 8 seconds ago 192.7 MB
[student@workstation test]$ docker tag b14d1cce99ee registry.lab.example.com:5000/do180/rhel7-customimage
[student@workstation test]$ docker images --digests
REPOSITORY TAG DIGEST IMAGE ID CREATED SIZE
registry.lab.example.com:5000/do180/rhel7-customimage latest <none> b14d1cce99ee About a minute ago 192.7 MB
[student@workstation test]$ docker push registry.lab.example.com:5000/do180/rhel7-customimage
The push refers to a repository [registry.lab.example.com:5000/do180/rhel7-customimage]
86888f0aea6d: Mounted from do288/nginx-parent
dda6e8dfdcf7: Mounted from do288/nginx-parent
latest: digest: sha256:ba9cf3994b932b1331313d04705cc6ad1314216d4a5ad34bd288857b26134a3b size: 737
[student@workstation test]$ docker images --digests
REPOSITORY TAG DIGEST IMAGE ID CREATED SIZE
registry.lab.example.com:5000/do180/rhel7-customimage latest sha256:ba9cf3994b932b1331313d04705cc6ad1314216d4a5ad34bd288857b26134a3b b14d1cce99ee About a minute ago 192.7 MB
```
[GitHub: docker-cli issue: docker images --digest image does not display digest. Opened bug](https://github.com/docker/cli/issues/728)
[GitHub: moby issue: Docker build should compute image digests #32016 ](https://github.com/moby/moby/issues/32016)
### 6. Deploying Containerized Applications on OpenShift
[Openshift Docs: Getting started with the CLI](https://docs.openshift.com/container-platform/4.5/cli_reference/openshift_cli/getting-started-cli.html)
https://github.com/jamiehannaford/what-happens-when-k8s
https://kubernetes.io/ru/docs/concepts/overview/working-with-objects/kubernetes-objects/
[Kubernetes hands on series: What happens when you create a Pod in Kubernetes?](https://rakeshjain-devops.medium.com/kubernetes-hands-on-series-what-happens-when-you-create-a-pod-in-kubernetes-1251598d566b)
[Troubleshooting OpenShift SDN](https://docs.openshift.com/container-platform/3.11/admin_guide/sdn_troubleshooting.html)
Openshift SDN diagram

https://itnext.io/benchmark-results-of-kubernetes-network-plugins-cni-over-10gbit-s-network-36475925a560
```console
oc get hostsubnet
NAME HOST HOST IP SUBNET
rh71-os1.example.com rh71-os1.example.com 192.168.122.46 10.1.1.0/24
rh71-os2.example.com rh71-os2.example.com 192.168.122.18 10.1.2.0/24
rh71-os3.example.com rh71-os3.example.com 192.168.122.202 10.1.0.0/24
```
The Interfaces on a Node
These are the interfaces that the OpenShift SDN creates:
br0: The OVS bridge device that containers will be attached to. OpenShift SDN also configures a set of non-subnet-specific flow rules on this bridge.
tun0: An OVS internal port (port 2 on br0).
This gets assigned the cluster subnet gateway address, and is used for external network access.
OpenShift SDN configures netfilter and routing rules
to enable access from the cluster subnet to the external network via NAT.
vxlan_sys_4789: The OVS VXLAN device (port 1 on br0), which provides access to containers on remote nodes. Referred to as vxlan0 in the OVS rules.
vethX (in the main netns): A Linux virtual ethernet peer of eth0 in the Docker netns. It will be attached to the OVS bridge on one of the other ports.
SDN Flows Inside a Node

> Depending on what you are trying to access (or be accessed from) the path will vary. There are four different places the SDN connects (inside a node). They are labeled in red on the diagram above.
Pod: Traffic is going from one pod to another on the same machine (1 to a different 1)
Remote Node (or Pod): Traffic is going from a local pod to a remote node or pod in the same cluster (1 to 2)
External Machine: Traffic is going from a local pod outside the cluster (1 to 3)
Of course the opposite traffic flows are also possible.
[S2I process explained](https://docs.okd.io/3.11/creating_images/s2i.html#build-process)
[Openshift.com blogs: Enhancing your Builds on OpenShift: Chaining Builds](https://www.openshift.com/blog/chaining-builds)
[Youtube Video: OpenShift for Beginners - CI/CD & DevOps - Builds and Build Triggers](https://www.youtube.com/watch?v=-RqiHB-bnkg)
[OpenShift 4(and 3): Image Builds](https://www.openshift.com/blog/openshift-4-image-builds)
[Github repo: sclorg containers doc](https://github.com/sclorg/containers-doc)
[Using Red Hat OpenShift image streams with Kubernetes deployments](https://developers.redhat.com/blog/2019/09/20/using-red-hat-openshift-image-streams-with-kubernetes-deployments/)
[How to Simplify Container Image Management in Kubernetes with OpenShift Image Streams](https://www.openshift.com/blog/image-streams-faq)

Pic. 1. Image Stream python pointing to two external docker registries (tags 3.5 and 3.6), one internal registry, and to a different tag.
[Using a custom builder image on Red Hat OpenShift with OpenShift Do](https://developers.redhat.com/blog/2019/07/15/using-a-custom-builder-image-on-red-hat-openshift-with-openshift-do/)
[Sticking with HEAD on OpenShift with Image Streams](https://www.redhat.com/en/blog/sticking-head-openshift-image-streams)
[Variations on imagestreams in OpenShift 4](https://itnext.io/variations-on-imagestreams-in-openshift-4-f8ee5e8be633)

[OpenShift Commons Briefing #43: Source-to-Image Deep Dive](https://www.youtube.com/watch?v=flI6zx9wH6M)
https://www.openshift.com/blog/linux-capabilities-in-openshift
https://cookbook.openshift.org/
[opensource.com free e-book: A guide to Kubernetes for SREs and sysadmins](https://opensource.com/downloads/kubernetes-sysadmin)
[E-BOOK Managing your Kubernetes clusters for dummies](https://www.redhat.com/en/resources/managing-kubernetes-clusters-dummies-ebook)
https://itnext.io/4-container-design-patterns-for-kubernetes-a8593028b4cd
### 7. Deploying Multi-Container Applications
[docker networks: bridge, overlay](https://docs.docker.com/network/)
### 8. Troubleshooting Containerized Applications
[Learnk8s blog: A visual guide on troubleshooting Kubernetes deployments](https://learnk8s.io/troubleshooting-deployments)

[OpenShift 3.11: Triaging Disasters and Outages](https://access.redhat.com/articles/5520651)

[RedHat Article: Consolidated Troubleshooting Article OpenShift Container Platform 4.x](https://access.redhat.com/articles/4217411)
### 9. Comprehensive Review of Introduction to Containers, Kubernetes, and Red Hat OpenShift
https://www.richardwalker.dev/pages/openshift.html
https://access.redhat.com/articles/5059881
https://www.certdepot.net/openshift-articles/
https://kodekloud.com/blog/best-kubernetes-books/
https://github.com/redhat-scholars/redhat-scholars.github.io
[Cloud Native workshops and tutorials](https://redhat-scholars.github.io/cloudnative-tutorials/)
[OpenShift Starter Guides Developing Java Applications on OpenShift - Starter Lab](https://redhat-scholars.github.io/openshift-starter-guides/rhs-openshift-starter-guides/4.9)
> You will find here notes and links to official docs with additional information on products and technologies that described on RedHat Cources.
> THIS DOCUMENT DOES NOT REPRINT ANY COPYRIGHTED CONTENT FROM REDHAT TRAINING. You will find here only public accessible outline.