Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

First acquaintance of Kubernetes (K8s): theoretical basis

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

What is Kubernetes?

Kubernetes, K8s for short, is an abbreviation made by using 8 instead of 8 characters "ubernete". Kubernetes is not only an open source container orchestration engine of Google, but also an open source container cluster management system, which can realize the functions of automatic deployment, automatic scaling, monitoring and maintenance of container applications.

I. Kubernetes architecture

Kubernetes originated from Google's internal Borg and provides an application-oriented container cluster deployment and management system. The goal of Kubernetes is to eliminate the burden of orchestrating physical / virtual computing, network, and storage infrastructure, and to enable application operators and developers to focus entirely on container-centric principles for self-service operations.

Kubernetes has comprehensive cluster management capabilities, including multi-level security protection and access mechanism, multi-tenant application support capability, transparent service registration and service discovery mechanism, built-in load balancer, fault detection and self-repair capability, service rolling upgrade and online expansion, scalable resource automatic scheduling mechanism, and multi-granularity resource quota management capability.

Borg is a large-scale cluster management system within Google, which is responsible for the scheduling and management of many core services within Google. The purpose of Borg is to enable users to focus more on their core business without worrying about resource management. Borg can even maximize resource utilization across multiple data centers.

Kubernetes belongs to the master-slave distributed architecture, which is mainly composed of Master and Node, as well as the client command line tool kubectl and other add-ons.

Master: as a control node, it schedules and manages the cluster; it is composed of kube-apiserver, kube-scheduler, kube-controller-manager and etcd. Node: a container for running business applications as a work node; consists of kubelet, kube-proxy, and docker (or rocket). II. Kubernetes components

Master refers to the cluster control node. Each Kubernetes cluster needs at least one Master to manage and control the cluster. Master can be a physical machine or a virtual machine, and the following components are running on the Master node:

Kube-apiserver: provides the key service processes of the HTTP Rest interface, which is the only entry for adding, deleting, modifying, querying and other operations of all resources in the cluster, and is also the control entry of the cluster.

Kube-controller-manager: the running management controller is the background process that handles routine tasks in the cluster. Each Controller is responsible for a specific control flow, and Controller Manager is the core manager of these Controller.

Kube-scheduler: the process responsible for resource scheduling (Pod scheduling), selecting a Node node for the newly created Pod.

Etcd: the default storage system of kubernetes. The data of all resource objects in the cluster are stored in etcd.

Node refers to the worker node of a cluster, which, like Master, can be a physical host or a virtual machine. Each Node is assigned some workload (Docker container) by Master, and when a Node goes down, the workload on it is automatically transferred to other nodes by Master. The components running on Node are as follows:

Kubelet: responsible for the creation, start and stop of containers corresponding to Pod, and works closely with Master nodes to achieve the basic functions of cluster management.

Kube-proxy: an important component that implements the communication and load balancing mechanism of Kubernetes Service.

Docker: container engine, which is responsible for the creation and management of native containers.

3. Kubernetes object Pod

Pod is the most basic and smallest unit for the creation or deployment of Kubernetes clusters. One or more containers run in each Pod, each Pod has a special container called Pause, and the other containers are business containers. These business containers share the network stack and Volume (storage volume) of Pause containers. Kubernetes assigns a unique IP address to each Pod, called Pod IP, and all containers in a Pod share the same Pod IP. Service

Service defines such an abstraction: a logical grouping of Pod, a policy that can access them. Service is usually called micro-service, which defines the access entrance address of a service. Through this entrance, the front-end application (Pod) accesses a group of cluster instances composed of Pod replicas behind it. The communication between Service and its back-end Pod replica cluster is realized through Label Selector. Label

Tag, a Label is a key-value pair of key=value, specified by the user. Label can be attached to various resource objects, such as Pod, Service, etc., a resource object can define any number of Label, and the same Label can also be added to any number of resource objects. Label is usually determined when the resource object is defined, and can be dynamically added or deleted after the object is created. Volume

The storage volume is similar to Docker's Volume, except that the Volume in Kubernetes is defined on Pod, and all containers in this Pod can mount it to a specific file directory to achieve resource sharing among containers. Persistent Volume

Unlike Volume, network storage volume shares resources between Node, and each Node can be mounted and used. Pod can use PersistentVolume resources by defining a PersistentVolumeClaim (PVC) object. Name

