Kubernetes Knowledge
Kip Landergren
(Updated: )
My Kubernetes knowledge base explaining the control plane, pods, network ingress, and cluster management using minikube and kubectl.
Contents
- Overview
- Core Idea
- Key Concepts
- Kubernetes Terminology
- How to Learn Kubernetes
- minikube
- kubectl
- helm
Overview
Kubernetes is an infrastructure orchestration tool. It abstracts your compute resources into a cluster of nodes that you can run your applications on. Kubernetes uses a control loop to constantly monitor and manage the state of your cluster against a desired state defined by you, either through imperative commands or through declarative statements in configuration files.
A cluster is managed by the Kubernetes “Control Plane” which is comprised of a master node and various Kubernetes-internal Services. The control plane communicates with the kubelet
Service running on each node in the cluster. This communication spurs the creation of Kubernetes objects that comprise your application.
The smallest working Kubernetes object is a “Pod”. A Pod is the host environment within which a collection of one or more containers are run. Pods are generally considered disposable and ephemeral—any higher level behavior is managed by a “Controller”.
Note: the containers running within a Pod are implementation-agnostic. While the same syntax is used as Docker, other containerization technologies may be used.
A Controller manages high level component behavior by coordinating the life-cycle, monitoring, and scaling of a set of Pods. Together these Pods may comprise a component such as a web service, database, or custom code.
While a Controller unites the management of Pods, access to the component is united through a “Service” object. A Service is simply a set of Pods identified using label selectors. One can configure Services for external or internal access and its definition provides a convenient abstraction over having to manage discovery and registration yourself.
There are multiple ways to externally access a cluster. One way is through an “Ingress Controller” which exists at the edge of your cluster network and manages HTTP/s access to cluster components. All external callers must go through this Ingress Controller, which may be configured with rules and options to route requests appropriately.
The definition of a cluster and its components is accomplished through either imperative commands via kubectl
or through declarative object definitions in config files. These objects being defined allow you to richly describe the properties and behaviors of your cluster components and provide a built-in mechanism for transitioning those components from one state to another (such as through deployment or reversion).
Core Idea
Define the structure of your cloud components, how they should scale, and hand over to Kubernetes to manage.
Key Concepts
Containerization
The process of packaging applications using host-level isolation. Various containerization technologies are supported, but Docker is most common.
Cluster Management
Define how a cluster should work and let Kubernetes build and manage it, abstracting away the underlying server and networking infrastructure.
Kubernetes Terminology
- cluster
- a set of nodes running containerized applications
- container
- a runnable instance of an image. also a loosely isolated environment
- control plane
- the master system managing the cluster, comprised of a master node and various Kubernetes-internal services
- controller
- object that manages high level component behavior through pod management
- image
- a read-only template with instructions for creating a compute environment
- manifest
- the YAML configuration file describing an object
- node
- a worker machine configured to run pods and be managed by the control plane
- pod
- the host environment within which a collection of one or more containers are run
- service
- object representing a set of pods identified using label selectors
How to Learn Kubernetes
- Learn Docker
- Install
minikube
- Read and understand the Official User Guide / Concept Documentation
- Build local applications using
minikube
andkubectl
minikube
minikube
is a tool that provisions and manages a single-node Kubernetes cluster optimized for local development. Instead of creating a cloud-based cluster every time you want to work on something, minikube
creates a single-node cluster inside a virtual machine running locally on your dev machine.
The version of kubernetes running within minikube
is controlled by the --kubernetes-version
flag.
Accessing Local Docker Images
Locally built images are able to be referenced from kubernetes config files if they are built using the Docker daemon configured with minikube
. Refer to Kubernetes Reference for details on how to configure.
Images are also available through hosting a local image registry, but I do not have that configured.
kubectl
kubectl
controls the Kubernetes cluster manager. The version of kubectl
is critical to choose based on your cluster version and Kubernetes’s version skew policy.
Pronounced “cube-control”, “cube-cuttle”, or “cube-see-tee-ell”.
Note: Docker for Mac puts a version in /usr/local/bin
that, even if unlinked, will be re-linked on restart. Docker for Mac will respect if you have a kubectl in that location.
helm
Billed as the “Kubernetes package manager”, helm
helps manage and provide access to “charts”, which are packaged recipes for building Kubernetes applications.