{"id":582,"date":"2018-10-17T21:10:25","date_gmt":"2018-10-17T21:10:25","guid":{"rendered":"https:\/\/www.appservgrid.com\/paw93\/?p=582"},"modified":"2018-10-18T13:47:18","modified_gmt":"2018-10-18T13:47:18","slug":"getting-acquainted-with-gvisor-rancher-labs","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw93\/index.php\/2018\/10\/17\/getting-acquainted-with-gvisor-rancher-labs\/","title":{"rendered":"Getting Acquainted with gVisor | Rancher Labs"},"content":{"rendered":"<p>Like many of us in the Kubernetes space, I\u2019m excited to check out the<br \/>\nshiny new thing. To be fair, we\u2019re all working with an amazing product<br \/>\nthat is younger than my pre-school aged daughter. The shiny new thing at<br \/>\nKubeCon Europe was a new container runtime authored by Google named<br \/>\ngVisor. Like a cat to catnip, I had to check this out and share it with<br \/>\nyou.<\/p>\n<h2>What is gVisor?<\/h2>\n<p>gVisor is a sandboxed container runtime, that acts as a user-space<br \/>\nkernel. During KubeCon Google announced that they open-sourced it to the<br \/>\ncommunity. Its goal is to use paravirtualization to isolate<br \/>\ncontainerized applications from the host system, without the heavy<br \/>\nweight resource allocation that comes with virtual machines.<\/p>\n<h2>Do I Need gVisor?<\/h2>\n<p>No. If you\u2019re running production workloads, don\u2019t even think about it!<br \/>\nRight now, this is a metaphorical science experiment. That\u2019s not to say<br \/>\nyou may not want to use it as it matures. I don\u2019t have any problem with<br \/>\nthe way it\u2019s trying to solve process isolation and I think it\u2019s a good<br \/>\nidea. There are also alternatives you should take the time to explore<br \/>\nbefore adopting this technology in the future.<\/p>\n<p>That being said, if you want to learn more about it, when you\u2019ll want to<br \/>\nuse it, and the problems it seeks to solve, keep reading.<\/p>\n<h2>Where might I want to use it?<\/h2>\n<p>As an operator, you\u2019ll want to use gVisor to isolate application<br \/>\ncontainers that aren\u2019t entirely trusted. This could be a new version of<br \/>\nan open source project your organization has trusted in the past. It<br \/>\ncould be a new project your team has yet to completely vet or anything<br \/>\nelse you aren\u2019t entirely sure can be trusted in your cluster. After all,<br \/>\nif you\u2019re running an open source project you didn\u2019t write (all of us),<br \/>\nyour team certainly didn\u2019t write it so it would be good security and<br \/>\ngood engineering to properly isolate and protect your environment in<br \/>\ncase there may be a yet unknown vulnerability.<\/p>\n<h2>What is Sandboxing<\/h2>\n<p>Sandboxing is a software management strategy that enforces isolation<br \/>\nbetween software running on a machine, the host operating system, and<br \/>\nother software also running on the machine. The purpose is to constrain<br \/>\napplications to specific parts of the host\u2019s memory and file-system and<br \/>\nnot allow it to breakout and affect other parts of the operating system.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/rancher.com\/img\/blog\/2018\/what-is-gvisor-1.png\" \/><\/p>\n<h4>Source: https:\/\/cloudplatform.googleblog.com\/2018\/05\/Open-sourcing-gVisor-a-sandboxed-container-runtime.html, pulled 17 May 2018<\/h4>\n<h2>Current Sandboxing Methods<\/h2>\n<p>The virtual machine (VM) is a great way to isolate applications from the<br \/>\nunderlying hardware. An entire hardware stack is virtualized to protect<br \/>\napplications and the host kernel from malicious applications.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/rancher.com\/img\/blog\/2018\/what-is-gvisor-2.png\" \/><\/p>\n<h4>Source: https:\/\/cloudplatform.googleblog.com\/2018\/05\/Open-sourcing-gVisor-a-sandboxed-container-runtime.html, pulled 17 May 2018<\/h4>\n<p>As stated before, the problem is that VMs are heavy. The require set<br \/>\namounts of memory and disk space. If you\u2019ve worked in enterprise IT, I\u2019m<br \/>\nsure you\u2019ve noticed the resource waste.<\/p>\n<p>Some projects are looking to solve this with lightweight OCI-compliant<br \/>\nVM implementations. Projects like Kata containers are bringing this to<br \/>\nthe container space on top of runV, a hypervisor based runtime.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/rancher.com\/img\/blog\/2018\/what-is-gvisor-3.png\" \/><\/p>\n<h4>Source: https:\/\/katacontainers.io\/, pulled 17 May 2018<\/h4>\n<p>Microsoft is using a similar technique to isolate workloads using a<br \/>\nvery-lightweight Hyper-V virtual machine when using Windows Server<br \/>\nContainers with Hyper-V isolation.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/rancher.com\/img\/blog\/2018\/what-is-gvisor-4.png\" \/><\/p>\n<h4>Source: partial screenshot, https:\/\/channel9.msdn.com\/Blogs\/containers\/DockerCon-16-Windows-Server-Docker-The-Internals-Behind-Bringing-Docker-Containers-to-Windows, timestamp 31:02 pulled 17 May 2018<\/h4>\n<p>This feels like a best-of-both worlds approach to isolation. Time will<br \/>\ntell. Most of the market is still running docker engine under the<br \/>\ncovers. I don\u2019t see this changing any time soon. Open containers and<br \/>\ncontainer runtimes certainly will begin taking over a share of the<br \/>\nmarket. As that happens, adopting multiple container runtimes will be an<br \/>\noption for the enterprise.<\/p>\n<h2>Sandboxing with gVisor<\/h2>\n<p>gVisor intends to solve this problem. It acts as a kernel in between the<br \/>\ncontainerized application and the host kernel. It does this through<br \/>\nvarious mechanisms to support syscall limits, file system proxying, and<br \/>\nnetwork access. These mechanisms are a paravirtualization providing a<br \/>\nvirtual-machine like level of isolation, without the fixed resource cost<br \/>\nof each virtual machine.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/rancher.com\/img\/blog\/2018\/what-is-gvisor-5.png\" \/><\/p>\n<h4>Source: partial screenshot, https:\/\/channel9.msdn.com\/Blogs\/containers\/DockerCon-16-Windows-Server-Docker-The-Internals-Behind-Bringing-Docker-Containers-to-Windows, timestamp 31:02 pulled 17 May 2018<\/h4>\n<h2>runsc<\/h2>\n<p>gVisor the runtime is a binary named runsc (run sandboxed container) and<br \/>\nis an alternative to runc or runv if you\u2019ve worked with kata containers<br \/>\nin the past.<\/p>\n<h2>Other Alternatives to gVisor<\/h2>\n<p>gVisor isn\u2019t the only way to isolate your workloads and protect your<br \/>\ninfrastructure. Technologies like SELinux, seccomp and Apparmor solve a<br \/>\nlot of these problems (as well as others). It would behoove you as an<br \/>\noperator and an engineer to get well acquainted with these technologies.<br \/>\nIt\u2019s a lot to learn. I\u2019m certainly no expert, although I aspire to be.<br \/>\nDon\u2019t be a lazy engineer. Learn your tools, learn your OS, do right by<br \/>\nyour employer and your users. If you want to know more go read the man<br \/>\npages and follow <a href=\"https:\/\/blog.jessfraz.com\/post\/containers-security-and-echo-chambers\/\">Jessie<br \/>\nFrazelle<\/a>.<br \/>\nShe is an expert in this area of computing and has written a treasure<br \/>\ntrove on it.<\/p>\n<h2>Using gVisor with Docker<\/h2>\n<p>As docker supports multiple runtimes, it will work with runsc. To use it<br \/>\none must build and install the runsc container runtime binary and<br \/>\nconfigured docker\u2019s \/etc\/docker\/daemon.json file to support the gVisor<br \/>\nruntime. From there a user may run a container with the runsc runtime by<br \/>\nutilizing the \u2013runtime flag of the docker run command.<\/p>\n<p>docker run \u2013runtime=runsc hello-world<\/p>\n<h2>Using gVisor with Kubernetes<\/h2>\n<p>Kubernetes support for gVisor is experimental and implemented via the<br \/>\nCRI-O CRI implementation. CRI-O is an implementation of the Kubernetes<br \/>\nContainer Runtime Interface. Its goal is to allow Kubernetes to use any<br \/>\nOCI compliant container runtime (such as runc and runsc). To use this<br \/>\none must install runsc on the Kubernetes , then configure cri-o to use<br \/>\nrunsc to run untrusted workloads in cri-o\u2019s \/etc\/crio\/crio.conf file.<br \/>\nOnce configured, any pod without the io.kubernetes.cri-o.TrustedSandbox<br \/>\nannotation (or the annotation set to false), will be run with runsc.<br \/>\nThis would be as an alternative to using the Docker engine powering the<br \/>\ncontainers inside Kubernetes pods.<\/p>\n<h2>Will my application work with gVisor<\/h2>\n<p>It depends. Currently gVisor only supports single-container pods. Here<br \/>\nis a list of known working applications that have been tested with<br \/>\ngVisor.<\/p>\n<p>Ultimately support for any given application will depend on whether the<br \/>\nsyscalls used by the application are supported.<\/p>\n<h2>How does it affect performance?<\/h2>\n<p>Again, this depends. gVisor\u2019s \u201cSentry\u201d process is responsible for<br \/>\nlimting syscalls and requires a platform to implement context switching<br \/>\nand memory mapping. Currently gVisor supports Ptrace and KVM, which<br \/>\nimplement these functions differently, are configured differently, and<br \/>\nsupport different node configurations to operate effectively. Either<br \/>\nwould affect performance differently than the other.<\/p>\n<p>The architecture of gVisor suggests it would be able to enable greater<br \/>\napplication density over VMM based configurations but may suffer higher<br \/>\nperformance penalties in sycall-rich applications.<\/p>\n<h3>Networking<\/h3>\n<p>A quick note about network access and performance. Network access is<br \/>\nachieved via an L3 userland networking stack subproject called netstack.<br \/>\nThis functionality can be bypassed in favor of the host network to<br \/>\nincrease performance.<\/p>\n<h2>Can I use gVisor with Rancher?<\/h2>\n<p>Rancher currently cannot be used to provision CRI-O backed Kubernetes<br \/>\nclusters as it relies heavily on the docker engine. However, you<br \/>\ncertainly manage CRI-O backed clusters with Rancher. Rancher will manage<br \/>\nany Kubernetes server as we leverage the Kubernetes API and our<br \/>\ncomponents are Kubernetes Custom Resources.<\/p>\n<p>We\u2019ll continue to monitor gVisor as it matures. As such, we\u2019ll add more<br \/>\nsupport for gVisor with Rancher as need arises. Like the evolution of<br \/>\nWindows Server Containers in Kubernetes, soon this project will become<br \/>\npart of the fabric of Kubernetes in the Enterprise.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/rancher.com\/img\/bio\/jason-van-brackel.jpg\" alt=\"Jason Van Brackel\" width=\"100\" height=\"100\" \/><\/p>\n<p>Jason Van Brackel<\/p>\n<p>Senior Solutions Architect<\/p>\n<p>Jason van Brackel is a Senior Solutions Architect for Rancher. He is also the organizer of the Kubernetes Philly Meetup and loves teaching at code camps, user groups and other meetups. Having worked professionally with everything from COBOL to Go, Jason loves learning, and solving challenging problems.<\/p>\n<p><a href=\"https:\/\/rancher.com\/blog\/2018\/2018-05-24-what-is-gvisor\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Like many of us in the Kubernetes space, I\u2019m excited to check out the shiny new thing. To be fair, we\u2019re all working with an amazing product that is younger than my pre-school aged daughter. The shiny new thing at KubeCon Europe was a new container runtime authored by Google named gVisor. Like a cat &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw93\/index.php\/2018\/10\/17\/getting-acquainted-with-gvisor-rancher-labs\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Getting Acquainted with gVisor | Rancher Labs&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-582","post","type-post","status-publish","format-standard","hentry","category-kubernetes"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/posts\/582","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/comments?post=582"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/posts\/582\/revisions"}],"predecessor-version":[{"id":602,"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/posts\/582\/revisions\/602"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/media?parent=582"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/categories?post=582"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/tags?post=582"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}