In layman's Docker (vi): Deploy your app like Google

Source: Internet
Author: User

1. Overview

Google's Open source project has always been the focus of technical circles and discussion, this article will introduce the latest container orchestration management system Kubernetes. Kubernetes Open source project versions are frequently updated, and for first-time users, they define a large number of technical terms and are ready for new terms to appear. In this unstable technical framework, the user has indeed brought a certain technical threshold. In order to master the core technical concept of kubernetes, this paper tries to supper the domestic kubernetes technology enthusiasts by reading the official documents and sorting out the core usage practice ideas.

What is 1.1 kubernetes?

Kubernetes is an orchestration management system for container clusters. The understanding of "orchestration" here should be based on how to manage the container cluster in a unified manner across the Docker host scenario. The current Docker technology mainly provides a stand-alone version of container management practices, many third-party manufacturers through their own experience in the network to launch their own container orchestration tools, Google launched the Kubernetes technology is created in this context of open source projects. The problem that this project is trying to solve is to simplify the work of developing and operating container clusters so that development and operations can treat the system as a computer. This idea has been used extensively in distributed systems before the Docker container technology, such as Hadoop, Mesos, Yarn. Due to the limitations of virtualization technology, there are still significant limitations for larger instance sizes. After the advent of Docker technology, the already complex distributed system began to try to achieve a larger scale of the cluster, the temptation to achieve the standard to allow more manufacturers to participate in the original Mesos, yarn class cluster scheduling system to start the application of Docker technology. Then kubernetes and Mesos class compared, its advantage is no resource scheduling algorithm, only focus on container management. and Mesos, yarn and other scheduling system itself has a sound scheduling system experience, how to add Docker orchestration structure to the original system, need some standard design reference implementation, this time the appearance of kubernetes just make up for this need.

1.2 Kubernetes Technical Terminology Overview

First, in the Kubernetes cluster environment pods is the smallest deployable unit that represents a logical collection of container groups belonging to an application.

Second, the master node provides the central control point for the unified view of the cluster. We can use a master node to control multiple minion nodes.

Third, Minion is a work node that will run the tasks that the master node delivers. Minions can run one or more pods. It provides an application-level virtual machine in a container environment.

Through the following concept map, we can see more clearly the technical picture of kubernetes.

Let's go a little further and talk about how kubernetes is doing these features.

    • The Replication Controller is the resource Director on Master, ensuring that requests to create and destroy pods can be run by Minions nodes at any time. This ensures that the pods in the cluster can serve forever, and that the pod instance can be opened immediately after the pods fail, guaranteeing the availability of the pod instances service.
    • The Service provides a uniform name and address that provides load balancing for a set of pods. This service is actually the implementation of MicroServices, which provides a layer of abstraction on the basis of the pods we create. For example, our service is a job service, the front-end application can directly publish the task to the specified Servcie IP, the user for the job service how many instances to provide services do not need to be concerned.
    • The Label is a mandatory key-value pair that is stored on the Distributed storage service ETCD, allowing the replication controller to use it to implement service discovery.
    • Kubelet is the daemon that manages the container on each minion, which is the hypervisor that actually manages the Docker host to start the container.
    • Master API Server provides a restful k8s API interface to validate and configure Pod, service, and replication Controller, which is the gateway to unified management of the cluster system.
1.3 Relationship to the Docker tool chain

Docker recently launched three major packages: Compose, Swarm, machine have provided some kubernetes features, we need to understand the differences between them, so that we can better use kubernetes to do a good job.

    • Docker machine is a relatively low-level entry, a bit lower than the kubernetes implementation. Machine provides infrastructure IAAS capabilities to facilitate the management of Docker hosts in hybrid cloud situations. Similar to Google Compute Engine.
    • Docker Swarm is based entirely on the cluster API defined above the Docker API. In the direction, the Docker API provides a single-machine-wide API, and swarm provides cluster-level APIs. Google's Kubernetes team provided their own views on early swarm implementation discussions.
    • Docker compose is also a standalone development kit that, for developers, can use to build the current code into the specified Docker Image and then run it on a single machine. Kubernetes is a standard implementation that is defined to solve the difficulty of deploying to a container cluster. The current compose is implementing the ability to implement cluster orchestration based on Swarm and machine, which is the direct competitor of Kubernetes.
