A Deep Insight of Alibaba Open Source Project - Pouch

简介: Pouch is an open-source project created by Alibaba Group to promote the container technology movement.

1

By Allen Sun, Senior Engineer at Alibaba Group

Pouch's vision is to advance container ecosystem and promote container standards OCI (Open Container Initiative), so that container technologies could become the foundation for application development in the Cloud era.

Pouch can pack, deliver, and run any applications. It provides applications with a lightweight runtime environment with strong isolation and minimal overhead. Pouch isolates applications from varying runtime environment, and minimizes operational workload. Meanwhile, Pouch minimizes the effort for application developers to write Cloud-native applications, or to migrate legacy ones to a Cloud platform.

Features

Here we listed several important features of Pouch:

Security: Pouch is designed to be secure by default. It includes a lot of security features, such as hypervisor-based container technology, lxcfs, patched Linux kernel and so on.
P2P distribution: Pouch utilizes Dragonfly, a P2P-base distribution system, to achieve lightning-fast container image distribution.
Rich container: Besides the common ways of running container, Pouch includes a rich container mode, which integrates more services, hooks, and many others container internals to guarantee container's running like usual.
Kernel compatibility: Enables OCI-compatible runtimes to work on old kernel versions, like Linux kernel 2.6.32+.
Simplicity: You can set up Pouch in just a few steps.

From these features, we could conclude that Pouch is designed to fit very large-scale and production application scenarios. Container technology brings convenience to pack applications, but applications in containers are less secure as compared to applications in VMs. It will definitely be a concern of decision makers to choose container technology on the market. However, Pouch is developed by Alibaba, one of the largest e-commerce company in the world. Alibaba has faced a wide variety of security issues and have successfully coped with these issues. A lot of these issues are solved using hypervisor-based container and security-patched kernels.

P2P image distribution is one of the most practical thoughts we can think of for businesses as large as Alibaba. Tools like Dragonfly are the essentials in large companies. Unlike P2P image distribution, rich container is the one that confuses many at first glance. It works in the opposite way as compared with the ones that the container community advocates.

Pouch’s reason is quite simple; no one is willing to adopt a technology at once if it appears to be invasive, even if it brings huge benefits. This also confirms Pouch’s practical point of view. Kernel Compatibility is the reality almost every enterprise would face, but community seems to consider it less. How to make it in current kernel system is the key point that may be revealed in the future.

Architecture

Knowing the feature of Pouch and the benefits it brings, we take a deep dive into its architecture. Pouch has two kinds of architectures from two dimensions: ecosystem architecture and inner component architecture.

Ecosystem architecture: illustrates how Pouch fits into the container ecosystem

2

The ecosystem architecture may be a little bit complicated at first glance. Take it easy. We can get a thorough understanding of it from the following three dimensions.

Runtime Layer

Runtime layer is located on the top-right in the architecture picture. This dimension mainly focuses on OCI-compatible runtimes supported in Pouch. These runtimes unify specifications for standards on operating system process and application containers. Currently, Pouch supports four kinds of OCI-compatible runtimes:

• runC
• runlxc
• runV
• clear containers

With runC, Pouch creates common containers like other container engine does, for example Docker. With runlxc, Pouch creates containers based on LXC. runlxc helps a lot when users need to run containers on a wide variaty of Linux kernels with the ability to be compatible with kernel 2.6.32+. Hypervisor-based containers have many application scenarios as well. Pouch will support it with runV and clear container.

All these four runtimes mentioned above are supported under containerd. Containerd takes over all detailed container management, including creation, start, stop, deletion and so on.

Orchestration Layer

Pouch is always active on supporting Kubernetes since the first day of its conception. We illustrate this part on the top half of the architecture diagram. First, Pouch will integrate cri-containerd inside, so Kubernetes can easily dominate Pouch to manage Pod. The workflow will pass cri-containerd, containerd client, containerd, runC/runV and pod. When configuring network of Pod, cri-containerd will take advantage of network plugins that implement CNI interface.

Container Layer

We support not only Pod in Kubernetes cluster, but also simple container management for users. This is especially useful for developers. In other words, Pouch supports single container API. In this way, workflow passes pouchd, containerd client, containerd, runC/runV and container. On the aspect of network, Pouch uses libnetwork to construct container's network. What's more, lxcfs is also used to guarantee the isolation between containers and between containers and host.

Component architecture: describes the interactions between various components inside Pouch.

3

Pouch CLI

