<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Nithin Jois</title>
    <description>The latest articles on Forem by Nithin Jois (@bondijois).</description>
    <link>https://forem.com/bondijois</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F570381%2Fcffe2391-0011-4578-a894-06b4b8b171aa.jpg</url>
      <title>Forem: Nithin Jois</title>
      <link>https://forem.com/bondijois</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/bondijois"/>
    <language>en</language>
    <item>
      <title>Understanding Unikernels: The Future of Cloud Computing, Probably</title>
      <dc:creator>Nithin Jois</dc:creator>
      <pubDate>Fri, 12 Feb 2021 15:48:28 +0000</pubDate>
      <link>https://forem.com/bondijois/understanding-unikernels-the-future-of-cloud-computing-probably-57a3</link>
      <guid>https://forem.com/bondijois/understanding-unikernels-the-future-of-cloud-computing-probably-57a3</guid>
      <description>&lt;p&gt;Having used Containers, Kubernetes and Serverless (a lot!) over the last few years,  I catch myself wondering &lt;strong&gt;'What next?'&lt;/strong&gt; when it comes to more efficient, faster and secure units of computing. My initial research indicates that Unikernels could be a promising bet.&lt;/p&gt;

&lt;h2&gt;
  
  
  What are Unikernels?
&lt;/h2&gt;

&lt;p&gt;Here's how I  summarised it for myself after a fair bit of reading:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Single purpose compute environments packaged with necessary dependencies, runtime, libraries, kernel capabilities and everything else required boot and run Application code, and System code in a single address space with No Operating System, No Users and No Shell resulting in smaller, faster and a more secure system.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The code-base and necessary components of run unikernels are typically a few MBs in size, thereby decreasing the possibility of multiple unnecessary and, potentially vulnerable components being installed. To top it off, System calls are usually unsupported as well. Additionally, randomising the memory layout(ASLR) makes it almost impossible for an attacker to invoke specific OS function calls.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Summary&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;No Shell&lt;/li&gt;
&lt;li&gt;No Users&lt;/li&gt;
&lt;li&gt;Single Process&lt;/li&gt;
&lt;li&gt;Does not need underlying Host OS(typically runs on Hypervisor)&lt;/li&gt;
&lt;li&gt;Decreased Attack Surface&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Types of Unikernels
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Clean Slate
&lt;/h4&gt;

&lt;p&gt;Restricted to a single language with all the necessary interfaces provided and also allows language specific virtual machines to function.&lt;/p&gt;

&lt;p&gt;Example: MirageOS, IncludeOS, HalVM, LING, runtime.js&lt;/p&gt;

&lt;h4&gt;
  
  
  Legacy
&lt;/h4&gt;

&lt;p&gt;Implemented using the POSIX(Portable Operating System Interface) standard which makes it possible to run most POSIX-Compliant applications and services with a few configuration changes without having to re-write them completely.&lt;/p&gt;

&lt;p&gt;Example: OSv, Graphene, Nanos, Rumprun&lt;/p&gt;




&lt;h2&gt;
  
  
  VMs vs. Containers vs. Lightweight VMs vs. Unikernels
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;VMs&lt;/th&gt;
&lt;th&gt;Containers&lt;/th&gt;
&lt;th&gt;Lightweight VMs&lt;/th&gt;
&lt;th&gt;Unikernels&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Runs on a Hypervisor&lt;/td&gt;
&lt;td&gt;Requires a Host OS&lt;/td&gt;
&lt;td&gt;Requires a Host OS&lt;/td&gt;
&lt;td&gt;Runs on a Hypervisor&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Uses own Kernel + Allocated Resources&lt;/td&gt;
&lt;td&gt;Relies on Host Kernel + Consumes Host Resources&lt;/td&gt;
&lt;td&gt;Dedicated virtualized Kernel(KVM) + Allocated Resources&lt;/td&gt;
&lt;td&gt;Built-in Kernel libraries + Allocated Resources&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Multiple Processes&lt;/td&gt;
&lt;td&gt;Multiple Processes&lt;/td&gt;
&lt;td&gt;Multiple Processes&lt;/td&gt;
&lt;td&gt;Single Process&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Large Attack Surface&lt;/td&gt;
&lt;td&gt;Relatively Low Attack Surface&lt;/td&gt;
&lt;td&gt;Low Attack Surface&lt;/td&gt;
&lt;td&gt;Minimal Attack Surface&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Comparison of High-level Architectures
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fc6exr95fy4998bexxm4t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fc6exr95fy4998bexxm4t.png" alt="VMs vs. Containers vs. Lightweight VMs vs. Unikernels"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Why isn't everyone using this already!?
&lt;/h2&gt;

