Skip to main content

Kubernetes

What's k8s

Resource boundaries in different deployment era:

  • Traditional - No boundary
  • Virtualized - Isolated resource and security
  • Container - Bin + app

Facilitate Canary deployments

minikube

minikube provisions and manages local Kubernetes clusters optimized for development workflows.

MiniKube vs MicroK8s

Why k8s?

  • Service discovery and load balancing
  • Storage orchestration
  • Automated rollouts and rollbacks
  • Automatic bin packing
  • Self-healing
  • Secret and configuration management

k8s components

Control Plane Components

  • k8s cluster = a set of worker machines(nodes)
  • pods : smallest deployable units
  • kube-apiserver: Front end of control plane
  • etcd: distributed data store for cluster data.
  • kube-scheduler: allocate newly created pods to an available node.
  • kube-controller-manager: Node, Replication, Endpoints, Service Account & Token controller.
  • cloud-controller-manager: Node, Route, Service controller dependencies.

Node components

  • kubelet: manages docker to conform PodSpecs
  • kube-proxy: k8s service implementation.
  • Container runtime: Docker

Addons

  • DNS: For service and pods
  • Dashboard; UI
  • Container Resource Monitoring
  • Cluster-level Logging

K8s diagrams

k3s vs minikube vs kind

The Kubernetes API

Open API API object needs to handle buffer, xml or json?

Google developed protobuf before.

protobuf like design

Kubernetes Objects - "record of intent"

Kubernetes objects are persistent entities in the Kubernetes system.

  • Object Spec: describe the desired state
  • Status: current state of the object, managed by k8s control plane.

Management techniques

  • Imperative commands: kubectl
  • Imperative object config: .yaml file
  • Declarative object config: directory of files.

Troubleshooting: k8s error image pullbackoff

Object Names and IDs

  • Names: /api/v1/pods/some-name

  • IDs: UUID to track historical occurrences.

Namespaces

Virtual cluster

kubectl get namespace

Namespaces and DNS:

When you create a Service, it creates a corresponding DNS entry.

Labels and selectors

Labels = Identifying key/values

selectors: filtering via label.

  • equality-based : =, ==, !=

  • set-based : in,notin and exists

Annotations

arbitrary non-identifying metadata to objects.

Field Selectors

kubectl get pods --field-selector status.phase=Running

Cluster architecture

Nodes

Components: kubelet,

a container runtime, and the kube-proxy

Adding nodes:

  • kubelet can self-register

  • user manually add

Pod

Pod is the smallest deployable unit, one or more containers with shared resources and network. It can contain init containers and ephemeral containers for debugging.

Workload resource manage pods: Deployment or Job. track state StatefulSet