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 important concepts of k8s

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

Share

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

Today, I will talk to you about the important concepts of k8s, which may not be well understood by many people. In order to let you know more, Xiaobian summarized the following contents for you. I hope you can gain something according to this article.

Before practicing, you must learn several important concepts of Kubernetes, which are the building blocks of Kubernetes clusters.

Cluster

A Cluster is a collection of compute, storage, and network resources that Kubernetes uses to run various container-based applications.

Master

The Master is the brain of the Cluster and its primary responsibility is scheduling, i.e. deciding where to put applications to run. Master runs Linux operating system and can be physical or virtual machine. To achieve high availability, multiple Masters can be run.

Node

Node's responsibility is to run container applications. Node is managed by Master, Node is responsible for monitoring and reporting the status of container, and managing the life cycle of container according to the requirements of Master. Node runs on Linux and can be either a physical machine or a virtual machine.

The Cluster we created in the previous interactive tutorial has only one host host, host01,

It is both Master and Node.

Pod

A Pod is the smallest unit of work for Kubernetes. Each Pod contains one or more containers. The containers in the Pod are dispatched as a whole by the Master to run on a Node.

Kubernetes introduces pods for two main purposes:

Manageable.

Some containers are built to work closely together. Pods provide a higher level of abstraction than containers, encapsulating them into a deployment unit. Kubernetes schedules, scales, shares resources, and manages life cycles in the smallest unit of Pod.

Communication and resource sharing.

All containers in a Pod use the same network namespace, i.e. the same IP address and Port space. They can communicate directly with localhost. Similarly, these containers can share storage, and when Kubernetes mounts volume to a Pod, it essentially mounts volume to every container in the Pod.

Pods can be used in two ways:

Run a single container.

One-container-per-Pod is the most common Kubernetes model, in which a single container is simply encapsulated into a Pod. Even with a single container, Kubernetes manages pods rather than containers directly.

Run multiple containers.

But the question is: Which containers should fit into a Pod?

The answer is that these containers must be very closely connected and share resources directly.

Take an example.

This Pod contains two containers: a File Puller and a Web Server.

File Puller periodically pulls the latest files from the external Content Manager and stores them in a shared volume. The Web Server reads files from the volume and responds to requests from consumers.

The two containers work closely together to provide up-to-date data to consumers; they also share data through volumes. So putting it in a Pod is appropriate.

Another counterexample: Do you need to put Tomcat and MySQL in a Pod?

Tomcat reads data from MySQL, and they need to collaborate, but they don't need to be deployed together in a Pod, started together, and stopped together. At the same time, they exchange data through JDBC, not directly share storage, so it is more appropriate to put them in their own pods.

Controller

Kubernetes usually doesn't create pods directly, but manages pods through controllers. Controller defines the deployment characteristics of Pod, such as how many copies there are, what kind of Node to run on, etc. To meet different business scenarios, Kubernetes provides a variety of Controllers, including Deployment, ReplicaSet, DaemonSet, StatefuleSet, Job, etc., which we will discuss one by one.

Deployment is the most commonly used Controller, for example, in the online tutorial above, you can deploy an application by creating a Deployment. Deployment can manage multiple copies of a Pod and ensure that the Pod performs as expected.

ReplicaSet implements multiple copy management of Pods. ReplicaSets are automatically created when using Deployment, which means that Deployment manages multiple copies of a Pod through ReplicaSets. We usually do not need to use ReplicaSets directly.

DaemonSet is used in scenarios where only one copy of a Pod runs per Node. As its name suggests, DaemonSets are often used to run daemons.

StatefuleSet guarantees that each copy of a Pod has the same name throughout its lifecycle. Other Controllers do not provide this feature. When a Pod fails and needs to be deleted and restarted, the name of the Pod will change. StatefuleSet also ensures that copies are started, updated, or deleted in a fixed order.

Job is used for applications that are deleted at the end of a run. Pods in other controllers are usually running continuously for a long time.

Service

Deployment can deploy multiple replicas, each Pod has its own IP, how can the outside world access these replicas?

Through Pod's IP?

Keep in mind that pods are likely to be destroyed and restarted frequently, and their IP changes, making IP access impractical.

The answer is Service.

Kubernetes Service defines how outsiders can access a particular set of pods. Service has its own IP and port. Service provides Load Balancer for Pod.

Kubernetes runs the pod and accesses the pod. These two tasks are performed by the Controller and Service, respectively.

Namespace

If there are multiple users or project groups using the same Kubernetes Cluster, how do you separate the Controller, Pod, and other resources they create?

The answer is Namespace.

Namespace can logically divide a physical Cluster into multiple virtual clusters, and each Cluster is a Namespace. Resources in different namespaces are completely isolated.

Kubernetes creates two namespaces by default.

default --If not specified when creating the resource, it will be placed in this Namespace.

kube-system --System resources created by Kubernetes themselves will be placed in this Namespace.

After reading the above, do you have any further understanding of the important concepts of k8s? If you still want to know more knowledge or related content, please pay attention to the industry information channel, thank you for your support.

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