KEMBAR78
Kubernetes fundamentals | PPTX
Kubernetes fundamentals
Victor Morales
Victor Morales
• +15 yrs as a Software Engineer
• .NET, Java, python, Go programmer
• OpenStack, OPNFV, ONAP and CNCF
contributor.
https://about.me/electrocucaracha
Agenda
1. Kubernetes Architecture
• Control Plane components
• kubectl
• Controller Pattern
• Scheduler
• Node components
2. Kubernetes Installers
• Kubeadm
• Kubespray
• Kind
3. Kubernetes Resources
• Scopes Namespace or Cluster
• Pod
• Service and Labels
• Deployment and ReplicaSets
4. Demo
• Autoscaling strategies
• Horizontal Pod Autoscaler
Kubernetes Architecture
Kubernetes (K8s) is an
open-source system for
automating deployment,
scaling, and management
of containerized
applications.
Control Plane
components
• kube-apiserver: Exposes the Kubernetes API.
• etcd: Used as Kubernetes' backing store for all
cluster data.
• kube-scheduler: Watches for newly created Pods
with no assigned node, and selects a node for
them to run on.
• kube-controller-manager: Runs controller
processes.
• Node controller: Responsible for noticing and
responding when nodes go down.
• Replication controller: Responsible for maintaining the
correct number of pods for every replication controller
object in the system.
• Endpoints controller: Populates the Endpoints object
(that is, joins Services & Pods).
• Service Account & Token controllers: Create default
accounts and API access tokens for new namespaces
• cloud-controller-manager: Embeds cloud-specific
control logic.
master
kube-apiserver
kube-controller-managerkube-scheduler
etcd
cloud-controller-manager
kubectl
Tool that makes it easy to
use kubectl plugins.
The Kubernetes command-
line tool which allows you
to run commands against
Kubernetes clusters.
Controller pattern
A controller tracks at least one Kubernetes resource type. These objects have
a spec field that represents the desired state. The controller(s) for that
resource are responsible for making the current state come closer to that
desired state.
https://blog.container-solutions.com/kubernetes-operators-explained
kube-scheduler
The scheduler finds feasible Nodes
for a Pod and then runs a set of
functions to score the feasible
Nodes* and picks a Node with the
highest score among the feasible
ones to run the Pod. The
scheduler then notifies the API
server about this decision in a
process called binding.
*Nodes that meet the scheduling requirements for a Pod are called feasible nodes.
Feasible nodes
worker worker2 worker3 worker4
Feasible nodes
worker worker3
Filtering
Feasible nodes
worker worker3
Scoring
Priority 2 Priority 4
https://kubernetes.io/docs/concepts/scheduling-eviction/kube-scheduler/
Node components
• kubelet: Makes sure that containers are
running in a Pod.
• kube-proxy: Maintains network rules on
nodes. These network rules allow network
communication to your Pods from network
sessions inside or outside of your cluster.
• Container Runtime: Responsible for running
containers. (docker, containerd, CRI-O)
• Add-ons: Extend the functionality of
Kubernetes.
worker
kubelet
kube-proxy
docker
flannel
kubernetes-dashboard
coredns
Kubernetes Installers
Kubeadm
It is a tool built to provide best-practice
"fast paths" for creating Kubernetes
clusters. It performs the actions
necessary to get a minimum viable,
secure cluster up and running in a user
friendly way.
https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/create-cluster-kubeadm/
https://github.com/kubernetes/kubeadm
KinD
It is a tool for running local Kubernetes
clusters using Docker container “nodes”.
kind was primarily designed for testing
Kubernetes itself, but may be used for
local development or CI.
https://kind.sigs.k8s.io/
Kubespray
It deploys a Production-Ready
Kubernetes Cluster on bare
metal and most clouds, using
Ansible as its substrate for
provisioning and orchestration.
https://kubespray.io/#/
Kubernetes Resources
Namespaces
Help different
projects, teams, or
customers to share a
Kubernetes cluster.
control-plane
K8s cluster
worker worker2 worker3
pod1
deployment-1
pod2
pod1
deployment-1
pod2
namespace-1
namespace-2
API resources
https://v1-18.docs.kubernetes.io/docs/reference/generated/kubernetes-api/v1.18/
Cluster-scoped resources
Ingress
Manages external access to the services in a cluster, typically HTTP.
https://kubernetes.io/docs/concepts/services-networking/ingress/
Namespace-scoped resources
Pod A Pod is a Kubernetes abstraction that represents a group of
one or more application containers (such as Docker or rkt), and
some shared resources for those containers. Pods are the
atomic unit on the Kubernetes platform.
Service and Labels
A Service is an abstraction which defines
a logical set of Pods and a policy by
which to access them. The set of Pods
targeted by a Service is usually
determined by a LabelSelector.
Services match a set of Pods using labels
and selectors, a grouping primitive that
allows logical operation on objects in
Kubernetes. Labels are key/value pairs
attached to objects.
Deployment and ReplicaSets
A ReplicaSet’s purpose is to maintain a
stable set of replica Pods running at any
given time. As such, it is often used to
guarantee the availability of a specified
number of identical Pods.
A Deployment controller provides
declarative updates for Pods and
ReplicaSets.
Demo
https://github.com/electrocucaracha/k8s-HorizontalPodAutoscaler-demo
Autoscaling
strategies
• Horizontal Pod Autoscaler (HPA):
adjusts the number of replica Pods of an
application. (scale out/in)
• Vertical Pod Autoscaler (VPA): adjusts
the resource requests and limits of the
containers of an application. (scale
up/down)
• Cluster Autoscaler: adjusts the number
of nodes of the cluster.
control-plane
K8s cluster
worker worker2
pod1
deployment-1
pod1
pod2 pod3 pod4
HPA VPA Cluster Autoscalerhttps://d1smfj0g31qzek.cloudfront.net/above_the_clouds.ppt.pdf
Horizontal Pod
Autoscaler
• Resource Metrics API serves predefined resource usage metrics.
• Custom Metrics API serves user-specified custom metrics that are
associated with Kubernetes objects in the cluster.
• External Metrics API serves user-defined custom metrics that are
not associated with any Kubernetes objects.
https://itnext.io/autoscaling-apps-on-kubernetes-with-the-horizontal-pod-autoscaler-798750ab7847
Controller
Manager
Metrics APIMetrics
Collector
cpustats
Prometheus
Prometheus
Adapter
Horizontal Pod
Autoscaler
Scale out/in
/metrics
processed_requests_total
processed_requests_per_second
Kubernetes fundamentals