All objects in Kubernetes REST API are explicitly identified with Name and UID. Name can only have one Name in an object at a time, and if the object is deleted, you can also use the same Name to create a new object, and the Name is used to reference the object in the resource URL. Namespace

Namespace, which is used in many cases to achieve resource isolation for multi-tenancy. By "allocating" the resource objects within the cluster to different Namespace, Namespace forms logically grouped different projects, groups or user groups, so that different groups can be managed separately while sharing the resources of the whole cluster. Horizontal Pod Autoscaling

Referred to as HPA, it is the function of realizing Pod horizontal automatic scaling in Kubernetes. For Pod clusters, HPA can implement many automation functions. When the business load in Pod increases, you can create a new Pod to ensure the stable operation of the business system; when the business load in Pod drops, you can destroy Pod to improve resource utilization. Annotation

Annotations, similar to Label, are defined in the form of key/value key-value pairs. Annotation is user-defined "additional" information that can be easily found by external tools. In many cases, the module of Kubernetes will mark some special information of the resource object by Annotation. ReplicaSet

ReplicaSet (RS) is an upgraded version of Replication Controller (RC), which ensures that a specified number of Pod is running. The only difference between RC and RS is the support for Lable Selector. RS supports new set-based tags, while RC only supports equality-based tags.

When we define a RS and submit it to the Kubernetes cluster, the Controller Manager component on the Master node is notified to regularly inspect the target Pod currently alive in the system and ensure that the number of target Pod instances is exactly equal to the expected value of this RS. If there are too many copies of Pod running, the system will stop the excess Pod. If it is less than the expected value of RS, the system automatically creates some new Pod so that the number of target Pod instances is equal to the expected value of RS. Deployment

Deployment provides declarative updates for Pod and ReplicaSet to manage Pod and ReplicaSet. When we deploy a Pod, we need to create, schedule, bind nodes, and start the container, and Deployment is responsible for the entire deployment process. Typical usage scenarios for Deployment are as follows: create a Deployment object to generate the corresponding ReplicaSet, and complete the process of creating a copy of the Pod. Check the status of the Deployment to see if the deployment is complete (whether the number of Pod copies reaches the expected value). Update the Deployment to create a new Pod (such as a mirror upgrade). If the current Deployment is unstable, roll back to an earlier version of Deployment. Suspend or restore a Deployment. StatefulSet

StatefulSet provides a unique identity for Pod, enabling orderly deployment, deletion, and expansion. Deployment is used to deploy stateless services, and StatefulSet is used to deploy stateful services. The usage scenarios of StatefulSet are as follows: stability, unique network identity. Stability, persistent storage. Orderly deployment and expansion. Orderly deletion and termination. Orderly automatic scrolling updates. DaemonSet

DaemonSet allows all (or specific) Node nodes to run the same Pod. When a node joins the Kubernetes cluster, Pod will be scheduled to run on the node by DaemonSet. When the node is removed from the cluster, the Pod dispatched to the node by DaemonSet will also be removed. If you delete DaemonSet, all Pod related to DaemonSet will be deleted. Job

The task is executed only once, and the Pod is destroyed after the task execution is completed, and the one-time task can be processed in batches. You can also make tasks run regularly. IV. Summary

These components are the core components of Kubernetes system, and together they constitute the framework and computing model of Kubernetes system. By combining them flexibly, users can configure, create and manage container clusters quickly and easily. In addition to the core components described in this article, there are many auxiliary configuration resource objects in Kubernetes, such as LimitRange, ResourceQuota, and so on. In addition, there are some objects for internal use in the system, such as Binding, Event, etc., you can refer to the official API documentation.

Said that at the end,

I have just contacted Kubernetes (K8s). The content of this article is extracted from relevant books and relevant materials on the Internet, and written in combination with my own understanding. If there are any misunderstandings, please do not hesitate to point out and make progress together.

Due to the lack of learning materials about Kubernetes in China, there are related subscription columns on 51cto, but they all cost money. I will not comment on this. Here to beginners like me to recommend a book "Kubernetes authoritative Guide (2nd edition)", the Internet can be downloaded to the PDF version, although this book tells the Kubernetes version is 1.3, the version is relatively old, but for beginners can learn its theoretical knowledge, and combined with the new version of the relevant information on the Internet to understand, is also a very good learning method.

Friends who are interested in Kubernetes (K8s) can follow my blog. Later, I will continue to publish blog posts on learning Kubernetes. Welcome friends to join me on the journey of Kubernetes (K8s).

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report