Kubernetes - Logic
What is Kubernetes?
Kubernetes is at its core a container orchestrator. Kubernetes, or K8S, is used to control containers across various nodes (workers), and offers features such as load balancing, automated scaling for increases/decreases in demand, and node fault monitoring (taking faulty nodes out of load), amongst other features.
Kubernetes Components
Kubernetes runs from a master node, also known as a control plane. The control plane is made up of various components that Kubernetes uses to perform its job;
API Server
The API server is the front end for K8S. Users, admins, devices and more, all interact with K8S via the API server.
etcd
etcd is a key-value store that's used by Kubernetes to store all data used to manage the cluster.
Scheduler
The Kubernetes scheduler's main job is to distribute pods to the available workers (nodes) based on the resources they need and the constraints or rules in place. It doesn't manage node creation or deletion, only where to place pods within the existing cluster.
Controller
The Kubernetes controller is responsible for managing the overall state of the cluster by monitoring the desired state (as defined in specs like deployments) and making adjustments to ensure the actual state matches, such as ensuring the correct number of pods are running, scaling applications, or handling node failures.
Container Runtime
The container runtime is the underlying software that's used to run containers - ie docker, CRI-O, RKT
Kubelet
The kubelet is a Kubernetes agent that runs on each node and ensures containers in pods are running and healthy, based on the instructions it receives from the control plane. Kubelet communicates with the API server on the master node to report data about the pods on its worker, which is then used by the Controller for its operations.
Command Overview
kubectl
TheĀ kubectl command is used to interact with and manage a Kubernetes cluster. It allows administrators and developers to deploy applications, inspect resources, manage cluster components, and view logs. Essentially, kubectl acts as the command-line interface (CLI) for communicating with the Kubernetes API server to control the state of the cluster.
View cluster nodes
kubectl get nodes
View cluster info
kubectl cluster-info
Deploy an application to the cluster
kubectl run applicationname