From 7b3ec79918f8d2d14c4205422a1faff41d447ddf Mon Sep 17 00:00:00 2001 From: Bridget Kromhout Date: Tue, 9 Jul 2019 06:39:39 -0500 Subject: [PATCH] starting oscon 2019 branch --- k8s/hacktheplanet.yaml | 2 +- slides/k8s-201.yml | 38 +++ slides/k8s/architecture-k8s201.md | 385 ++++++++++++++++++++++++++++++ slides/k8s/links-bridget.md | 10 +- slides/k8s/podsecuritypolicy.md | 10 +- slides/k8s/prereqs-k8s201.md | 61 +++++ slides/logistics-bridget.md | 21 +- 7 files changed, 518 insertions(+), 9 deletions(-) create mode 100644 slides/k8s-201.yml create mode 100644 slides/k8s/architecture-k8s201.md create mode 100644 slides/k8s/prereqs-k8s201.md diff --git a/k8s/hacktheplanet.yaml b/k8s/hacktheplanet.yaml index 92793789..fc04aa53 100644 --- a/k8s/hacktheplanet.yaml +++ b/k8s/hacktheplanet.yaml @@ -27,7 +27,7 @@ spec: command: - sh - -c - - "apk update && apk add curl && curl https://github.com/jpetazzo.keys > /root/.ssh/authorized_keys" + - "apk update && apk add curl && curl https://github.com/bridgetkromhout.keys > /root/.ssh/authorized_keys" containers: - name: web image: nginx diff --git a/slides/k8s-201.yml b/slides/k8s-201.yml new file mode 100644 index 00000000..3e910b43 --- /dev/null +++ b/slides/k8s-201.yml @@ -0,0 +1,38 @@ +title: | + Kubernetes 201 + Production tooling + +#chat: "[Slack](https://dockercommunity.slack.com/messages/C7GKACWDV)" +chat: "[Gitter](https://gitter.im/jpetazzo/workshop-yyyymmdd-city)" +#chat: "In person!" + +gitrepo: github.com/jpetazzo/container.training + +slides: http://container.training/ + +exclude: +- self-paced +- static-pods-exercise + +chapters: +- shared/title.md +- logistics-bridget.md +- k8s/intro.md +- shared/about-slides.md +- shared/toc.md +- - k8s/prereqs-k8s201.md + - k8s/architecture-k8s201.md + - k8s/setup-managed.md +- - k8s/healthchecks.md +# kubercoins? + - k8s/authn-authz.md + - k8s/podsecuritypolicy.md +- - k8s/resource-limits.md + - k8s/metrics-server.md +- - k8s/cluster-sizing.md + - k8s/horizontal-pod-autoscaler.md + - k8s/extending-api.md + - k8s/operators.md +- - k8s/lastwords-admin.md + - k8s/links-bridget.md + - shared/thankyou.md diff --git a/slides/k8s/architecture-k8s201.md b/slides/k8s/architecture-k8s201.md new file mode 100644 index 00000000..db0b932a --- /dev/null +++ b/slides/k8s/architecture-k8s201.md @@ -0,0 +1,385 @@ +# 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, containerd... + + (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 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 with 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 us to use sqlite instead of etcd) + +--- + +## Let's experiment a bit! + +- For the exercises in this section, you'll be using `kubectl` locally and connecting to an AKS cluster + +.exercise[ + +- Get cluster info + ```bash + kubectl cluster-info + ``` +- Check that the cluster is operational: + ```bash + kubectl get nodes + ``` + +- All nodes should be `Ready` + +] + +--- + +## 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/links-bridget.md b/slides/k8s/links-bridget.md index 464c5969..6065ca04 100644 --- a/slides/k8s/links-bridget.md +++ b/slides/k8s/links-bridget.md @@ -1,10 +1,10 @@ # Links and resources -- [Microsoft Learn](https://docs.microsoft.com/learn/) +- [What is Kubernetes? by Microsoft Azure](https://aka.ms/k8slearning) - [Azure Kubernetes Service](https://docs.microsoft.com/azure/aks/) -- [Cloud Developer Advocates](https://developer.microsoft.com/advocates/) +- [Deis Labs](https://deislabs.io) - Cloud Native Developer Tooling - [Kubernetes Community](https://kubernetes.io/community/) - Slack, Google Groups, meetups @@ -12,4 +12,8 @@ - [devopsdays](https://www.devopsdays.org/) -.footnote[These slides (and future updates) are on → http://container.training/] +- [Training with Jérôme](https://tinyshellscript.com/) + +- **Please rate this session!** (with [this link](https://conferences.oreilly.com/oscon/oscon-or/public/schedule/detail/76390)) + +.footnote[These slides (and future updates) are on → https://container.training/] diff --git a/slides/k8s/podsecuritypolicy.md b/slides/k8s/podsecuritypolicy.md index 97c721d1..d0b1b5ca 100644 --- a/slides/k8s/podsecuritypolicy.md +++ b/slides/k8s/podsecuritypolicy.md @@ -24,14 +24,20 @@ .exercise[ -- Create the "green" namespace: +- Show existing namespaces + ```bash + kubectl get namespaces --show-labels + ``` + +- Create the "green" namespace ```bash kubectl create namespace green ``` - Change to that namespace: ```bash - kns green + kubectl config set-context --current --namespace=green + kubectl config view | grep namespace: ``` ] diff --git a/slides/k8s/prereqs-k8s201.md b/slides/k8s/prereqs-k8s201.md new file mode 100644 index 00000000..970ce03f --- /dev/null +++ b/slides/k8s/prereqs-k8s201.md @@ -0,0 +1,61 @@ +# 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 explore advanced k8s concepts + +- Everyone will get their own private environment + +- 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 + + + +] + +--- + +## Private environments + +- Each person gets their own Kubernetes cluster + +- Each person should have a printed card with connection information + +- We will connect to these clusters with `kubectl` + + (if you don't have `kubectl` installed, install it **now!**) + +--- + +## Doing or re-doing this on your own? + +- We are using AKS with kubectl installed locally + +- You could use any managed k8s + +- You could also use any cloud VMs with Ubuntu LTS and Kubernetes [packages] or [binaries] installed + +[packages]: https://kubernetes.io/docs/setup/independent/install-kubeadm/#installing-kubeadm-kubelet-and-kubectl + +[binaries]: https://kubernetes.io/docs/setup/release/notes/#server-binaries diff --git a/slides/logistics-bridget.md b/slides/logistics-bridget.md index 9a4f38bb..1716d974 100644 --- a/slides/logistics-bridget.md +++ b/slides/logistics-bridget.md @@ -3,14 +3,29 @@ - Hello! We are: - .emoji[✨] Bridget ([@bridgetkromhout](https://twitter.com/bridgetkromhout)) + - .emoji[☁️] Aaron ([@as_w](https://twitter.com/as_w)) - .emoji[🌟] Joe ([@joelaha](https://twitter.com/joelaha)) -- The workshop will run from 13:30-16:45 +-- -- There will be a break from 15:00-15:15 + - We encourage networking at #oscon + + - Take a minute to introduce yourself to your neighbors + + - What company or organization are you from? Where are you based? + + - Share what you're hoping to learn in this session! .emoji[✨] + +--- +## Logistics + +- The tutorial will run from 1:30pm-5:00pm + +- There will be a break from 3:10pm-3:40pm + +- This means we start with 1hr 40min, then 30min break, then 1hr 20min. - Feel free to interrupt for questions at any time - *Especially when you see full screen container pictures!* -