diff --git a/_lectures-containers/14-API.md b/_lectures-containers/105-Webinterface-Howtos.md similarity index 70% rename from _lectures-containers/14-API.md rename to _lectures-containers/105-Webinterface-Howtos.md index b7796cd..221afb5 100644 --- a/_lectures-containers/14-API.md +++ b/_lectures-containers/105-Webinterface-Howtos.md @@ -1,5 +1,5 @@ --- -title: Kubernetes/OpenShift API +title: Web interface How-tos author: CSC Training titleslide: true lang: en diff --git a/_lectures-containers/11-OpenShiftCLI.md b/_lectures-containers/11-OpenShiftCLI.md index 20b820f..d818792 100644 --- a/_lectures-containers/11-OpenShiftCLI.md +++ b/_lectures-containers/11-OpenShiftCLI.md @@ -1,7 +1,7 @@ --- -title: OpenShift CLI +title: Kubernetes and OpenShift CLI and API author: CSC Training titleslide: true lang: en layout: slides-remark ---- \ No newline at end of file +--- diff --git a/img/Kubernetes-arch.drawio.svg b/img/Kubernetes-arch.drawio.svg new file mode 100644 index 0000000..aa3209b --- /dev/null +++ b/img/Kubernetes-arch.drawio.svg @@ -0,0 +1,116 @@ + + + + + + + +
+
+
+ Node +
+
+
+
+ + Node + +
+
+ + + + +
+
+
+ Node +
+
+
+
+ + Node + +
+
+ + + + +
+
+
+ Node +
+
+
+
+ + Node + +
+
+ + + + +
+
+
+ Control pane +
+
+
+
+ + Control pane + +
+
+ + + + + +
+
+
+ etcd +
+
+
+
+ + etcd + +
+
+ + + + +
+
+
+ Master +
+
+
+
+ + Master + +
+
+
+ + + + + Viewer does not support full SVG 1.1 + + + +
\ No newline at end of file diff --git a/img/command-line.drawio.svg b/img/command-line.drawio.svg new file mode 100644 index 0000000..8f30916 --- /dev/null +++ b/img/command-line.drawio.svg @@ -0,0 +1,33 @@ + + + + + + + + +
+
+
+ + >_ + +
+
+
+
+ + >_ + +
+
+
+ + + + + Viewer does not support full SVG 1.1 + + + +
\ No newline at end of file diff --git a/img/oc-v-kubectl.drawio.svg b/img/oc-v-kubectl.drawio.svg new file mode 100644 index 0000000..e904e7d --- /dev/null +++ b/img/oc-v-kubectl.drawio.svg @@ -0,0 +1,307 @@ + + + + + + + + + + + + + + + + +
+
+
+ + DeploymentConfig + +
+
+
+
+ + DeploymentCo... + +
+
+ + + + + + +
+
+
+ + Route + +
+
+
+
+ + Route + +
+
+ + + + + +
+
+
+ + BuildConfig + +
+
+
+
+ + BuildConfig + +
+
+ + + + + + +
+
+
+ + ImageStream + +
+
+
+
+ + ImageStream + +
+
+ + + + + + +
+
+
+ + Deployment +
+
+
+
+
+
+ + Deployment + +
+
+ + + + + + +
+
+
+ + Ingress + +
+
+
+
+ + Ingress + +
+
+ + + + + + +
+
+
+ + ReplicationControler + +
+
+
+
+ + ReplicationC... + +
+
+ + + + + + +
+
+
+ + Pod +
+
+
+
+
+
+ + Pod + +
+
+ + + + + + +
+
+
+ + PhysicalVolume + +
+
+
+
+ + PhysicalVolu... + +
+
+ + + + + + +
+
+
+ + Secret + +
+
+
+
+ + Secret + +
+
+ + + + + + +
+
+
+ + ConfigMap + +
+
+
+
+ + ConfigMap + +
+
+ + + + +
+
+
+ Kubernetes +
+
+
+
+ + Kubernetes + +
+
+ + + + +
+
+
+ OpenShift +
+
+
+
+ + OpenShift + +
+
+ + + + + + +
+
+
+ + DaemonSet + +
+
+
+
+ + DaemonSet + +
+
+
+ + + + + Viewer does not support full SVG 1.1 + + + +
\ No newline at end of file diff --git a/img/run_containers.drawio.svg b/img/run_containers.drawio.svg new file mode 100644 index 0000000..bc6c5ac --- /dev/null +++ b/img/run_containers.drawio.svg @@ -0,0 +1,294 @@ + + + + + + + + + +
+
+
+ + Hardware + +
+
+
+
+ + Hardware + +
+
+ + + + + +
+
+
+ Kernel +
+
+
+
+ + Kernel + +
+
+ + + + +
+
+
+ Node +
+
+
+
+ + Node + +
+
+ + + + + + +
+
+
+ + Container + +
+
+
+
+ + Conta... + +
+
+ + + + + +
+
+
+ + Container + +
+
+
+
+ + Conta... + +
+
+ + + + + + + +
+
+
+ + Image + +
+
+
+
+ + Image + +
+
+ + + + + +
+
+
+ + Registry + +
+
+
+
+ + Regis... + +
+
+ + + + +
+
+
+ Software +
+
+
+
+ + Softw... + +
+
+ + + + +
+
+
+ Libraries +
+
+
+
+ + Libra... + +
+
+ + + + +
+
+
+ Software +
+
+
+
+ + Softw... + +
+
+ + + + +
+
+
+ Libraries +
+
+
+
+ + Libra... + +
+
+ + + + + + +
+
+
+ Software +
+
+
+
+ + Softw... + +
+
+ + + + +
+
+
+ Libraries +
+
+
+
+ + Libra... + +
+
+ + + + +
+
+
+ Changes +
+
+
+
+ + Chang... + +
+
+ + + + + + + + +
+
+
+ + +
+
+
+
+ + + + +
+
+
+ + + + + Viewer does not support full SVG 1.1 + + + +
\ No newline at end of file diff --git a/img/source2image.drawio.svg b/img/source2image.drawio.svg new file mode 100644 index 0000000..91150e8 --- /dev/null +++ b/img/source2image.drawio.svg @@ -0,0 +1,250 @@ + + + + + + + + + +
+
+
+ + GiT repository + +
+
+
+
+ + GiT repository + +
+
+ + + + + + + +
+
+
+ Rahti - OpenShift +
+
+
+
+ + Rahti - OpenShift + +
+
+ + + + +
+
+
+ Deployment +
+
+
+
+ + Deployme... + +
+
+ + + + +
+
+
+ Pod +
+
+
+
+ + Pod + +
+
+ + + + + + + + + + +
+
+
+ Route +
+
+
+
+ + Route + +
+
+ + + + + + +
+
+
+ Network Traffic +
+
+
+
+ + Network Traffic + +
+
+ + + + +
+
+
+ Image +
+ Registry +
+
+
+
+ + Image... + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+ Build +
+
+
+
+ + Build + +
+
+ + + + + + +
+
+
+ Service +
+
+
+
+ + Service + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + Viewer does not support full SVG 1.1 + + + +
\ No newline at end of file diff --git a/img/trigger.drawio.svg b/img/trigger.drawio.svg new file mode 100644 index 0000000..264cdbb --- /dev/null +++ b/img/trigger.drawio.svg @@ -0,0 +1,189 @@ + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+ Image +
+ Registry +
+
+
+
+ + Image... + +
+
+ + + + +
+
+
+ Trigger +
+
+
+
+ + Trigg... + +
+
+ + + + +
+
+
+ Cluster +
+
+
+
+ + Clust... + +
+
+ + + + +
+
+
+ Push +
+
+
+
+ + Push + +
+
+ + + + +
+
+
+ Build +
+
+
+
+ + Build + +
+
+ + + + +
+
+
+
+ HTTP(s) WebHook +
+
+
+
+
+
+ + HTTP(... + +
+
+ + + + +
+
+
+ GitHub +
+
+
+
+ + GitHub + +
+
+ + + + +
+
+
+ Push +
+
+
+
+ + Push + +
+
+ + + + +
+
+
+ + Developer + +
+
+
+
+ + Develo... + +
+
+
+ + + + + Viewer does not support full SVG 1.1 + + + +
\ No newline at end of file diff --git a/md/075-BasicsOfContainers.md b/md/075-BasicsOfContainers.md index 56b25d1..3eb4302 100644 --- a/md/075-BasicsOfContainers.md +++ b/md/075-BasicsOfContainers.md @@ -46,7 +46,17 @@ After --- -# Containers +# What is a container? + +A **OS-level virtualization** software package. Allows **easy** and **reliable** development and deployment. +* Uses features of the Linux kernel (_cgroups_ and _namespaces_) to provide an isolated environment. + +.center[![:scale 70%, Run containers](../img/run_containers.drawio.svg)] + + +--- + +# Container characteristics .container[.col[ diff --git a/md/10-CreatingContainers.md b/md/10-CreatingContainers.md index 81c6836..16e206c 100644 --- a/md/10-CreatingContainers.md +++ b/md/10-CreatingContainers.md @@ -9,69 +9,91 @@ class: topicslide --- -# [Rahti] Creating a project +# Source2Image -.container[ - .col66[ +.container[.col[ -* Click in "Create Project" - * **Name**: Short name that will be used to reference the project - * **Display Name**: Descriptive name that should make clear what the project is - * **Description**: It **must** be: "csc_project: 2001316". It must be associated to a CSC project for billing purposes. -* Initial quota of 5 projects +Automatically builds and deploys code into Rahti: -] -.col[ -![:scale 80%, Logging page](/csc-cloud/img/creatingProject.png) +* Receives a GiT repository. Clones and analyses it. -]] +* Builds the container **image**. ---- +* Stores the image in the project registry -# [Rahti] How to open a terminal session +* Deploys the application -.container[ - .col66[ -![:scale 100%, Terminal in a Pod](/csc-cloud/img/terminalPod.png) - ].col[ - -* Go to the "Pods page" - **Applications** > **Pods** -* Click in the running Pod that you one to open an interactive session with -* Click in **Terminal** +].col[ + +```sh +oc new-app https://github.com/sclorg/django-ex +oc expose svc django-ex +``` + +![:scale 80%, Source2Image](../img/source2image.drawio.svg) ]] + + --- -# [Rahti] How to see application logs? +# Local build + +Build an image from you local computer using a [Dockerfile](https://docs.docker.com/engine/reference/builder/) "recipe". + +.container[.col[ + +* Dockerfile example: + +```Dockerfile +FROM centos/python-38-centos7 +COPY . /opt/app-root/ +WORKDIR /opt/app-root/ +RUN pip install -r requirements.txt +ENTRYPOINT ["/usr/libexec/s2i/run"]| +``` + +Similar to what a Source2Image process will do -.container[ - .col66[ -.center[![:scale 95%, View log GUI](/csc-cloud/img/viewLog.png)] - ] - .col[ +].col[ -* Go to the "Deployments page" - * **Applications** > **Deployments** -* Click in "View Log" +* Build: -![:scale 100%, View Log Page](/csc-cloud/img/viewLogPage.png) + * with: `docker build .` + * with: `buildah bud --format=docker` + * with: `docker buildx build .` +Different tools with different use cases in mind. ]] --- -# [Rahti] Editing API objects +# Auto triggered builds -.container[ - .col66[ -![:scale 100%, Edit Pod](/csc-cloud/img/editPod.png) - ].col[ +![webhook](../img/trigger.drawio.svg) -* Go to the objects page, in this case the "Pods page" -* Click in the object you want to edit. -* Click in **Actions** > **Edit YAML** +When a developer pushes code, an automatic process is started to bring changes to Rahti. + +.container[.col[ + +1. Code is pushed + +1. GitHub\* .footnote[\* or Gitlab, or any other alternative] has internal logic to trigger or not a build + +1. After the build is done, the image is stored internally + +1. A new image triggers a re-deployment + +].col[ + +Set it up by: + +* Create build: `oc new-build ` + +* Add the web hook: + * + +]] - ]] diff --git a/md/105-Webinterface-Howtos.md b/md/105-Webinterface-Howtos.md new file mode 100644 index 0000000..2226399 --- /dev/null +++ b/md/105-Webinterface-Howtos.md @@ -0,0 +1,77 @@ +layout: false +class: topicslide + +.topic[ + +# Web interface How-tos + +] + +--- + +# Creating a project + +.container[ + .col66[ + +* Click in "Create Project" + * **Name**: Short name that will be used to reference the project + * **Display Name**: Descriptive name that should make clear what the project is + * **Description**: It **must** be: "csc_project: 2001316". It must be associated to a CSC project for billing purposes. +* Initial quota of 5 projects + +] +.col[ +![:scale 80%, Logging page](/csc-cloud/img/creatingProject.png) + +]] + +--- + +# How to open a terminal session + +.container[ + .col66[ +![:scale 100%, Terminal in a Pod](/csc-cloud/img/terminalPod.png) + ].col[ + +* Go to the "Pods page" + **Applications** > **Pods** +* Click in the running Pod that you one to open an interactive session with +* Click in **Terminal** + +]] + +--- + +# How to see application logs? + +.container[ + .col66[ +.center[![:scale 95%, View log GUI](/csc-cloud/img/viewLog.png)] + ] + .col[ + +* Go to the "Deployments page" + * **Applications** > **Deployments** +* Click in "View Log" + +![:scale 100%, View Log Page](/csc-cloud/img/viewLogPage.png) + +]] + +--- + +# Editing API objects + +.container[ + .col66[ +![:scale 100%, Edit Pod](/csc-cloud/img/editPod.png) + ].col[ + +* Go to the objects page, in this case the "Pods page" +* Click in the object you want to edit. +* Click in **Actions** > **Edit YAML** + + ]] + diff --git a/md/11-OpenShiftCLI.md b/md/11-OpenShiftCLI.md index 3409b50..06da638 100644 --- a/md/11-OpenShiftCLI.md +++ b/md/11-OpenShiftCLI.md @@ -1,8 +1,186 @@ +layout: false +class: topicslide -# OpenShift CLI +.topic[ -- Exersise section might suffice for this - - or +# Kubernetes and OpenShift + +## CLI and API + +] + +--- + +# API Objects + +In Kubernetes/OpenShift everything is an object. Each object represents the **desired and current state** of an aspect of the application. + +.container[ + .col[ + +* Categories: + * Network + * Container, management and creation + * Job scheduling + * Runtime of containers + +* Represented in JSON or YAML format + +] + .col70[ +.center[![:scale 80%, Objects](/csc-cloud/img/Kubernetes-fuller.drawio.svg)] + ]] + +--- + +# OpenShift Command Line Interface + +.container[.col[ + +The most common advanced way to interact with the API is using the _command line interface_ tools. + +* `kubectl`, the Kubernetes command-line tool. + + * [Install kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/) + +* `oc`, the OpenShift command-line tool. `oc` features are a superset and has the same interface than `kubectl`. + * [How to install the oc tool](https://docs.csc.fi/cloud/rahti/usage/cli/#how-to-install-the-oc-tool) + +].col[ + +.right[![:scale 70%, Superset](../img/oc-v-kubectl.drawio.svg)] + +]] + +--- + +# Command line operations + +The following are the most common command line operations: + +.container[.col60[ + +* **LOGIN**, `oc login`. Could take a TOKEN or a username/password. +* **PROJECT MANAGEMENT**, `oc projects` and `oc new-project`. List, switch, and create projects. +* **INFORMATION**, `oc get` and `oc describe`. Describe is more detailed and human friendly, and get is more machine friendly (JSON and YAML outputs). +* **CREATE**, `oc create`. +* **MODIFY**, `oc edit` and `oc replace`. Edit is interactive. +* **DELETE**, `oc delete`. + +].col[ + +.right[![:scale 90%, Command Line](../img/command-line.drawio.svg)] + +]] + +--- + +# Project + +A project sandboxes API objects (Pods and others) in a common namespace. +.container[ + .col[ + +* Similar to **Namespace** + * (with extra features) +* Local **isolated network** + * For security reasons, projects can not access other projects by default. +* A project has: + * **Name**: Should be short and descriptive + * **Display Name**: Should be understandable + * **Description**: Must be `csc_project: 9999999` + * where `9999999` is the project number + + +].col[ +![:scale 100%, Project page](/csc-cloud/img/projectPage.png) +]] + +--- + +# Pod + +.container[ +.col[ + +* A pod is a collection of **containers** sharing a network and Inter-process communication namespace + * Containers live in one pod +* There is no *container object* in Kubernetes +* Nearly always one container per pod + * Ex: Sidecar container design pattern + +] +.maxhalf.col.padleft[ +.boxcol.container[ +.col[ + +```yaml +# my-pod.yaml +kind: Pod +apiVersion: v1 +metadata: + name: my-pod +spec: + containers: + - name: container-1 + image: container-1-image + - name: container-2 + image: container-2-image +``` + +] +.padleft.scaleimg.col[ +.center[![pod](/csc-cloud/img/pod-and-conts.drawio.svg) +]]] + +Communicate via: + +* localhost (network) +* shared folders (emptyDir) +* memory (Inter-process communication) + +]] + +--- + +# Service + +An API object that provides pods a **load balanced** stable network identity. + +.container[ + +.col[ + +* The IP of a Pod **may change**, the **IP** of a Service **will not change**. + * Pods should communicate with each other using services + +] +.col[ + +.center[![Service](/csc-cloud/img/servicePod.drawio.svg)] + +]] + +--- + +# Route + +.container[ +.col[ + +An API object that exposes a Service to the internet via HTTP/HTTPS. + +* Every host with the pattern `*.rahtiapp.fi` will point **automatically** to Rahti: + * `my-hello-openshift.rahtiapp.fi` is an alias for `rahtiapp.fi`. + + * If the host must be different to this pattern, a `DNS CNAME` entry must be configured by the user to point to `rahtiapp.fi`. +* Every host with the pattern `*.rahtiapp.fi` will have automatically a valid **TLS certificate**. + +] + +.col[ + +.center[![Route Service Pod](/csc-cloud/img/routeServicePod.drawio.svg)] + +]] -- Add overview content on OpenShift architecture, API and CLI diff --git a/md/12-AppDeployment.md b/md/12-AppDeployment.md index 45abe4d..ed74ef4 100644 --- a/md/12-AppDeployment.md +++ b/md/12-AppDeployment.md @@ -1,10 +1,14 @@ -# Deploying Containerized Applications +layout: false +class: topicslide -- Exersise section might suffice for this - - or +.topic[ -- Add overview content (e.g. packaging, adding route, etc ) +# Deployment of Applications +## by Example +] +--- + +# diff --git a/md/14-API.md b/md/14-API.md deleted file mode 100644 index cafc4e1..0000000 --- a/md/14-API.md +++ /dev/null @@ -1,139 +0,0 @@ -layout: false -class: topicslide - -.topic[ - -# Kubernetes/OpenShift API - -] - ---- - -# API Objects - -.container[ - .col[ - -In Kubernetes/OpenShift everything is a object - -* Set of API object **abstractions**: - * Network - * Container, management and creation - * Job scheduling - * Runtime of containers -] - .col70[ -.center[![:scale 85%, Objects](/csc-cloud/img/Kubernetes-fuller.drawio.svg)] - ]] - ---- - -# Project - -A project sandboxes API objects (Pods and others) in a common namespace. -.container[ - .col[ - -* Similar to **Namespace** - * (with extra features) -* Local **isolated network** - * For security reasons, projects can not access other projects by default. -* A project has: - * **Name**: Should be short and descriptive - * **Display Name**: Should be understandable - * **Description**: Must be `csc_project: 9999999` - * where `9999999` is the project number - - -].col[ -![:scale 100%, Project page](/csc-cloud/img/projectPage.png) -]] - ---- - -# Pod - -.container[ -.col[ - -* A pod is a collection of **containers** sharing a network and Inter-process communication namespace - * Containers live in one pod -* There is no *container object* in Kubernetes -* Nearly always one container per pod - * Ex: Sidecar container design pattern - -] -.maxhalf.col.padleft[ -.boxcol.container[ -.col[ - -```yaml -# my-pod.yaml -kind: Pod -apiVersion: v1 -metadata: - name: my-pod -spec: - containers: - - name: container-1 - image: container-1-image - - name: container-2 - image: container-2-image -``` - -] -.padleft.scaleimg.col[ -.center[![pod](/csc-cloud/img/pod-and-conts.drawio.svg) -]]] - -Communicate via: - -* localhost (network) -* shared folders (emptyDir) -* memory (Inter-process communication) - -]] - ---- - -# Service - -An API object that provides pods a **load balanced** stable network identity. - -.container[ - -.col[ - -* The IP of a Pod **may change**, the **IP** of a Service **will not change**. - * Pods should communicate with each other using services - -] -.col[ - -.center[![Service](/csc-cloud/img/servicePod.drawio.svg)] - -]] - ---- - -# Route - -.container[ -.col[ - -An API object that exposes a Service to the internet via HTTP/HTTPS. - -* Every host with the pattern `*.rahtiapp.fi` will point **automatically** to Rahti: - * `my-hello-openshift.rahtiapp.fi` is an alias for `rahtiapp.fi`. - - * If the host must be different to this pattern, a `DNS CNAME` entry must be configured by the user to point to `rahtiapp.fi`. -* Every host with the pattern `*.rahtiapp.fi` will have automatically a valid **TLS certificate**. - -] - -.col[ - -.center[![Route Service Pod](/csc-cloud/img/routeServicePod.drawio.svg)] - -]] -