&lt;p&gt;Although Unikernels have been around for a while, one of the main reasons it hasn't been in the spotlight all that much is probably owing to the fact that most applications are designed to run as multi-process systems. Migrating them to a single-process, single address-space system can be challenging to say the least. Managing and using unikernels for someone not completely familiar with the system can be challenging as well, but there are projects that are making this relatively easy.&lt;/p&gt;

&lt;p&gt;Thanks to DevSecOps and Microservices, a lot of the complexity in Operations and Security is fairly abstracted. But, asking developers to become experts at low-level C and learn all there is about Operating Systems, and the necessary libraries to write Unikernels for Applications isn't going to end very well. Finally, debugging and testing can bequite challenging for the average developer unless they know their way around strace, ftrace and GDB. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Remember, you're not going to be testing just the application code anymore.&lt;/strong&gt; If the libraries, or the language are modified to work with unikernels, those will have to be tested as well.&lt;/p&gt;

&lt;p&gt;For Unikernels to be widely used, the complexity behind them should ideally be abstracted, and the effort to implement, deploy and manage should be seamless.&lt;/p&gt;




&lt;h2&gt;
  
  
  Implementing Unikernels
&lt;/h2&gt;

&lt;p&gt;I've decided to use &lt;a href="https://nanos.org/" rel="noopener noreferrer"&gt;Nanos&lt;/a&gt; unikernel by &lt;a href="https://nanovms.com/?via=nithinjois" rel="noopener noreferrer"&gt;NanoVMs&lt;/a&gt; and their CLI tool &lt;a href="https://ops.city/" rel="noopener noreferrer"&gt;ops&lt;/a&gt; to build, and deploy. It seems like the simplest option out there, and the documentation is fairly straight-forward as well. &lt;/p&gt;

&lt;p&gt;Additionally, the fact that they support deployments on &lt;a href="https://nanos.org/thebook#infrastructure" rel="noopener noreferrer"&gt;multiple cloud-providers&lt;/a&gt; right out of the box seemed pretty nifty. I'm going to leverage this feature and deploy on AWS.&lt;/p&gt;

&lt;p&gt;Ops is going package everything to create an AMI(Amazon Machine Image), which I can then launch as an EC2 instance.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Disclaimer:&lt;/strong&gt; &lt;em&gt;I'm a tiny, tiny investor in &lt;a href="https://nanovms.com/?via=nithinjois" rel="noopener noreferrer"&gt;NanoVMs&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Prerequisites
&lt;/h3&gt;

&lt;p&gt;Since I didn't want to mess with my machine, I got myself a lightsail server running ubuntu 20.04 LTS. Once the necessary dependencies(&lt;a href="https://aws.amazon.com/cli/" rel="noopener noreferrer"&gt;aws-cli&lt;/a&gt;, &lt;a href="https://www.qemu.org/download/" rel="noopener noreferrer"&gt;qemu&lt;/a&gt;, &lt;a href="https://golang.org/doc/install" rel="noopener noreferrer"&gt;golang&lt;/a&gt; and &lt;a href="https://ops.city/" rel="noopener noreferrer"&gt;ops&lt;/a&gt;) were installed on the server, I configured aws-cli by running &lt;code&gt;aws configure&lt;/code&gt; and, created an aws s3 bucket called &lt;code&gt;s3://understanding-unikernels&lt;/code&gt; that's going to help create the AMI.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;prerequisites.sh&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;apt update &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; apt &lt;span class="nt"&gt;-y&lt;/span&gt; upgrade
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Installing golang"&lt;/span&gt;
wget https://golang.org/dl/go1.15.7.linux-amd64.tar.gz &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;tar&lt;/span&gt; &lt;span class="nt"&gt;-C&lt;/span&gt; /usr/local &lt;span class="nt"&gt;-xzf&lt;/span&gt; go1.15.7.linux-amd64.tar.gz
&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;PATH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$PATH&lt;/span&gt;:/usr/local/go/bin
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Installing AWS-CLI and qemu"&lt;/span&gt;
apt &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-y&lt;/span&gt; awscli qemu
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Installing ops"&lt;/span&gt;
curl https://ops.city/get.sh &lt;span class="nt"&gt;-sSfL&lt;/span&gt; | sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fgbc4gp5osznaurc3bu1s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fgbc4gp5osznaurc3bu1s.png" alt="Installed prerequisites and respective versions"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  IAM Permissions
&lt;/h3&gt;