Kubernetes fundamentals

  • 1.
  • 2.
    Victor Morales • +15yrs as a Software Engineer • .NET, Java, python, Go programmer • OpenStack, OPNFV, ONAP and CNCF contributor. https://about.me/electrocucaracha
  • 3.
    Agenda 1. Kubernetes Architecture •Control Plane components • kubectl • Controller Pattern • Scheduler • Node components 2. Kubernetes Installers • Kubeadm • Kubespray • Kind 3. Kubernetes Resources • Scopes Namespace or Cluster • Pod • Service and Labels • Deployment and ReplicaSets 4. Demo • Autoscaling strategies • Horizontal Pod Autoscaler
  • 4.
  • 5.
    Kubernetes (K8s) isan open-source system for automating deployment, scaling, and management of containerized applications.
  • 6.
    Control Plane components • kube-apiserver:Exposes the Kubernetes API. • etcd: Used as Kubernetes' backing store for all cluster data. • kube-scheduler: Watches for newly created Pods with no assigned node, and selects a node for them to run on. • kube-controller-manager: Runs controller processes. • Node controller: Responsible for noticing and responding when nodes go down. • Replication controller: Responsible for maintaining the correct number of pods for every replication controller object in the system. • Endpoints controller: Populates the Endpoints object (that is, joins Services & Pods). • Service Account & Token controllers: Create default accounts and API access tokens for new namespaces • cloud-controller-manager: Embeds cloud-specific control logic. master kube-apiserver kube-controller-managerkube-scheduler etcd cloud-controller-manager
  • 7.
    kubectl Tool that makesit easy to use kubectl plugins. The Kubernetes command- line tool which allows you to run commands against Kubernetes clusters.
  • 8.
    Controller pattern A controllertracks at least one Kubernetes resource type. These objects have a spec field that represents the desired state. The controller(s) for that resource are responsible for making the current state come closer to that desired state. https://blog.container-solutions.com/kubernetes-operators-explained
  • 9.
    kube-scheduler The scheduler findsfeasible Nodes for a Pod and then runs a set of functions to score the feasible Nodes* and picks a Node with the highest score among the feasible ones to run the Pod. The scheduler then notifies the API server about this decision in a process called binding. *Nodes that meet the scheduling requirements for a Pod are called feasible nodes. Feasible nodes worker worker2 worker3 worker4 Feasible nodes worker worker3 Filtering Feasible nodes worker worker3 Scoring Priority 2 Priority 4 https://kubernetes.io/docs/concepts/scheduling-eviction/kube-scheduler/
  • 10.
    Node components • kubelet:Makes sure that containers are running in a Pod. • kube-proxy: Maintains network rules on nodes. These network rules allow network communication to your Pods from network sessions inside or outside of your cluster. • Container Runtime: Responsible for running containers. (docker, containerd, CRI-O) • Add-ons: Extend the functionality of Kubernetes. worker kubelet kube-proxy docker flannel kubernetes-dashboard coredns
  • 11.
  • 12.
    Kubeadm It is atool built to provide best-practice "fast paths" for creating Kubernetes clusters. It performs the actions necessary to get a minimum viable, secure cluster up and running in a user friendly way. https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/create-cluster-kubeadm/ https://github.com/kubernetes/kubeadm
  • 13.
    KinD It is atool for running local Kubernetes clusters using Docker container “nodes”. kind was primarily designed for testing Kubernetes itself, but may be used for local development or CI. https://kind.sigs.k8s.io/
  • 14.
    Kubespray It deploys aProduction-Ready Kubernetes Cluster on bare metal and most clouds, using Ansible as its substrate for provisioning and orchestration. https://kubespray.io/#/
  • 15.
  • 16.
    Namespaces Help different projects, teams,or customers to share a Kubernetes cluster. control-plane K8s cluster worker worker2 worker3 pod1 deployment-1 pod2 pod1 deployment-1 pod2 namespace-1 namespace-2
  • 17.
  • 18.
  • 19.
    Ingress Manages external accessto the services in a cluster, typically HTTP. https://kubernetes.io/docs/concepts/services-networking/ingress/
  • 20.
  • 21.
    Pod A Podis a Kubernetes abstraction that represents a group of one or more application containers (such as Docker or rkt), and some shared resources for those containers. Pods are the atomic unit on the Kubernetes platform.
  • 22.
    Service and Labels AService is an abstraction which defines a logical set of Pods and a policy by which to access them. The set of Pods targeted by a Service is usually determined by a LabelSelector. Services match a set of Pods using labels and selectors, a grouping primitive that allows logical operation on objects in Kubernetes. Labels are key/value pairs attached to objects.
  • 23.
    Deployment and ReplicaSets AReplicaSet’s purpose is to maintain a stable set of replica Pods running at any given time. As such, it is often used to guarantee the availability of a specified number of identical Pods. A Deployment controller provides declarative updates for Pods and ReplicaSets.
  • 24.
  • 25.
    Autoscaling strategies • Horizontal PodAutoscaler (HPA): adjusts the number of replica Pods of an application. (scale out/in) • Vertical Pod Autoscaler (VPA): adjusts the resource requests and limits of the containers of an application. (scale up/down) • Cluster Autoscaler: adjusts the number of nodes of the cluster. control-plane K8s cluster worker worker2 pod1 deployment-1 pod1 pod2 pod3 pod4 HPA VPA Cluster Autoscalerhttps://d1smfj0g31qzek.cloudfront.net/above_the_clouds.ppt.pdf
  • 26.
    Horizontal Pod Autoscaler • ResourceMetrics API serves predefined resource usage metrics. • Custom Metrics API serves user-specified custom metrics that are associated with Kubernetes objects in the cluster. • External Metrics API serves user-defined custom metrics that are not associated with any Kubernetes objects. https://itnext.io/autoscaling-apps-on-kubernetes-with-the-horizontal-pod-autoscaler-798750ab7847
  • 27.

Editor's Notes

  • #10 https://levelup.gitconnected.com/kubernetes-scheduler-101-751f65841fa0
  • #22 https://12factor.net/
  • #26 https://medium.com/swlh/applications-autoscaling-strategy-in-kubernetes-50535683322f https://cdn2.hubspot.net/hubfs/498921/eBooks/scalability_new.pdf
  • #28 https://levelup.gitconnected.com/building-kubernetes-apps-with-custom-scaling-a-gentle-introduction-a332d7ebc795