From ef70ed8006372a483bf758f0ac02395a8101a7c8 Mon Sep 17 00:00:00 2001 From: Jerome Petazzoni Date: Thu, 4 Apr 2019 09:33:04 -0500 Subject: [PATCH] Pre-requirements + Architecture sections --- slides/k8s/architecture.md | 364 ++++++++++++++++++++++++++++++++++++ slides/k8s/prereqs-admin.md | 63 +++++++ 2 files changed, 427 insertions(+) create mode 100644 slides/k8s/architecture.md create mode 100644 slides/k8s/prereqs-admin.md diff --git a/slides/k8s/architecture.md b/slides/k8s/architecture.md new file mode 100644 index 00000000..3efc8712 --- /dev/null +++ b/slides/k8s/architecture.md @@ -0,0 +1,364 @@ +# Kubernetes architecture + +We can arbitrarily split Kubernetes in two parts: + +- the *nodes*, a set of machines that run our containerized workloads; + +- the *control plane*, a set of processes implementing the Kubernetes APIs. + +Kubernetes also relies on underlying infrastructure: + +- servers, network connectivity (obviously!), + +- optional components like storage systems, load balancers ... + +--- + +## Control plane location + +The control plane can run: + +- in containers, on the same nodes that run other application workloads + + (example: Minikube; 1 node runs everything) + +- on a dedicated node + + (example: a cluster installed with kubeadm) + +- on a dedicated set of nodes + + (example: Kubernetes The Hard Way; kops) + +- outside of the cluster + + (example: most managed clusters like AKS, EKS, GKE) + +--- + +class: pic + +![Kubernetes architecture diagram: control plane and nodes](images/k8s-arch2.png) + +--- + +## What runs on a node + +- Our containerized workloads + +- A container engine like Docker, CRI-O, container... + + (in theory, the choice doesn't matter, as the engine is abstracted by Kubernetes) + +- kubelet: an agent connecting the node to the cluster + + (it connects to the API server, registers the node, receives instructions) + +- kube-proxy: a component used for internal cluster communication + + (note that this is *not* an overlay network or a CNI plugin!) + +--- + +## What's in the control plane + +- Everything is stored in an etcd + + (it's the only stateful component) + +- Everyone communicates exclusively through the API server: + + - we (users) interact with the cluster through the API server + + - the nodes register and get their instructions through the API server + + - the other control plane components also register to the API server + +- API server is the only component that reads/writes from/to etcd + +--- + +## Communication protocols: API server + +- The API server exposes a REST API + + (except for some calls, e.g. to attach interactively to a container) + +- Almost all requests and responses are JSON following a strict format + +- For performance, the requests and responses can also be done over protobuf + + (see this [design proposal](https://github.com/kubernetes/community/blob/master/contributors/design-proposals/api-machinery/protobuf.md) for details) + +- In practice, protobuf is used for all internal communication + + (between control plane components, and with kubelet) + +--- + +## Communication protocols: on the nodes + +The kubelet agent uses a number of special-purpose protocols and interfaces, including: + +- CRI (Container Runtime Interface) + + - used for communication with the container engine + - abstracts the differences between container engines + - based on gRPC+protobuf + +- [CNI (Container Network Interface)](https://github.com/containernetworking/cni/blob/master/SPEC.md) + + - used for communication with network plugins + - network plugins are implemented as executable programs invoked by kubelet + - network plugins provide IPAM + - network plugins set up network interfaces in pods + +--- + +class: pic + +![Kubernetes architecture diagram: communication between components](images/k8s-arch4-thanks-luxas.png) + +--- + +# The Kubernetes API + +[ +*The Kubernetes API server is a "dumb server" which offers storage, versioning, validation, update, and watch semantics on API resources.* +]( +https://github.com/kubernetes/community/blob/master/contributors/design-proposals/api-machinery/protobuf.md#proposal-and-motivation +) + +([Clayton Coleman](https://twitter.com/smarterclayton), Kubernetes Architect and Maintainer) + +What does that mean? + +--- + +## The Kubernetes API is declarative + +- We cannot tell the API, "run a pod" + +- We can tell the API, "here is the definition for pod X" + +- The API server will store that definition (in etcd) + +- *Controllers* will then wake up and create a pod matching the definition + +--- + +## The core features of the Kubernetes API + +- We can create, read, update, and delete objects + +- We can also *watch* objects + + (be notified when an object changes, or when an object of a given type is created) + +- Objects are strongly typed + +- Types are *validated* and *versioned* + +- Storage and watch operations are provided by etcd + + (note: the [k3s](https://k3s.io/) project allows to use sqlite instead of etcd) + +--- + +## Create + +- Let's create a simple object + +.exercise[ + +- Create a namespace with the following command: + ```bash + kubectl create -f- < + (example: this [demo scheduler](https://github.com/kelseyhightower/scheduler) uses the cost of nodes, stored in node annotations) + +- A pod might stay in `Pending` state for a long time: + + - if the cluster is full + + - if the pod has special constraints that can't be met + + - if the scheduler is not running (!) diff --git a/slides/k8s/prereqs-admin.md b/slides/k8s/prereqs-admin.md new file mode 100644 index 00000000..e3f77154 --- /dev/null +++ b/slides/k8s/prereqs-admin.md @@ -0,0 +1,63 @@ +# Pre-requirements + +- Kubernetes concepts + + (pods, deployments, services, labels, selectors) + +- Hands-on experience working with containers + + (building images, running them; doesn't matter how exactly) + +- Familiar with the UNIX command-line + + (navigating directories, editing files, using `kubectl`) + +--- + +## Labs and exercises + +- We are going to build and breaks multiple clusters + +- Everyone will get their own private environment(s) + +- You are invited to reproduce all the demos (but you don't have to) + +- All hands-on sections are clearly identified, like the gray rectangle below + +.exercise[ + +- This is the stuff you're supposed to do! + +- Go to @@SLIDES@@ to view these slides + +- Join the chat room: @@CHAT@@ + + + +] + +--- + +## Private environments + +- Each person gets their own private set of VMs + +- Each person should have a printed card with connection information + +- We will connect to these VMs with SSH + + (if you don't have an SSH client, install one **now!**) + +--- + +## Doing or re-doing this on your own? + +- We are using basic cloud VMs with Ubuntu LTS + +- The Kubernetes packages have been installed + + (from official repos) + +- We disabled IP address checks + + (to allow pod IP addresses to be carried by the cloud network)