&lt;p&gt;The aws user I configured on my server for aws-cli has &lt;code&gt;AdministratorAccess&lt;/code&gt; policy attached to it and, also needs the &lt;code&gt;vmimport&lt;/code&gt; policy since ops is going to be importing AMI(s). This can be done from the &lt;a href="https://console.aws.amazon.com/iam/home?region=us-west-2#/users" rel="noopener noreferrer"&gt;AWS Management Console&lt;/a&gt; by attaching the &lt;code&gt;vmimport&lt;/code&gt; managed policy to the aws user.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;I definitely &lt;em&gt;do not&lt;/em&gt; recommend using &lt;code&gt;AdministratorAccess&lt;/code&gt; policy. I'm only using it since I'm testing things out, and it makes things a lot easier!&lt;/p&gt;

&lt;p&gt;If &lt;strong&gt;Cloud Security&lt;/strong&gt;, &lt;strong&gt;Containers&lt;/strong&gt;, &lt;strong&gt;Kubernetes Security&lt;/strong&gt; and &lt;strong&gt;DevSecOps&lt;/strong&gt; is something you're interested in, be sure to check out &lt;a href="https://appsecengineer.com/?via=nithinjois" rel="noopener noreferrer"&gt;AppSecEngineer&lt;/a&gt; for self-paced trainings with state-of-the-art hands-on Labs!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fjob7o0oocdxnbjyabovz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fjob7o0oocdxnbjyabovz.png" alt="IAM Permissions"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Create Snapshot Image
&lt;/h3&gt;

&lt;p&gt;Now that all the prerequisites have been installed, and the necessary dependencies are configured, I'm going to create a super-simple golang static file server that's going to serve &lt;code&gt;index.html&lt;/code&gt; on port 8080.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;server.go&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;package&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s"&gt;"log"&lt;/span&gt;
    &lt;span class="s"&gt;"net/http"&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;fs&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;http&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;FileServer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;http&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Dir&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"static"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="n"&gt;http&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Handle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"/"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fs&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;log&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Listening...on 8080"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;http&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ListenAndServe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;":8080"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;nil&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;static/index.html&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;!doctype html&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;html&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;charset=&lt;/span&gt;&lt;span class="s"&gt;"utf-8"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;title&amp;gt;&lt;/span&gt;Hello!&lt;span class="nt"&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;h1&amp;gt;&lt;/span&gt;Understanding Unikernels!&lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once &lt;code&gt;server.go&lt;/code&gt; and &lt;code&gt;index.html&lt;/code&gt; are created, we can build our code to create the &lt;code&gt;server&lt;/code&gt; executable.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;GOOS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;linux go build server.go
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The last thing that needs to be done before we're ready to create our unikernel is the configuration file for &lt;code&gt;ops&lt;/code&gt;. This file is going to contain the s3 bucket-name that was previously created(&lt;code&gt;s3://understanding-unikernels&lt;/code&gt;), and the aws-region to create resources.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;config.json&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"Dirs"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"static"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"CloudConfig"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;:{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"ProjectID"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"test-project"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"Zone"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"&amp;lt;region&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"BucketName"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"&amp;lt;bucket-name&amp;gt;"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"RebootOnExit"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After running all the steps mentioned above, directory structure should be similar to the one below:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;directory structure&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;understanding-unikernels/
├── config.json
├── server
├── server.go
└── static
    └── index.html
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By leveraging &lt;code&gt;ops&lt;/code&gt;, we can now create and list out the unikernel machine-image(s) on our AWS account.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ops image create &lt;span class="nt"&gt;-t&lt;/span&gt; aws &lt;span class="nt"&gt;-c&lt;/span&gt; config.json &lt;span class="nt"&gt;-a&lt;/span&gt; server

ops image list &lt;span class="nt"&gt;-t&lt;/span&gt; aws &lt;span class="nt"&gt;-z&lt;/span&gt; &amp;lt;region&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fl683dyc5qocmftw1cww3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fl683dyc5qocmftw1cww3.png" alt="Create Snapshot Image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Create Instance
&lt;/h3&gt;

&lt;p&gt;Once the unikernel has been imported onto AWS as an AMI, we can proceed to launch it as an EC2 instance with ops. Since the static file-server is configured to run on port 8080, we'll need to mention that along with the AWS region as part of the ops command to run the instance.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ops instance create &lt;span class="nt"&gt;-c&lt;/span&gt; config.json &lt;span class="nt"&gt;-t&lt;/span&gt; aws &lt;span class="nt"&gt;-z&lt;/span&gt; &amp;lt;region&amp;gt; &lt;span class="nt"&gt;-i&lt;/span&gt; server-image &lt;span class="nt"&gt;--port&lt;/span&gt; 8080
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F9k0pm6j5glame7ryal5e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F9k0pm6j5glame7ryal5e.png" alt="Create Instance"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;One thing I observed was that ops defaults to the Instance type &lt;code&gt;t2.micro&lt;/code&gt; which uses the &lt;code&gt;xen&lt;/code&gt; hypervisor. The &lt;code&gt;--flavor&lt;/code&gt; flag in ops can be used to change the Instance type. Additionally, &lt;a href="https://github.com/nanovms/nanos/pull/1365" rel="noopener noreferrer"&gt;support for AWS Nitro instances&lt;/a&gt; has been added as well, but the AMI needs ENA(Elastic Network Adapter) enabled to work with Nitro instances which can be checked by running the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;aws ec2 describe-images &lt;span class="nt"&gt;--image-id&lt;/span&gt; &amp;lt;ami-id&amp;gt; &lt;span class="nt"&gt;--query&lt;/span&gt; &lt;span class="s2"&gt;"Images[].EnaSupport"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Delete Instance
&lt;/h3&gt;

