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

What are the basics of Kubernetes

2025-03-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

Most people do not understand the knowledge points of this article "what are the basics of Kubernetes?", so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "what are the basics of Kubernetes" article.

What is Kubernetes?

In 2008, LXC (Linux containers) released its first version, the original container version; in 2013, Docker released its first version; and Google released LMCTFY in 2014.

In order to solve the problems of container deployment, scaling and management in large cluster (Cluster), software such as Kubernetes, Docker Swarm and so on appeared, which is called container orchestration engine.

The creation of containers has solved many pain points in development and deployment, but with the rise of cloud native and micro services, some management problems have emerged in pure Docker. Let's think about it first. To run a Docker container, you only need to use docker run... Command is fine, which is a fairly simple (relatibely simple) method.

However, it is difficult to implement the following scenarios:

Containers across multiple hosts connect to each other (connecting containers across multiple hosts)

Expansion Container (scaling containers)

Configure applications without downtime (deploying applications without downtime)

Multi-faceted service discovery (service discovery among several aspects)

Kubernetes is a production-level container scheduling system developed by Google based on more than ten years of experience in production environment operation and maintenance. In the Kunernetes document, describe Kubernetes as follows:

[Success]

An open-source system for automating deployment, scaling, and management of containerized applications.

"an open source system that automates deployment, expands, and manages container applications"

The infrastructure of Google has reached a large scale before the popularization of virtual machine (Virtual machines) technology. Efficient use of clusters and management of distributed applications has become the core of Google challenges, while container technology provides an efficient solution to package clusters.

For many years, Google has been using Borg to manage the containers in the cluster, and has accumulated a lot of cluster management experience and operation and maintenance software development capabilities. Google referred to Borg and developed Kubernetes, that is, Borg is the predecessor of Kubernetes. (however, Google currently mainly uses Borg).

Kubernetes addresses these challenges from the start with a set of primitives, powerful and extensible API, and the ability to add new objects and controllers makes it easy to address a wide variety of product requirements (production needs).

Orchestration management is controlled or operated through a series of monitoring cycles; each controller asks for the status of the object and then modifies it until the condition is met. Container choreography is the most important technology for managing containers. Dockers also has its officially developed swarm choreography tool, but in the container choreography war in 2017, swarm lost to Kubernetes.

The composition of Kubernetes Cluster

In Kubernets, the environment in which applications are running is virtualized, so we generally don't talk about hardware.

When we talk about Kubernetes and application deployment, we often refer to the concepts of container, node, Pods and so on, which work together to manage the deployment and execution of containerized applications, but there are a variety of terms that are dazzling. To better understand Kubernetes, we will list these bounded objects below.

Component name Cluster Cluster Node Node Pod untranslated Container Container Containerzed Application Container Application

In Kubernetes, different objects have different scope of management and function, and their boundary sizes are also different. In the following content, these components will be introduced in terms of granularity from small to large.

Pod

Pod is the smallest unit of work managed and scheduled in Kubernetes, and Pod can contain multiple containers. These containers share resources such as networks in Pod. When Pod is deployed, a set of highly related containers is deployed to the same node.

The node refers to a server, virtual machine, etc., running a complete operating system, providing CPU, memory and other computing resources, a node can deploy multiple Pod.

In a cluster (Cluster), there are N servers, that is, N nodes. There are two kinds of these nodes, one is the master node, the other is the worker node. The master node runs the Kubernetes system components, while the worker node is responsible for running the user's programs. All nodes are managed by master. When we manage the Kubernetes cluster by command or API, we send commands or requests to the system components on the master node, and then control the whole cluster.

In addition, there is the concept of namespace in kubernetes, which is similar to Linux-namespace, where namespaces are used in a cluster to isolate different Pod. But in Kubernetes, the Pod of different namespace can access each other, and they are not completely isolated.

Kubernetes structure

Using a diagram to represent the architecture is the fastest way to illustrate Kubernetes. Here is a picture called Kubernetes Architecture graphic.

The above figure shows a simple kubernetes structure. In the dotted box on the left, there are master nodes running a variety of components. Master nodes are responsible for controlling the entire cluster, of course, there can be multiple master nodes in a large cluster, while on the right are three working nodes, which are responsible for running our container application. This structure is generally called the master-slave structure, and for some reason it was later renamed master-minions in Kubernetes. It doesn't matter if the work node is dead, the master node will automatically deploy the business on the failed node to another node.

The work node is relatively simple. In the work node, we see that there are two components: kubelet and kube-proxy. Both kubelet and kube-proxy communicate with the kube-apiserver of the master node. Kube-proxy, whose full name is Kubenetes Service Proxy, is responsible for load balancing network traffic between components.