2. Use the actual combat

We can deploy the Kubernetes cluster system in the light of the official platform installation script, this article uses Ubuntu system as the basic system to install Kubernetes cluster. The official script is installed to install successfully in the following steps:

First, download the kubernetes source code to each cluster machine and build the latest version of the suite yourself.

$ cd cluster/ubuntu-cluster$ sudo./build.sh$ sudo cp./binaries/*/opt/bin   #复制到/opt/bin directory, primarily for ease of deployment script invocation.

Then, configure the Kubernetes cluster component, assuming our machine list is as follows:

IP Address

Role

192.168.100.30

Master

192.168.100.31

Minion

192.168.100.32

Minion

Simply go to the Cluster/ubuntu-cluster directory and execute the configue.sh again to complete the configuration.

For example, on the Master node (192.168.100.30):

$ sudo./configure.shwelcome to use this script to configure k8s Setupplease Enter all your cluster node IPs, MASTER node Comes Firstand separated with blank space like "<ip_1>  ":  192.168.100.30 192.168.100.31 192.168.100.32This machine acts as  both Master and Minion:  1 only  master:             2 only  minion:             3Please Choose a role > 2IP address of this machine >  192.168.100.30Configure Success

When you see the message "Configure Success", the configuration of this machine is completed.

Of course, in the official Ubuntu example, it uses flannel to create a set of overlay networks (Overlay network) that enables the interconnection of containers across hosts. You can know through the figure 1flannel network that flannel0 and Docker0 are divided between the same network segment, Docker internal container IP and DOCKER0 gateway is NAT, through FLANNEL+ETCD to provide custom UDP packets, This example can help us to understand the main realization of the interconnection between the cross-host containers.

Figure 1 Flannel Network

After deploying the kubernetes system, we can verify that the service is working by using the built-in commands. such as running

$ kubectl Get minionsname            LABELS          STATUS192.168.100.30            NotReady192.168.100.31            Ready192.168.100.32 Ready            

Well, the system has been successful. I discovered during the deployment that not every time the installation was completed successfully. For example, the port is occupied, the key service is not up and so on. Then I summarize these situations to facilitate troubleshooting:

    • Master node, the main service is Kube-apiserver, Kube-controller-manager, Kube-scheduler, the following display needs to be guaranteed to run:

      If you do not see the running process, you should look at the running log, in the Ubuntu installation instance, the log is unified in the/var/log/upstart/directory.

    • Slave node, the main service is Kube-proxy, kubelet two services, the following display needs to be guaranteed to run:

    • Network-related components, mainly ETCD services, and SDN Component Services such as flannel. This piece of the problem is very rare, I encountered most of the problems are focused on the network topology, through learning to understand the network can basically solve the problem.
    • The Kubernetes project is not yet a production grade project and is not validated at the production level in the actual scenario. We are just passing through the examples in the official example catalogue to understand exactly what features are needed in our scenario, and then feedback to the community to make kubernetes more mature.
3. Summary

Kubernetes after the first version was released in September 2014, the version iterations were implemented on a weekly basis. It is also not recommended that users use the system in a production environment. But its design ideas and concise architecture design are enough to draw on a lot of valuable engineering experience. In the successful case of reference, kubernetes implementation technology was successfully applied in the latest version of Red Hat's OpenShift V3. Therefore, the Kubernetes project is a good open source project that deserves everyone's learning, and by understanding its design idea, it can be quickly applied to the local container orchestration cluster system implementation.

In-depth Docker (vi): Deploy your app like Google

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.