当前位置:网站首页>Cloud native Virtualization: building edge computing instances based on kubevirt
Cloud native Virtualization: building edge computing instances based on kubevirt
2022-04-23 17:48:00 【Volcanic engine edge calculation】
With Kubernetes The popularity of , More and more businesses are running on containers , However, there are still some business forms that are more suitable for running on virtual machines , How to control virtual machines and containers at the same time has gradually become the mainstream demand in the cloud native era , Kubevirt The perfect solution .
- Kubevirt Introduce
- Virtual machine management
- summary
In the age of cloud Nativity , More and more businesses are gradually migrating to containers , Container has also become an indispensable form of resource publishing and management , The lightweight advantage of container is more obvious in the scene of edge computing , therefore , When building a cloud platform at the edge, we must consider the running form of compatible containers .
Kubernetes At present, it is the most common and popular platform for container scheduling and scheduling , At the same time, more and more cloud vendors choose to use Kubernetes To manage both containers and virtual machines . stay Kubernetes Build a platform for managing virtual machines , There have also been many excellent projects in the industry , for example Kubevirt、Virtlet etc. , among Kubevirt With its architectural design and functional advantages, it has become one of the best solutions to solve the compatibility problem between virtual machine and container . This article will be Kubevirt Based on , How to share details based on Kubevirt Build an edge calculation example .
01 Kubevirt Introduce
Kubevirt What is it?
Kubevirt yes Red Hat Open source projects that run virtual machines as containers , be based on Kubernetes function , By using custom resources (CRD) And other Kubernetes Function to seamlessly expand existing clusters , To provide a set of virtualization tools that can be used to manage virtual machines API.
The overall architecture
The picture above depicts Kubevirt The overall structure of , It contains four main key components :
-
virt-api:
-
by Kubevirt Provide API Service capability, , For example, many custom API request , Such as power on 、 To turn it off 、 Restart and other operations , adopt APIService As Kubernetes Apiserver Plug in for , Business can be done through Kubernetes Apiserver Ask directly to virt-api;
-
-
virt-controller:
-
Kubevirt The controller , Function like Kubernetes Of controller-manager, Management and monitoring VMI Object and its associated Pod, Update its status ;
-
-
virt-handler:
-
With Daemonset Formal deployment , Function like Kubelet, adopt Watch This machine VMI And instance resources , Manage all virtual machine instances on the host ;
-
The main actions are as follows :
-
send VMI As defined in Spec And the corresponding libvirt ( Local socket signal communication ) Keep in sync ;
-
Report and control the update of virtual machine status ;
-
Call the relevant plug-ins to initialize the network and storage resources on the node ;
-
Heat transfer related operations ;
-
-
-
virt-launcher:
-
Kubevirt Will be for each one VMI Object to create a Pod, The Pod The main process of is virt-launcher,virt-launcher Of Pod Provides cgroups and namespaces The isolation ,virt-launcher Is the main process of the virtual machine instance .
-
virt-handler By way of VMI Of CRD Object passed to virt-launcher To inform virt-launcher start-up VMI. then ,virt-launcher Use local... In its container libvirtd Instance to start VMI.virt-launcher trusteeship VMI process , And in VMI Terminate after exit .
-
If Kubernetes Running at VMI Try closing... Before exiting virt-launcher Containers ,virt-launcher Will send the signal from Kubernetes Forwarding to VMI process , And try to delay the termination of the container , until VMI Successfully closed .
-
The following figure for virt-launcher And libvirt Communication overview :
Resource objects
Kubevirt yes Kubernetes Virtual machine management plug-in , Realize the management function of virtual machine by customizing controller and resources , By customizing resources (CRD) Mechanism , meanwhile Kubevirt You can customize additional operations , To adjust the behavior that is not available in a regular container . Here are some key resources :
-
VirtualMachineInstance(VMI): Is the smallest resource for managing virtual machines , One VirtualMachineInstance Object represents a running virtual machine instance , Contains the various configurations required for a virtual machine .
-
VirtualMachine(VM): For... In the cluster VirtualMachineInstance Provide management functions , For example, power on / To turn it off / Restart the virtual machine , Ensure the startup state of the virtual machine instance , And the virtual machine instance is 1:1 The relationship between .
-
VirtualMachineInstanceMigrations: Resources required for virtual machine migration , A resource object is represented as a migration task , And reflect the status of virtual machine migration .
-
VirtualMachineInstanceReplicaSet: similar ReplicaSet, You can specify the quantity , Batch create virtual machines .
-
DataVolume: It's right PVC The abstraction above , By customizing the data source , from CDI The controller is automatically created PVC And import the data to PVC For virtual machines .
The following is a VM Resource examples :
apiVersion: kubevirt.io/v1alpha3
kind: VirtualMachine
metadata:
labels:
kubevirt.io/vm: vm-cirros
name: vm-cirros
spec:
running: false
template:
metadata:
labels:
kubevirt.io/vm: vm-cirros
spec:
domain:
devices:
disks:
- disk:
bus: virtio
name: containerdisk
- disk:
bus: virtio
name: cloudinitdisk
machine:
type: ""
resources:
requests:
memory: 64M
terminationGracePeriodSeconds: 0
volumes:
- name: containerdisk
containerDisk:
image: kubevirt/cirros-container-disk-demo:latest
- cloudInitNoCloud:
userDataBase64: IyEvYmluL3NoCgplY2hvICdwcmludGVkIGZyb20gY2xvdWQtaW5pdCB1c2VyZGF0YScK
name: cloudinitdisk
02 Virtual machine management
In understanding Kubevirt What is it? , Its main architecture and key resource objects , Let's see how to use it Kubevirt Virtual machine management . It is mainly divided into virtual machine creation 、 Storage and network .
Virtual machine creation
Virtual machine creation is divided into creation DataVolume( Prepare storage for the virtual machine ) and VMI Two parts . The brief process is as follows :
-
User pass kubectl/api establish VM object ;
-
virt-api adopt webhook check VM object ;
-
virt-controller Listen to the VM The creation of , Generate VMI object ;
-
virt-controller Listen to the VMI The creation of , Judge the virtual machine DataVolume Whether it is initialized , If it's not initialized , Create DateVolume Initialize and prepare the data required by the virtual machine ;
-
virtual machine DataVolume Once the initialization is complete ,virt-controller establish virt-launcher Pod To start the virtual machine ;
-
kubernetes Scheduling virtual machines Pod To a host in the cluster ;
-
virt-controller Watch To VMI Your container has started , to update VMI Object nodeName Field . Follow up work by virt-handler Take over for further operation ;
-
virt-handler(DaemonSet)Watch To VMI Assigned to the host running it , By acquiring Domain And vmi State to decide to send a command to start the virtual machine ;
-
virt-launcher Get virt-handler command , And libvirtd Instance communication to operate the virtual machine .
above , We have completed the preliminary creation of the virtual machine . But during the virtual machine creation process , Different status prompts may appear , This paper lists several common states and their diagrams :
-
Pending: The virtual machine instance has been created , Wait for the subsequent control process ;
-
Scheduling: virtual machine Pod Created , Scheduling ;
-
Scheduled: virtual machine Pod Dispatch complete , And in running state , After this state virt-controller Control over , from virt-handler Take over the follow-up work ;
-
Running: The virtual machine is running normally ;
-
Succeeded: The virtual machine received sigterm Exit due to signal or internal shutdown operation ;
-
Failed: Virtual machine due to abnormal conditions crash;
Virtual machine storage
Storage part Kubevirt Can be based on Kubetnetes function , So it can be reused Kubernetes Storage design in , Such as PVC、PV etc. . meanwhile ,Kubevirt stay PVC Customized on DataVolume resources .
DataVolume By Kubevirt The team developed and open source container data import plug-ins CDI(containerized-data-importer) Defined by the CRD.
Before the virtual machine starts, it will create DataVolume object , from CDI The controller is automatically created PVC, And download data according to the supported data sources . Virtual Pod Before starting Kubernetes Would call CSI Mount the cloud disk on the host , It is expressed as a piece of equipment and hung on the equipment to launcher Pod in , Finally, the virtual machine passes virtio Drive access disk device .
Virtual machine network
On the Internet ,Kubevirt Reuse the Kubernetes Container network for , And on top of this 4 A virtual machine network model . At present Kubevirt Four main network modes are supported :
// +k8s:openapi-gen=true
type InterfaceBindingMethod struct {
Bridge *InterfaceBridge `json:"bridge,omitempty"`
Slirp *InterfaceSlirp `json:"slirp,omitempty"`
Masquerade *InterfaceMasquerade `json:"masquerade,omitempty"`
SRIOV *InterfaceSRIOV `json:"sriov,omitempty"`
}
Virtual machines and container networks are interconnected , It can realize the interconnection between different forms of services of virtual machines and containers . Here's an introduction Bridge Pattern , This method is relatively simple to implement , But the network loss is also large :
-
Bridge In mode pod Of veth pair Still by cni Manage creation , and virt-launcher Will Pod IP cast off ,pod veth equipment eth0 Only as a bridge between the virtual network card of the virtual machine and the external network .
-
virt-launcher stay pod Created in tap equipment vnet0 and bridge Bridge equipment br1, At the same time, a simple single ip dhcp server, Boot in virtual machine dhclient, Virt-launcher take IP Assign to virtual machine .
03 summary
The above is based on Kubevirt The technical scheme of constructing edge computing example , Also on the Kubevirt The architecture and main modules are described in detail .Kubevirt As Kubernetes Of CRD plug-in unit , Not only for Kubernetes It complements the ability of scheduling virtual machines , It also provides a relatively mature platform for solving the fusion scheduling of container and virtual machine 、 Viable solutions .
Reference material :
[1] https://github.com/kubevirt/kubevirt
[2] https://kubevirt.io/
版权声明
本文为[Volcanic engine edge calculation]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231744412999.html
边栏推荐
- 470. 用 Rand7() 实现 Rand10()
- Leak detection and vacancy filling (VIII)
- 1217_ Generating target files using scons
- How to manually implement the mechanism of triggering garbage collection in node
- Hcip fifth experiment
- Applet learning notes (I)
- C1小笔记【任务训练篇二】
- 394. 字符串解码-辅助栈
- Read software engineering at Google (15)
- Add drag and drop function to El dialog
猜你喜欢
嵌入式系统中,FLASH中的程序代码必须搬到RAM中运行吗?
01 - get to know the advantages of sketch sketch
440. 字典序的第K小数字(困难)-字典树-数节点-字节跳动高频题
关于gcc输出typeid完整名的方法
394. String decoding - auxiliary stack
Qt 修改UI没有生效
【Appium】通过设计关键字驱动文件来编写脚本
Index: teach you index from zero basis to proficient use
On the method of outputting the complete name of typeID from GCC
2021长城杯WP
随机推荐
古代埃及希腊,数学用的什么进制
[binary number] maximum depth of binary tree + maximum depth of n-ary tree
The system cannot be started after AHCI is enabled
470. 用 Rand7() 实现 Rand10()
209. 长度最小的子数组-滑动窗口
JVM class loading mechanism
Compilation principle first set follow set select set prediction analysis table to judge whether the symbol string conforms to the grammar definition (with source code!!!)
2022年广东省安全员A证第三批(主要负责人)特种作业证考试题库及在线模拟考试
SQL optimization for advanced learning of MySQL [insert, primary key, sort, group, page, count]
Qt error: /usr/bin/ld: cannot find -lGL: No such file or directory
Type judgment in [untitled] JS
470. Rand10() is implemented with rand7()
JS forms the items with the same name in the array object into the same array according to the name
Hcip fifth experiment
MySQL advanced index [classification, performance analysis, use, design principles]
关于gcc输出typeid完整名的方法
干货 | 快速抽取缩略图是怎么练成的?
vite配置proxy代理解决跨域
uni-app黑马优购项目学习记录(下)
QT modification UI does not take effect