In the above figure, the master node is composed of multiple components, and the structure is more complex. The working data of the whole cluster is recorded in the master node, which is responsible for controlling the operation of the whole cluster. It doesn't matter if the work node is dead, but the master node is dead and the whole cluster is dead. Therefore, if there are conditions, multiple primary nodes should also be set.

A primary node contains the following access:

An API service (kube-apiserver)

A scheduler (kube-scheduler)

Various controllers (there are two controllers in the picture above)

A storage system (this component is called etcd) stores data such as cluster status, container settings, network configuration, and so on.

There are still a lot of things in this picture, which will not be explained here for the time being. We will learn the terms and keywords in Kubernetes in later chapters.

module

A kubernetes cluster is composed of a group of machines or virtual machines called nodes, which have two types: master and worker. There is at least one master node in a cluster, and Pod can also be deployed to a worker node without a master node. If the number of nodes in the cluster is very large, consider extending the master node and using multiple master nodes to control the cluster.

In the previous section, we saw that the master node contains more components, and the work node also contains some components, which can be divided into two types, namely Control Plane Components (control plane components) and Node Components (node components).

Control Plane Components is used to make global decisions on the cluster and is deployed on the master node

Node Components runs in the worker node to provide a Kubernetes environment for Pod.

Master node

Master is made up of a set of components called the control plane. If you have deployed kubernetes through minikube or kubeadm according to Chapter 2, then we can open the / etc/kubernetes/manifests/ directory, where the YAML file of the default control plane component of K8s is stored.

. ├── etcd.yaml ├── kube-apiserver.yaml ├── kube-controller-manager.yaml └── kube-scheduler.yaml

All four components are essential to a cluster.

In the structure diagram, there is also a cloud-controller component, which is mainly provided by the cloud platform service provider and belongs to a third-party component, which is not discussed here. Let's take a look at the components in master.

Ports to be used by each component (control plane component) in the master node:

Protocol direction port range functions user TCP inbound 6443Kubernetes API server all components TCP inbound 2379-2380etcd server client APIkube-apiserver, etcdTCP inbound 10250Kubelet APIkubelet itself, control plane component TCP inbound 10251kube-schedulerkube-scheduler itself TCP inbound 10252kube-controller-managerkube-controller-manager itself

Ports that need to be used by each component in a normal node:

The protocol direction port range functions the consumer TCP inbound 10250Kubelet APIkubelet itself, the control plane component TCP inbound 30000-32767NodePort service "all components kube-apiserver

Kube-apiserver is one of the main processes of K8s. Apiserver component exposes Kubernetes API (HTTP API). Apiserver is the front end of Kubernetes control plane. We can write code in Go, C # and other programming languages, call Kubernetes remotely and control the operation of the cluster. The endiont port exposed by apiserver is 6443.

In order to control the operation of the cluster, Kubernetes officially provides a binary command line tool called kubectl. It is apiserver that provides the interface service. After kubectl parses the instructions entered by the user, it initiates a HTTP request to apiserver, and then feeds back the result to the user.

[Info] kubectl

Kubectl is a very powerful cluster control tool that comes with Kubernetes, managing the entire cluster through command line operations.

Kubernetes has many visual panels, such as Dashboard, behind which is also the API that calls apiserver, which is equivalent to the front end adjusting the back end.

In short, we use a variety of cluster management tools, the back end is apiserver, through apiserver, we can also customize a variety of cluster management tools, such as grid management tool istio. Tencent Cloud, Aliyun and other cloud platforms all provide online kubernetes services, as well as console visual operations, which also make use of apiserver.

Etcd

Etcd is a key-value database with both consistency and high availability, and serves as a background database for storing all cluster data of Kubernetes. All the operation results of apiserver are stored in etcd database. Etcd mainly stores the status, network configuration and other persistent data of K8s. Etcd is implemented by B+ tree. Etcd is a very important component that needs to back up data in time.

Kube-scheduler

Scheduler is responsible for monitoring the newly created pod and assigning the pod to the node. When the container is to be run, the request sent is forwarded by the scheduler to the API; scheduler and a suitable node can be found to run the container.

Kube-controller-manager

Kube-controller-manager contains multiple controllers, all of which are compiled into a binary file, but different processes are generated after startup. These controllers are:

Node controller (Node Controller)

Responsible for notifying and responding to node failure

Task controller (Job controller)

Monitor Job objects that represent one-time tasks, and then create a Pods to run those tasks until they are complete

Endpoint Controller (Endpoints Controller)

Populate the endpoint (Endpoints) object (that is, add Service and Pod)

Service account and token Controller (Service Account & Token Controllers)

Create a default account and API access token for the new namespace

Pod, Job, Endpoints, Service and so on controlled by the controller are all to be studied deeply later.

The above is the content of this article on "what are the basic knowledge of Kubernetes". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please pay attention to the industry information channel.

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

Development

Wechat

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

12
Report