The basic principles and connection between Docker and Kubernetes

Docker

The reason for Docker

I believe that programmers have heard a saying: "Is this script running on my machine without any problem?" The emergence of Docker has made this meme a thing of the past. Developers can package their applications, dependent packages, and environment variables into a container, and then release the container to a machine with Linux installed. This process saves the work of developing and operating the same environment.

So how is the underlying layer of Docker implemented? Docker is actually a system of Client-Server structure. The Docker daemon runs on the host, and then the client accesses the Docker daemon through a Socket connection. The Docker daemon accepts commands from the client and manages the containers running on the host according to the commands .

When using Docker, you need to pull an image file from the warehouse and start a container . The image files, containers, and warehouses mentioned here are several important concepts in Docker, which will be described below.

Important concepts in Docker

  1. Image file Image: equivalent to a root file system configured with a certain environment. For example, the official image ubuntu:16.04 contains a complete set of root file system of Ubuntu16.04 minimum system. We can also publish the image file of our own configured environment.

  2. Container Container: A container is an entity when mirroring, and a container can be created, started, stopped, deleted, suspended, etc.

  3. Warehouse Repository: The warehouse is used to save a series of images.

Advantages of Docker

Why do we need Docker when we already have virtual machines? Here is a picture, which intuitively shows the difference between Docker and virtual machines.

Docker vs virtual machine

It can be seen that the virtual machine needs to initialize the client's operating system, while Docker runs on the host's operating system, which means that Docker does not need to reload an operating system when it is created, achieving a high degree of lightweight. This means that the creation speed of Docker is much higher than that of virtual machines, and it requires less system resources, and the number of Dockers that can run on a host is higher than that of virtual machines. A table summarizing the differences between Docker and virtual machines is posted here.

Docker vs virtual machine

Docker uses

In order to avoid the length of the article, please refer to the specific instructions for using Docker:
Docker Common Commands

Kubernetes

In actual enterprises, container cluster management systems are often used, which can realize automatic deployment, expansion of container clusters, maintenance and other functions. Among them, Kubernetes is commonly used, also known as k8s (there are 8 letters between k and s)

Kubernetes main functions

K8s is mainly used to manage and orchestrate docker containers. It is a docker-based scheduling service that provides resource scheduling, balanced disaster recovery, service registration, dynamic expansion and other functional suites. Its functions are as follows:

  1. Data volume: data sharing between containers in pod, data volume can be used

  2. Application health check: An exception may occur in the service in the container and the service may be unavailable. Health check strategies can be used to ensure the robustness of the application.

  3. Replicated application instances: The controller maintains a replica count of pods, ensuring that a pod or a group of pods of the same type is always available.

  4. Elastic scaling: dynamically and automatically scale the number of pods according to the set indicators (CPU utilization, etc.)

  5. Load balancing: A group of pod copies are assigned a private cluster IP address, load balancing forwards the request to the backend container, and deploys it in the cluster. Other pods can access the cluster through this Cluster IP.

  6. Rolling update: update service without interruption, update one pod at a time, instead of deleting the entire service at the same time

  7. Service orchestration: Deployment services are described through files to make program deployment more efficient.

  8. Resource monitoring: The Node node component integrates the cAdvisor resource collection tool, which can summarize the resource data of the entire cluster node through Heapster, then store it in the InfluxDB time series database, and then display it by Grafana

  9. Provide authentication and authorization: support authentication and authorization strategies such as attribute access control and role access control.

Important Concepts in Kubernetes

  1. Container Set Pod : This is an important concept in Kubernetes. Pods are deployed on a single node and contain a container group of one or more containers. All containers in the same pod share the same IP address, IPC, hostname, and other resources. Containersets abstract networking and storage from the underlying containers. This makes it easier to move containers around the cluster.
  2. Node Node: A computer responsible for executing requests and assigned tasks. Nodes are controlled by the Kubernetes master.
  3. Host Master: The computer responsible for executing requests and assigned tasks. Nodes are controlled by the Kubernetes master.
  4. Replication controller: Used to control the number of identical copies of pods that should be running somewhere in the cluster.
  5. Service Service : It is also a "microservice" in the so-called microservice architecture. Separate work content from container sets. The Kubernetes service proxy automatically distributes service requests to the correct set of pods.

For specific reference to the concepts: Kubernetes basic concept analysis

Kubernetes uses

Specific reference:
Kubernetes Chinese Community - From Scratch k8s
Kubernetes Official Website - Chinese
Kubernetes Chinese Documentation

Guess you like

Origin blog.csdn.net/weixin_41670608/article/details/126416170