1. What is Kubernetes?
1.1 History of deployment
Deployment methods have gone through 3 eras:
- Traditional Deployment: Hardware
- Virtualized Deployment: VM
- Container Deployment: Container
Each step means further use of resources.
1.2 What does Kubenetes used for?
Kubenetes = Container Deployment Organizor
It provides the following functions:
- Life control: Automated rollouts and rollbacks, Self-healing
- Resource allocation: Manage CPU, RAM resources for containers
- Application level control: Load balance, Configuration
Glossary
(1) rollouts and rollbacks
(2) self-healing
(3) configuration
2. Kubernetes Components
2.1 Resource organization level
To understand how Kubernetes organize and manage resources, first introducing the following Resources Organized Concepts(small scope to big one).
Assuming that we have an online store, it provided abilities to create accounts, search and buy stuff, pay for the bill… If we use Kubernetes to build and manage this project, it will be like:
- Container(provide an infra component, such as a web server): A isolated virtual enviroment for running a single application, usually assigned with an docker image and a build task. Such as an HTTP web server.
- Pod(provide a collection of containers that has the same functionality, such as a load balanced web server): Consisted of several Containers of the same kind, for load balance purpose.
- Node(provide a business scoped functionality, such as User account service and exposed API service): Consisted of a set of Pods, providing a business functionality.
- Cluster(an application-scoped integrated system): Consisted of various Nodes, a fully fledged system.
2.1 How does K8S work?
2.1.1 Control Panel: Cluster-scope Manager
In Cluster scope, Kubenetes inject a built-in node named Control Panel to manage node/pod/container life cycle.
Control Panel has these components:
- kube-apiserver: It exposes K8S API, provide a front end entry.
- etcd: Consistent and highly-available key value store used as Kubernetes’ backing store for all cluster data.
- kube-scheduler: Control plane component that watches for newly created Pods with no assigned node, and selects a node for them to run on.
- kube-controller-manager: Logically, each controller is a separate process, but to reduce complexity, they are all compiled into a single binary and run in a single process.
- cloud-controller-mamager: cloud service provider’s API.
In most cases, All control panel components is deployed on the same machine. But there is also Highly Available clusters option for you to choose.
2.1.2 Node Components: Node-scope Manager
Node components:
- run on every node
- maintain running pods
- keep runtime enviroment
Consist of:
- kubelet: maintain containers according to PodSpecs file.
- kube-proxy: network proxy
- container runtime: softwares is responsible for running containers(Docker, containerd, CRI-O)
3 Kubernetes Objects
3.1 Concepts
Kubernetes Object is a data model in Kubernetes to describe resources. It can be described in .yaml
format, illustrating configuration including container details(but very similar).
Kubernetes Object is logically presented as a container in the runtime, but meanwhile it contains a public Kubernetes machenism to maintaining container running well(healthy and in accord with the Kubernetes Object Yaml File)
Kubernetes API is provided by control panel, providing Web API to multipulate resources. Resources are in Kubernetes Object format.
- Open Api: basic basic way to call
- Kubectl: an encapsulated command line interface
- …
3.2 Object Spec and Status
spec
: desired statusstatus
: current status in runtime- Kubernetes API: require JSON based spec
- Kubectl: require YAML based object spec
pods
4 Workloads
workload = kubernetes resource
- base resource: pod
- built-in resource(workload resource): deployment, replicaSet…
4.1 Pod
4.1.1 What is Pod
- the smallest deployable units of computing in kubernetes.
- consisted of one or more containers
- ONE: mostly common model
- MULTIPLE: a cohesive unit of several co-located containers to provide a specific service
- isolated between other pods, shared namespaces and filesystem in its containers.
4.1.2 Pod Template
Custom Resource Defination
https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/
CRD - defination
CRO - instance