Kubernetes 101
Kubernetes 101
For Beginners
Unrestricted
Agenda
● Introduction ● Concepts
○ Legacy Systems ○ Core
○ Docker ○ Workloads
○ Docker-Compose ○ Network
○ Docker-Swarm ○ Storage
○ What isKubernetes? ○ Configuration
○ What doesKubernetes do? ○ Auth and Identity
○ Helm
● Architecture
○ MiniKube
○ MasterComponents
○ NodeComponents ● Behind theScenes
○ Additional Services ● Deployment from Beginning to
○ Kubectl End
○ Kube Config ● AKS Deployment Demo
○ End to End AKS Deployment
Introduction
Legacy Systems
Legacy App Deployment Model on Bare Metal Servers.
Legacy Systems
App Deployment on Virtual Machines Overview.
Welcome Docker
Virtual Machines vs Docker Containers
Virtual Machines
Virtual machines (VMs) are an abstraction of physical hardware turning one server into
many servers.
The hypervisor allows multiple VMs to run on a single machine.
Each VM includes a full copy of an operating system, the application, necessary binaries
and libraries - taking up tens of GBs.
VMs can also be slower to boot.
Container:
Containers are an abstraction at the app layer that packages code and dependencies together.
Multiple containers can run on the same machine and share the OS kernel with other containers,
each running as isolated processes in user space.
Containers typically take up less space than VMs.
Docker Workshops
Docker Basics:
https://www.katacoda.com/courses/docker/deploying-first-Container
Dockerize NodeJs:
https://www.katacoda.com/courses/docker/3
Compose is a tool for defining and running
multi-container Docker applications.
Workshop:
COMPOSE
https://www.katacoda.com/boxboat/courses/df-dev/02-docker-compose
Docker Swarm is a clustering and scheduling
tool for Docker containers.
Workshop:
SWARM
https://www.katacoda.com/courses/docker-orchestration/getting-started-with-swarm-mode
https://www.katacoda.com/boxboat/courses/df-ops/01-docker-swarm
=
Intro - What is Kubernetes?
Workshop:
https://www.katacoda.com/loodse/courses/kubernetes/kubernetes-01-playground
Kubernetes
Architecture
Architecture Overview
Masters - Acts as the primary control plane for Kubernetes. Masters are
responsible at a minimum for running the API Server, scheduler, and cluster
controller. They commonly also managestoring cluster state, cloud-provider
specific components and other cluster essential services.
Nodes -Are the ‘workers’ of a Kubernetes cluster. They run a minimal agent
that manages the node itself, and are tasked with executing workloads as
designated by the master.
Architecture
Overview
Master
Components
Master Components
● Kube-apiserver
● Etcd
● Kube-controller-manager
● Cloud-controller-manager
● Kube-scheduler
kube-apiserver
The apiserver provides aforward facing REST interface into the kubernetes
control plane and datastore. All clients, including nodes, users and other
applications interact with kubernetes strictly through the API Server.
Etcd acts as the cluster datastore; providing a strong, consistent and highly
available key-value store used for persisting cluster state.
kube-controller-manager
● Kubelet
● Kube-proxy
● Containerruntime engine
kubelet
Acts as the node agent responsible for managing pod lifecycle on its host.
Kubelet understands YAML container manifests that it can read from several
sources:
● File path
● HTTP Endpoint
● Etcd watch acting on any changes
● HTTP Server mode accepting container manifests over a simple API.
kube-proxy
Available ProxyModes:
● Userspace
● iptables
● ipvs (alpha in 1.8)
Container Runtime
● Containerd (docker)
● Cri-o
● Rkt
● Kata (formerly clear and hyper)
● Virtlet (VM CRI compatible runtime)
Additional Services
resource
KUBECTX:
https://github.com/ahmetb/kubectx
Workshops:
KubeAdm
https://www.katacoda.com/loodse/courses/kubernetes/kubernetes-03-cluster-
setup
App Deployment:
https://www.katacoda.com/boxboat/courses/kubernetes-basic/module-2
Kubernetes
Concepts
Kubernetes Concepts - Core
Cluster - A collection of hosts that aggregate their available resources including cpu, ram,disk,
and their devices into ausable pool.
Master - The master(s)represent a collection of components that makeup the control plane of
Kubernetes. These components are responsible for all cluster decisions including both
scheduling and responding to cluster events.
Node - A single host, physical or virtual capable of running pods. A node is managedby the
master(s), and at a minimum runs both kubelet and kube-proxy to be considered part of the
cluster.
Label - Key-value pairs that are used to identify, describe and group together related sets of
objects. Labels have astrict syntax and available character set.*
Selector - Selectors use labels to filter or select objects. Both equality-based (=,==,!=)or
simple key-value matching selectors are supported.
* https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#syntax-and-character-set
Labels, and Annotations,
and Selectors
Labels:
app:nginx
tier: frontned
Annotations
description: “nginxfrontend”
Selector:
app:nginx
tier: frontend
Concepts - Workloads
Pod - A pod is the smallest unit of work or management resource within Kubernetes. It is
comprised of one or more containers that share their storage, network, and context
(namespace, cgroupsetc).
Workshop:
https://www.katacoda.com/boxb
oat/courses/kf1/03-deployments
Concepts - Workloads (cont.)
StatefulSet - A controller tailored to managing Pods that must persist or maintain state.Pod
identity including hostname,network, and storagewill be persisted.
DaemonSet - Ensures that all nodes matching certain criteria will run aninstance of a
supplied Pod. Ideal for cluster wide services such aslog forwarding, or health monitoring.
StatefulSet
● Bypasses defaultscheduler
● Schedules asingle instance on every host while
adhering to tolerances and taints.
Workshop:
https://www.katacoda.com/reselbob/scenario
s/k8s-daemonset-w-node-affinity
Concepts – Network
Networking - Fundamental Rules
1) All Pods can communicate with all other Pods without NAT
2) All nodes can communicate with all Pods (andvice-versa) without NAT.
3) The IP that aPod sees itself as is the same IP that others see it as.
Networking - Fundamentals Applied
Containers in a pod exist within the same network namespace and share an
IP;allowing for intrapod communication over localhost.
Pods are given a cluster unique IP for the duration of its lifecycle, but the pods
themselves are fundamentally ephemeral.
Services are given a persistent cluster unique IP that spans the Pods lifecycle.
Service - Services provide amethod of exposing and consuming L4 Pod network accessible
resources. They use label selectors to map groups of pods and ports to a cluster-unique virtual
IP.
Ingress - An ingress controller is the primary method of exposing a cluster service (usually
http) to the outside world. These are load balancers or routers that usually offer SSL
termination, name-basedvirtual hosting etc.
Service
Workshop:
https://www.katacoda.com/boxboat/courses/kf2/01-services
Ingress Controller
Workshop:
https://www.katacoda.com/boxboat/courses/kf2/03-ingress
Concepts - Storage
Volume - Storage that is tied to the Pod Lifecycle, consumable by one or more
containers within the pod.
Workshop:
https://www.katacoda.com/courses/kubernetes/storage-introduction
Concepts -Configuration
Secret - Functionally identical to ConfigMaps, but stored encoded asbase64, and encrypted at
rest (ifconfigured).
ConfigMaps and Secrets
Workshop:
https://www.katacoda.com/javajon/courses/kubernetes-fundamentals/configmap-secret
Concepts - Auth and Identity (RBAC)
[Cluster]Role - Roles contain rules that act as a set of permissions that apply verbs like “get”,
“list”, “watch” etc over resources that are scoped to apiGroups. Roles are scoped to namespaces,
and ClusterRoles are applied cluster-wide.
Workshop:
https://www.katacoda.com/boxboat/courses/kf2/04-misc
[Cluster]Role
https://www.katacoda.com/javajon/courses/kubernetes-fundamentals/minikube
Behind
The Scenes
Deployment From
Beginning to End
Kubectl
7)Initializers are given opportunity to mutate request before the object is published.
12)ReplicaSet ispublished.
ReplicaSet Controller
27)If there are any liveless/readiness probes, these are executed before the
PodStatus isupdated.
28)If all complete successfully, PodStatus is set to ready and the container
has startedsuccessfully.
1. https://www.slideshare.net/BobKillen?utm_campaign=profiletracking&ut
m_medium=sssite&utm_source=ssslideview
2. https://www.katacoda.com/
3. https://kubernetes.io/