There are lots of different commands encapsulated in Pouch CLI, like create, start, stop, exec and so on. Users can interact with Pouchd by Pouch CLI. When executing a command, Pouch CLI will translate it into Pouchd API calls to satisfy users' demand. Pouch Client API is a well-encapsulated package in Pouch CLI. It is very easy for others to integrate Pouch Client Package into third-party software. And this package currently only supports Golang language. When calling Pouchd via Pouch Client Package, the communication is over HTTP.

Pouchd

Pouchd is designed decoupled from the very beginning. It makes Pouchd quite easy to understand. And it helps a lot for us to hack on Pouch. In general, we treat that Pouchd can be split into the following pieces:

• HTTP server
• bridge layer
• Manager(System/Network/Volume/Container/Image)
• ctrd

HTTP Server receives API calls directly and replies to client side. Its job is to parse requests and construct correct struct, which is supposed to be passed to bridge layer, and to construct response no matter server succeeds in handling request or fails.

bridge layer is a translation layer which handles objects from client to meet managers or containerd's demand and handles objects from managers and containerd to make response compatible with Moby's API.

Manager is main processor of Pouchd. It deals proper object from requests, and does the corresponding work. There are five managers currently in Pouchd: container manager, image manager, network manager, volume manager and system manager.

ctrd is containerd client in Pouchd. When managers need to communicate with container, ctrd is the right thing to do this work. Managers call functions in ctrd and send request towards containerd. In addition, when state of container changes, containerd is the first component to be aware of this, and ctrd has container watch goroutines to detect this and update inner data stored in cache.

Conclusion

Although Pouch technology is widely used in Alibaba, there is still a long road ahead for a fully stable and open source version of Pouch. We will focus our efforts on developing Pouch together with the community.

Personal Profile:

Allen Sun, Senior Engineer at Alibaba Group, is currently responsible for the open source construction of the Pouch container project at Alibaba. He has been involved in cloud computing for over 5 years, and is one of the first batch of researchers and practitioners of container technology. Allen played a central role in the evangelism of container technology. He is the author of the book The Source Code Analysis of Docker and a personal advocate of the open source spirit, as well as a Maintainer of the Docker Swarm Project.

You can visit Allen's LinkedIn page through this link.

目录
相关文章
|
8月前
|
存储 人工智能 运维
集之互动推出AIGC视频全栈解决方案,“陪跑模式”解决企业内容生产难题
集之互动正式推出其“服务+培训+定制系统”的AIGC视频全栈解决方案,旨在通过“AI战略合作伙伴”式的陪跑服务,解决企业在视频内容生产中面临的高成本、长周期、安全合规及技术落地难等核心痛点。
314 5
vite环境引入web worker方法
在 vite 环境中使用 web worker 时,如果遇到生产环境中 worker.js 文件的 MIME 类型被识别为 text/html,导致报错无法运行的情况时,可以参考以下两种方法,原理都是避免编译时产出单独的 worker.js 文件。方法一worker文件不需要包装,引入时后缀增加 ?worker&inline,使用时直接 new ImportedWorker();self.
2013 1
|
存储 Cloud Native Linux
C++ vector内存增长机制
C++ vector内存增长机制
|
关系型数据库 MySQL Linux
部署MySQL数据库(Linux)
MySQL是一个关系型数据库管理系统,常用于LAMP和LNMP等网站场景中。本教程介绍如何在Linux系统ECS实例上安装、配置以及远程访问MySQL数据库。
2889 9
|
移动开发 监控 网络协议
基于Socket通讯(C#)和WebSocket协议(net)编写的两种聊天功能(文末附源码下载地址)
基于Socket通讯(C#)和WebSocket协议(net)编写的两种聊天功能(文末附源码下载地址)
|
Docker 容器
如何解决Docker容器和宿主机时间同步问题
在使用了Docker以后,大家可能遇到的一个问题就是Docker容器的时间和宿主机时间不同步。造成这个问题的主要原因是宿主机设置了时区,而Docker容器并且设置,导致两者相差8小时。 接下来,我们通过在在宿主机和容器里分别执行date命令来看下实际的情况。 在宿主机执行date命令的结果:
34782 0
|
存储 XML 前端开发
【Flutter前端技术开发专栏】Flutter中的网络请求与数据处理
【4月更文挑战第30天】本文介绍了Flutter开发中的网络请求和数据处理。 Flutter开发者可选择http(官方库)或dio(功能更强大)进行网络请求。http库简单易用,dio支持更多功能如拦截器。数据处理涉及JSON和XML解析,数据存储可选SharedPreferences或Hive,数据传递推荐使用InheritedWidget或Provider状态管理库。了解这些知识点能提升Flutter开发效率。
648 0
【Flutter前端技术开发专栏】Flutter中的网络请求与数据处理