&lt;p&gt;The final step is to delete the EC2 instance, and the AMI that was created. Doing this with ops is extremely simple.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ops instance delete &lt;span class="nt"&gt;-t&lt;/span&gt; aws &lt;span class="nt"&gt;-z&lt;/span&gt; &amp;lt;region&amp;gt; &amp;lt;instance-id&amp;gt;

ops instance list &lt;span class="nt"&gt;-t&lt;/span&gt; aws &lt;span class="nt"&gt;-z&lt;/span&gt; &amp;lt;region&amp;gt;

ops image delete &amp;lt;ami-name&amp;gt; &lt;span class="nt"&gt;-t&lt;/span&gt; aws &lt;span class="nt"&gt;-z&lt;/span&gt; &amp;lt;region&amp;gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fm4vzkp6gey2q7bjo4ucy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fm4vzkp6gey2q7bjo4ucy.png" alt="Delete Instance"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Security Considerations
&lt;/h2&gt;

&lt;p&gt;One major security issue is the fact that unikernels run the application, and the kernel together as a single process allowing applications(or attackers) to potentially call kernel-level functions. Supply chain attacks, which are a very likely threat can make this a reality.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Nanos however manages to retain different privileges for kernel and user code by having separate partitions thereby preventing such attacks to a certain extent. Additionally, arbitrary code execution can be prevented by leveraging the &lt;code&gt;exec_protection&lt;/code&gt; flag that &lt;a href="https://github.com/nanovms/nanos/pull/1251" rel="noopener noreferrer"&gt;prevents the kernel from executing any code outside the main program executable.&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Interesting Projects
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;If you are working on a cool unikernel project that's not mentioned below, please reach out to me. I'd love to give it a shot and add it to the list!&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://torokernel.io/" rel="noopener noreferrer"&gt;ToroKernel&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://nanos.org/" rel="noopener noreferrer"&gt;Nanos&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://mirage.io/" rel="noopener noreferrer"&gt;MirageOS&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.includeos.org/" rel="noopener noreferrer"&gt;IncludeOS&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://osv.io/" rel="noopener noreferrer"&gt;OSv&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://grapheneproject.io/" rel="noopener noreferrer"&gt;Graphene&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://wiki.xenproject.org/wiki/Mini-OS" rel="noopener noreferrer"&gt;MiniOS&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;For those of you interested in going further down this rabbit hole, here are a few links that will help:&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=8UgiPODw3CY" rel="noopener noreferrer"&gt;The Next Generation Cloud: Unleashing the Power of the Unikernel - Russell Pavlicek&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://cnp.neclab.eu/projects/lightvm/lightvm.pdf" rel="noopener noreferrer"&gt;My VM is Lighter (and Safer) than your Container&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://hackernoon.com/hacking-unikernels-through-process-injection-a-step-by-step-guide-oobk323f" rel="noopener noreferrer"&gt;Hacking Unikernels Through Process Injection - Ian Eyberg&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=cUvNths_5RA" rel="noopener noreferrer"&gt;Rainbows and Unikernels - Garrett Smith&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.nccgroup.trust/globalassets/our-research/us/whitepapers/2019/ncc_group-assessing_unikernel_security.pdf" rel="noopener noreferrer"&gt;Assessing Unikernel Security - NCC Group Whitepaper&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://arxiv.org/abs/1911.06260" rel="noopener noreferrer"&gt;A Security Perspective on Unikernels&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=0v21hGvCDPY" rel="noopener noreferrer"&gt;From the Ground Up: How We Built the Nanos Unikernel - Will Jhun, NanoVMs, Inc.&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;Originally published at &lt;a href="https://nithinjois.substack.com" rel="noopener noreferrer"&gt;https://nithinjois.substack.com&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>security</category>
      <category>cloud</category>
      <category>cybersecurity</category>
      <category>unikernels</category>
    </item>
  </channel>
</rss>
