Tag: unikernels

  • Why Unikernels Are Great for DevOps

    Why Unikernels Are Great for DevOps

    DevOps tooling seems to be in a never-ending state of self-transformation. The continuing evolution of infrastructure and the tools that go with it are forever creating new ecosystems. On the infrastructure side, we saw VMWare, Citrix and other companies bring to market massive virtualization in the late ’90s and early ’00s. This, of course, prompted a little bookstore in Seattle to unleash something known as “the cloud,” forever changing the way developers push code to production.

    The cloud, of course, is just an API around virtualization. A lot of the infrastructure changes prompted configuration management software, including Chef and Puppet, to emerge. Puppet is now 15 years old and Chef is around 10; even Ansible is now 7 years old.

    In the past years, we’ve seen tools such as Terraform emerge and other higher-layer infrastructure, such as Docker, which led into Kubernetes. There’s a lot of tooling out there to make applications run on servers. Just as the containers/Kubernetes ecosystems have tried to implement change on top of virtualization infrastructure, we are starting to see developers dig back down into the operating system layer to improve infrastructure there. This leads us to our topic today: unikernels.

    Unikernels are single-purpose virtual machines (VM). They only run one application—which is interesting when you think about it, because that’s precisely how a lot of DevOps practitioners provision their applications today. There is way too much software to provision nowadays—pools of app servers, clusters of databases, etc. Unikernels are fast to boot, fast to run, small in size, way more secure than Linux or containers and, if you have access to your own bare metal—either in your data center or through a provider—you can run thousands of them per box.

    Some stats? Some can boot in less than five milliseconds—that’s slightly slower than calling fork (three milliseconds) but orders of magnitude faster than Linux. Some can run databases including Cassandra and MySQL, 20 percent faster. Some people (yours truly included) have provisioned thousands of them on a single box with no performance degradation. Some are reporting them running as a VM faster than a comparable bare-metal Linux installation of that application. Clearly, this is worth investigating.

    There are many different methods that a given organization can take to provision software, but it’s pretty clear that popping into a server over SSH and sudo apt-get install something is very much of a downtrend. Phrases such as “immutable infrastructure” and “continuous deployment” fly right in the face of this sort of practice. You are either rebuilding your containers, rebuilding your instance or both. Unikernels really embrace this model as there is no apt-get-like functionality in them and you can’t log in to them remotely. They don’t even have the concept of users, mainly because at the end of the day, why do you even need them?

    At scale, it’s getting more difficult by the day to make the argument for this construct. If the app is misbehaving, shoot it in the head and take it down. Debug the reason locally. It’s extremely rare for an end user to reason that there is something wrong with the host operating system.

    In a unikernel, the only reason you’ll see a reference to a user is that most apps will demand to be run as a particular user or do things such as check for root privileges. In our case, if you look at underlying calls such as getuid, they are just stubs because we don’t need or use them. Keep in mind that this isn’t the mid-’90s anymore. We don’t have boxes laying around, where there are half-dozen users all running their code on the same box anymore. That model has long been gone. Unikernels don’t have shells and don’t have the notion of running other programs besides the one that is running.

    If it’s easier to think about, consider that unikernels are much more like processes than they are like operating systems, although they share characteristics of both. While many link, the application in others will load. Unikernels are a concept that are largely misunderstood because everyone assumes it’s somehow like Linux. Just as unikernels are not just “containers 2.0,” unikernels are very different from Linux as well. Linux is a general-purpose operating system, while unikernels only run one application. Linux was made to run on bare metal, while unikernels are made to run as VMs. Keep in mind Linux predates VMWare by a solid eight or nine years and the cloud by many more. Operating system researchers wanted to go this route in the ’90s, but we just weren’t ready yet.

    Another way to think about them is that they implement a sandbox for server-side applications. Much in the same way that the Chrome browser isolates each tab from each other to prevent one evil site from messing with another browser tab, unikernels prevent one application from messing with another application. Although under the hood, the technical implementation is quite different. More importantly, the unikernel single-process model eliminates the capability of running other ad-hoc programs inside the same VM. This is a huge blow to attackers who wish to run other programs on the same machine. It doesn’t prevent things such as remote file inclusion (RFI) attacks for various scripting languages, but for compiled and VM runtimes, it’s a striking blow because it deals with the fundamental problem of attackers using exploits only as a key to enter the server. Once they are on the server, they want to run their programs such as mysqldump or a cryptominer. They could care less about your software. Those organizations practicing shift-left security, or zero-trust infrastructure, should be keeping the development of unikernels on their radar.

    However, unikernels are not without their problems. These are computers we are talking about here. One of the larger problems for unikernel adoption was that to build them, you had to be a lower-level systems engineer doing things such as twiddling CFLAGS in makefiles or patching foreign codebases you’d never patch yourself. This was problematic and something we wanted to fix with a new open source tool. So, we opened up OPS—which can take any existing Linux application and run it as a unikernel, making their use a lot easier.

    If you’ve made it this far, I’m going to reward you: Let’s build and run a unikernel right now. Then, at least, the next time someone asks you if you’ve used them before, you can say yes.

    First thing is, you’ll want to grab OPS. You can paste this into a Linux or Mac shell, and it will download and install itself:


    curl https://ops.city/get.sh -sSfL | sh

    If you’d like to examine the source and build it yourself go to https://github.com/nanovms/ops.

    Next, let’s create a project directory:


    mkdir nodejs && cd nodejs

    Put this into a hi.js file:


    var http = require('http'); http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('Hello Worldn'); }).listen(8083, "0.0.0.0"); console.log('Server running at http://127.0.0.1:8083/');

    This is simply a small little web server that listens on port 8083.

    At this point you might be asking yourself, Do I need to install node on my system? The answer is no—not unless you plan on using external packages.

    Now we can run it:

    If it’s the first time you run ops, it will first download a node “package,” which is the interpreter and anything else it needs to run. For some languages, such as Python and Ruby, this can be substantial.

    Then it builds a small disk-bootable disk image that contains your application code and, as you can see, boot straight into it. There is no init manager like Linux and there aren’t 30 different services that get fired off. Keep in mind this is a single process running.

    Now you should be able to hit it up with curl and see it run:

    You’ve just built and run your first unikernel. How cool is that?

    As certain trends such as “serverless,” “functions as a service,” and “no ops” gain steam, these concepts go hand in hand with unikernels. DevOps practitioners at organizations that use microservices and containers will also want to take notice as the amount of work to deploy artifacts such as these decrease considerably. Why is that? One of the many problems that containers had to struggle with was that all the existing underlying infrastructure layers that live at the virtualization layer, such as file systems and networking, had to be shifted up a few layers. Not only did this introduce performance and security challenges, but it also threw out the 20 years of virtualization software and ecosystem development that already existed. What’s interesting about unikernels is that they are always deployed as VMs, so they get to re-use a lot of the underlying ecosystem that has been existent, with very little or no change required.

    From an adoption standpoint, unikernels are flying at ultra-sonic speeds under the radar. A lot of people are not aware of how many projects or organizations are working on unikernels today. Unikernels are starting to attract major attention from many various groups and institutions. Even famous, old stalwart Linux contributors such as Ulrich Drepper, the maintainer of libc, are working on unikernel projects today. Now there are even foundations and consortiums for unikernels. One recently announced was the UNICORE project. IBM even listed its No. 1 cloud patent recently as a hypervisor built for unikernels.

    If you’re are a self-described DevOps person, it’d behoove you to learn more about unikernels and start playing around with them to understand them better. They aren’t going to kill Linux and they’re not going to kill containers, but do expect to see massive adoption in the coming years—not just because of their security and performance benefits, but because of the new forms of compute they unlock.

    — Ian Eyberg

  • One Secure OS for the Cloud – The Rise of Unikernels

    One Secure OS for the Cloud – The Rise of Unikernels

    In the last few years, a number of open source projects have started to build interesting new technologies to create faster and more secure and scalable cloud applications. The name: unikernels. The goal: develop a new breed of applications (or port existing ones) for the cloud that significantly improve security, performance and scalability by reducing the traditional layer-cake application stack into a single unikernel virtual machine (VM) image. In other words, the operating system, any libraries you need and the application itself are compiled into a small unikernel image.

    Traditional application stacks run in parallel within an operating system, which in turn may run in a (VM). The operating system manages resources and isolates applications from one another. In a unikernel, a single application is run in single VM, relying instead on the hypervisor to isolate those VMs. Unikernels are constructed by using “library operating systems,” from which the user selects the minimal set of services required for an application to run. In some unikernels, the compiler and linker eliminate all code that is not used and packages it into a single image that can be directly deployed to the cloud. These sealed, fixed-purpose images run directly on a hypervisor without an intervening guest OS such as Linux.

    Screen Shot 2015-04-01 at 10.59.12 PMUnikernels also deliver impressive flexibility, speed and versatility for cross-platform environments, big data analytics and scale-out cloud computing. Like container-based solutions, unikernels fulfill the promise of easy deployment, but also offer an extremely tiny, specialized runtime footprint that is much less vulnerable to attack

    A number of unikernel open source projects are beginning to take off, each with its own unique focus and approach. For example, MirageOS and HaLVM take a clean-slate approach and emphasize safety and security; ClickOS stresses speed; while OSv and Rump kernels aim for compatibility with existing applications. Both OSv and Rump kernels have made significant progress in porting existing applications: for example MySQL, PHP and Nginx have been ported to Rump Kernels, whereas many applications such as Tomcat, Jetty, Cassandra, OpenJDK and others have been ported to OSv. Meanwhile, MirageOS has demonstrated 1MB unikernels that serve DNS, Git and SSL web traffic with complete type safety down to the device drivers.

    Here’s a closer look at this new, more secure approach for deploying cloud services.

    Unikernel Applications Are Easy To Deploy

    The basic development and deployment model for unikernel applications is somewhat different than your traditional application stack where an application is delivered as a set of binaries, packages or some sort of installer. Different unikernels take slightly distinct approaches, but in all cases the unikernel application is in effect a VM image, which can directly be deployed into the cloud with zero configuration. This is not all that different from the build once, deploy everywhere model in use by Docker for example.

    Let’s look at two unikernels that each have a different workflow.

    The typical development workflow for MirageOS is that a developer writes the unikernel application on his local machine (e.g. Mac OSX) and compiles it against a local target. The correct libraries are provisioned through the OPAM package manager and included into the test image. The rationale for not directly developing in a hypervisor is that richer development tools are available locally. After all, a unikernel image is a VM image that contains nothing else but config data and the libraries and services that are used by the application. When the application has been tested, the developer will build a VM image and deploy it into a Xen-based cloud.

    Since MirageOS unikernels are so lean, they can even be checked into version-control themselves. This approach has been practiced by the MirageOS community for more than two years and has proven to be extremely flexible and agile. A recent post by Amir Chaudhry on ”Heroku for Unikernels” describes the kind of end-to-end workflows that the team is using.

    In the case of OSv, Cloudius Systems developed a tool for rapidly building and running OSv applications called Capstan. “Capstan is as simple and fast as using Docker for creating containers, but the result is a complete VM image that will run on any hypervisor with OSv support,” according to Cloudius Systems.

    How Unikernels Deliver Better Security

    Security is a key concern as industries move toward networked, scale-out designs with new and varying workloads and data types. Adam Wick, creator of the Haskell Lightweight Virtual Machine (HaLVM) and a research lead at Galois Inc., which counts the U.S. Department of Defense and DARPA as clients, says 2015 is already turning out to be a break-out year for security.

    “Cloud computing has been a hot topic for several years now, and we’ve seen a wealth of projects and technologies that take advantage of the flexibility the cloud offers,” said Wick. “At the same time though, we’ve seen record-breaking security breach after record-breaking security breach.”

    The creator of MirageOS, Anil Madhavapeddy, says it’s “simply irresponsible to continue to knowingly provision code that is potentially unsafe, and especially so as we head into a year full of promise about smart cities and ubiquitous Internet of Things.”

    Galois, which specializes in R&D for new technologies, says enterprises are increasingly interested in the ability to cleanly separate functionality to limit the effect of a breach to just the component affected, rather than infecting the whole system. For next-generation and in-house clouds, unikernels make it possible to run thousands of small VMs per host.

    Galois, uses this capability in their CyberChaff project, which uses minimal VMs to improve intrusion detection on sensitive networks, while others have used similar mechanisms to save considerable cost in hardware, electricity, and cooling; all while reducing the attack surface exposed to malicious hackers.

    Traditional application stacks running in Linux, and to a lesser degree Docker images, rely on a fairly heavyweight core OS to provide critical services. Thus, a vulnerability in the Linux kernel affects every Linux container, Wick said. In contrast, unikernels follow a an approach similar to a la carte menus: thus only minimal functionality and services needed to run the application are present within a unikernel image. Thus writing an exploit to attack a unikernel application is much more difficult than doing the same for traditional application stacks.

    Cloudius Systems, which is running a private beta of OSv, which it tags the operating system for the cloud, recognizes that progress is being made on making container technologies more secure.

    “Rocket is indeed an improvement over Docker, but containers aren’t a multi-tenant solution by design,” said CEO Dor Laor. “No matter how many SELinux Linux policies you throw on containers, the attack surface will still span all aspects of the kernel.”

    Conclusion

    The key takeaway for organizations worried about security is that they should treat their infrastructure in a less monolithic way. Unikernels allow for the careful management of particularly critical portions of an organization’s data and processing needs. While it does take some extra work to build unikernel applications, it’s getting easier every day as more developers address orchestration, logging and monitoring challenges. At the same time, unikernels are no harder to package and deploy than Docker containers. This means unikernels are coming of age just as many developers are getting serious about security as they begin to build scale-out, distributed systems.

     

    About the Author/Lars Kurth

    lars-devopsLars Kurth is the Xen Project Advisory Board Chairman. A Collaborative Project at The Linux Foundation, the Xen Project community is focused on advancing virtualization in a number of different commercial and open source market segments, including server virtualization, Infrastructure as a Services (IaaS), desktop virtualization, security applications, embedded and hardware appliances. Designed from the start for cloud computing, Xen Project members include: Amazon Web Services, AMD, ARM, Cavium, Cisco, Citrix, Google, Intel, NetApp, Oracle, Rackspace, and Verizon Terremark. For more information, please visit XenProject.org.