Brief introduction
It is a new, container-based, distributed solution that solves the problem of load balancing and deployment in traditional system architectures based on a powerful automation mechanism, thus saving 30% development costs, followed by a complete clustering capability,
Including service registration, service discovery, fault detection and repair, service rolling upgrade, online expansion, health monitoring and other capabilities. Using Kubernetes can be a great way for developers to be more focused on business implementations while embracing a microservices architecture
Architecture
Basic concepts and terminology
1 , master cluster's control node.
Each kubernetes cluster needs to have a master node responsible for the management and control of the entire cluster. The Mater node includes a set of key processes:
- Kube-apiserver resources to delete and change the entrance of the operation, the doorman
- Kube-controller-manage Automation Control Center for all resources, major
- Kube-schedule is responsible for the scheduling of resources, control room
2 , node cluster's load nodes
Each node is assigned a certain workload (container) by master, and when node stops running, master dispatches the container to the other Node,node nodes including a set of critical processes:
- Kubelet responsible for the creation of pod corresponding container, start-Stop task
- Kube-proxy for service communication and load balancing
- Docker engine Docker engines are responsible for the creation and management of native containers
Common commands
View cluster Nodes
Kubectl Get Nodes
View node Details
Kubectl describe node xxx
3 , pod resource call base unit
Each pod contains a root container (pause) container and several other business containers, where the state of the root container represents the state of the container as a whole, and the business container shares the IP of the Pause container and the volumn it hangs on. Each pod in the cluster is assigned a unique IP, called the pod IP, and multiple containers in a pod share the pod IP address.
Pod A container stops, k8s detects and restarts all containers in the pod, so it fits in a pod to hold a business-related container
(1) The number of copies of the Replication Controller (RC) meets expectations at any time
The RC definition includes the following sections:
-
- Number of replicas expected by pod
- Label Selector for filtering the target pod
- Create a new copy ' when the number of replicas is less than expected
Example: Defines a copy of tier:frontend in a kubenetes cluster with only one
(2) Replication Set (RS) Next-generation RC
The difference with RC is that RS supports the label Selector of the collection type, while RC supports only the equation-based label Selector. Other feature types.
(3) Label and label Selector
Label and label selector Concepts, Kubernetes can set the Key=value form of a label for the corresponding resource (pod,rc,service,deployment), which is simply understood as classification. At the same time, label selector can be managed according to the specified label and resource. For example, a service can load-balance a pod with a corresponding label based on the label selector. Label selector is divided into equation form (env=test) and set form (env not In[test,dev])
(4) Deployment increase the control and statistics of service start-up status on the basis of RS
An upgrade was made on the basis of RC to better solve the service orchestration problem. You can know the "progress of the deployment" of the current pod
Common commands
Create deployment
Kubectl create-f Tomcat-deployment.yaml
View Information '
Kubectl Get deployments
(5) Service Kubernetes the core resource object, POD RC RS, and other resource objects are all services provided for the service
kubernetes Every service inside is what we call microservices.
-
- RC's role is to ensure service capabilities and service quality is always in the expected Biaozhun
- Service and backend replica clusters are load balanced via label selector
Once the service is created, Kubernetes automatically assigns it an available cluster IP and does not change throughout the service's lifetime, and service name and services IP DNS mappings resolve the problem
Common commands
View Service
Kubectl Get Svc-n XXX
Create service
Kubectl create-f XXX
Kubernetes Getting Started