<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Kata-Containers on sysarcher/@ich_code</title><link>https://sysarcher.github.io/categories/kata-containers/</link><description>Recent content in Kata-Containers on sysarcher/@ich_code</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Tue, 11 Jun 2019 21:22:37 +0200</lastBuildDate><atom:link href="https://sysarcher.github.io/categories/kata-containers/index.xml" rel="self" type="application/rss+xml"/><item><title>Kata annotations</title><link>https://sysarcher.github.io/posts/kata-annotations/</link><pubDate>Tue, 11 Jun 2019 21:22:37 +0200</pubDate><guid>https://sysarcher.github.io/posts/kata-annotations/</guid><description>&lt;p&gt;&lt;em&gt;Annotations are a great feature in Kubernetes and a means for communicating to kata some options. &lt;a href="https://github.com/kata-containers/documentation/issues/486"&gt;They are being documented as of the time of this writing&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Using annotations, you can:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Customize the Kernel that is used (see &lt;code&gt;KernelPath&lt;/code&gt; example below)&lt;/li&gt;
&lt;li&gt;Change the guest image (&lt;code&gt;ImagePath&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Hypervisor (&lt;code&gt;HypervisorPath&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Firmware (&lt;code&gt;FirmwarePath&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;etc. etc. (All of the annotations are listed in &lt;a href="https://github.com/kata-containers/runtime/blob/master/virtcontainers/pkg/annotations/annotations.go"&gt;&lt;code&gt;annotations.go&lt;/code&gt;&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="using-a-custom-kernel"&gt;Using a Custom Kernel&lt;/h3&gt;
&lt;p&gt;Here is the &lt;code&gt;yaml&lt;/code&gt; file I used to apply a custom kernel:&lt;/p&gt;</description><content:encoded><![CDATA[<p><em>Annotations are a great feature in Kubernetes and a means for communicating to kata some options. <a href="https://github.com/kata-containers/documentation/issues/486">They are being documented as of the time of this writing</a></em></p>
<p>Using annotations, you can:</p>
<ul>
<li>Customize the Kernel that is used (see <code>KernelPath</code> example below)</li>
<li>Change the guest image (<code>ImagePath</code>)</li>
<li>Hypervisor (<code>HypervisorPath</code>)</li>
<li>Firmware (<code>FirmwarePath</code>)</li>
<li>etc. etc. (All of the annotations are listed in <a href="https://github.com/kata-containers/runtime/blob/master/virtcontainers/pkg/annotations/annotations.go"><code>annotations.go</code></a>)</li>
</ul>
<h3 id="using-a-custom-kernel">Using a Custom Kernel</h3>
<p>Here is the <code>yaml</code> file I used to apply a custom kernel:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-yaml" data-lang="yaml"><span style="display:flex;"><span><span style="color:#f92672">apiVersion</span>: <span style="color:#ae81ff">v1</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">kind</span>: <span style="color:#ae81ff">Pod</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">metadata</span>:
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">annotations</span>:
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">com.github.containers.virtcontainers.KernelPath</span>: <span style="color:#e6db74">&#34;/usr/share/kata-containers/vmlinuz-4.19.31-40&#34;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">name</span>: <span style="color:#ae81ff">kata-example</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">spec</span>:
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">runtimeClassName</span>: <span style="color:#ae81ff">kata-qemu</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">containers</span>:
</span></span><span style="display:flex;"><span>  - <span style="color:#f92672">name</span>: <span style="color:#ae81ff">nginx-container</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">image</span>: <span style="color:#ae81ff">nginx</span>
</span></span></code></pre></div><p>The <code>metadata</code> key contains the <code>annotations</code> map. All of the annotations are listed in <a href="https://github.com/kata-containers/runtime/blob/master/virtcontainers/pkg/annotations/annotations.go"><code>annotations.go</code></a> on the main repo.</p>
]]></content:encoded></item><item><title>Kata and Kubernetes</title><link>https://sysarcher.github.io/posts/kata-k8s/</link><pubDate>Sun, 19 May 2019 21:22:37 +0200</pubDate><guid>https://sysarcher.github.io/posts/kata-k8s/</guid><description>&lt;h3 id="setting-up-kata-using-docker"&gt;Setting up Kata using Docker&lt;/h3&gt;
&lt;p&gt;This is documented here: &lt;a href="https://github.com/kata-containers/packaging/blob/master/kata-deploy/README.md#docker-quick-start"&gt;https://github.com/kata-containers/packaging/blob/master/kata-deploy/README.md#docker-quick-start&lt;/a&gt;&lt;/p&gt;
&lt;h3 id="using-minikube-and-kata"&gt;Using Minikube and Kata&lt;/h3&gt;
&lt;p&gt;&lt;a href="https://github.com/kata-containers/documentation/pull/445#"&gt;This PR&lt;/a&gt; is adding the documentation to get started with &lt;code&gt;minikube&lt;/code&gt;: &lt;a href="https://github.com/kata-containers/documentation/pull/445#"&gt;https://github.com/kata-containers/documentation/pull/445#&lt;/a&gt;&lt;/p&gt;
&lt;h3 id="using-kubeadm"&gt;Using &lt;code&gt;kubeadm&lt;/code&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;First, set up a Kubernetes cluster using &lt;code&gt;kubeadm&lt;/code&gt;: &lt;a href="https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/create-cluster-kubeadm/"&gt;https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/create-cluster-kubeadm/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;then, &lt;a href="https://github.com/kata-containers/packaging/blob/master/kata-deploy/README.md#kubernetes-quick-start"&gt;https://github.com/kata-containers/packaging/blob/master/kata-deploy/README.md#kubernetes-quick-start&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="conclusion"&gt;Conclusion&lt;/h3&gt;
&lt;p&gt;Using the new &lt;code&gt;kata-deploy&lt;/code&gt; method, it is very easy to set up a Kubernetes cluster that uses Kata Containers.&lt;/p&gt;</description><content:encoded><![CDATA[<h3 id="setting-up-kata-using-docker">Setting up Kata using Docker</h3>
<p>This is documented here: <a href="https://github.com/kata-containers/packaging/blob/master/kata-deploy/README.md#docker-quick-start">https://github.com/kata-containers/packaging/blob/master/kata-deploy/README.md#docker-quick-start</a></p>
<h3 id="using-minikube-and-kata">Using Minikube and Kata</h3>
<p><a href="https://github.com/kata-containers/documentation/pull/445#">This PR</a> is adding the documentation to get started with <code>minikube</code>: <a href="https://github.com/kata-containers/documentation/pull/445#">https://github.com/kata-containers/documentation/pull/445#</a></p>
<h3 id="using-kubeadm">Using <code>kubeadm</code></h3>
<ul>
<li>First, set up a Kubernetes cluster using <code>kubeadm</code>: <a href="https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/create-cluster-kubeadm/">https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/create-cluster-kubeadm/</a></li>
<li>then, <a href="https://github.com/kata-containers/packaging/blob/master/kata-deploy/README.md#kubernetes-quick-start">https://github.com/kata-containers/packaging/blob/master/kata-deploy/README.md#kubernetes-quick-start</a></li>
</ul>
<h3 id="conclusion">Conclusion</h3>
<p>Using the new <code>kata-deploy</code> method, it is very easy to set up a Kubernetes cluster that uses Kata Containers.</p>
]]></content:encoded></item><item><title>Taking Kata Steps</title><link>https://sysarcher.github.io/posts/kata-steps/</link><pubDate>Sun, 28 Apr 2019 21:22:37 +0200</pubDate><guid>https://sysarcher.github.io/posts/kata-steps/</guid><description>&lt;p&gt;So I thought that it might be a great idea to run an RT kernel inside Kata containers. This is a usecase because I soon hope to see Kata containers running on real-time capable hypervisors and also being used in scenarios where real-time is a thing. Soon!&lt;/p&gt;
&lt;p&gt;For now, let&amp;rsquo;s look at how I went about doing what I did..&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;You need to &lt;code&gt;go get github.com/kata-containers/packaging&lt;/code&gt; repository. (or, git clone if you so prefer.) Be sure to have your &lt;code&gt;$GOPATH&lt;/code&gt; properly set!!&lt;/li&gt;
&lt;li&gt;cd into &lt;code&gt;packaging/kernel&lt;/code&gt; directory.&lt;/li&gt;
&lt;li&gt;I chose the &lt;code&gt;4.19.31&lt;/code&gt; version of the kernel. Primarily because it was a newer kernel (not too different from the kernel version that comes with the current kata release.) and because it had the &lt;a href="https://cdn.kernel.org/pub/linux/kernel/projects/rt/4.19/patch-4.19.31-rt18.patch.xz"&gt;RT patches available&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;I changed &lt;a href="https://github.com/kata-containers/packaging/blob/dce0558ec6d8329e81fa59c809351170f6741a7a/kernel/build-kernel.sh#L25"&gt;the &lt;code&gt;kernel_version=&amp;quot;&amp;quot;&lt;/code&gt; line&lt;/a&gt; to &lt;code&gt;kernel_version=&amp;quot;4.19.31&amp;quot;&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;That&amp;rsquo;s it. We are ready to (1) apply the necessary patches from Kata maintainers to our Kernel of choosing and (2) apply the RT patches:&lt;/p&gt;</description><content:encoded><![CDATA[<p>So I thought that it might be a great idea to run an RT kernel inside Kata containers. This is a usecase because I soon hope to see Kata containers running on real-time capable hypervisors and also being used in scenarios where real-time is a thing. Soon!</p>
<p>For now, let&rsquo;s look at how I went about doing what I did..</p>
<ol>
<li>You need to <code>go get github.com/kata-containers/packaging</code> repository. (or, git clone if you so prefer.) Be sure to have your <code>$GOPATH</code> properly set!!</li>
<li>cd into <code>packaging/kernel</code> directory.</li>
<li>I chose the <code>4.19.31</code> version of the kernel. Primarily because it was a newer kernel (not too different from the kernel version that comes with the current kata release.) and because it had the <a href="https://cdn.kernel.org/pub/linux/kernel/projects/rt/4.19/patch-4.19.31-rt18.patch.xz">RT patches available</a></li>
<li>I changed <a href="https://github.com/kata-containers/packaging/blob/dce0558ec6d8329e81fa59c809351170f6741a7a/kernel/build-kernel.sh#L25">the <code>kernel_version=&quot;&quot;</code> line</a> to <code>kernel_version=&quot;4.19.31&quot;</code></li>
</ol>
<p>That&rsquo;s it. We are ready to (1) apply the necessary patches from Kata maintainers to our Kernel of choosing and (2) apply the RT patches:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span><span style="color:#75715e"># download and apply the kata patches to the kernel</span>
</span></span><span style="display:flex;"><span>./build-kernel.sh setup
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>cd kata-linux-4.19.31-36
</span></span><span style="display:flex;"><span>patch -p1&lt;../path-to-extracted-patch/patch-4.19.31-rt18.patch
</span></span></code></pre></div><p>Wait&hellip; we need to first, <code>make menuconfig</code> and enable <code>RT</code> capabilities</p>
<pre tabindex="0"><code>General Setup 
  --&gt; Preemption Model
    --&gt; Fully Preemptible Kernel (RT)
</code></pre><p>Now, we&rsquo;re ready to build the Kernel and install it*:</p>
<pre tabindex="0"><code>./build-kernel.sh setup
sudo ./build-kernel.sh install
</code></pre><h3 id="drum-roll-please">Drum Roll please</h3>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-console" data-lang="console"><span style="display:flex;"><span>$ docker run -it --runtime kata-runtime ubuntu bash
</span></span><span style="display:flex;"><span>root@77cf04fd8290:/# uname -r
</span></span><span style="display:flex;"><span>4.19.31-rt18
</span></span><span style="display:flex;"><span>root@77cf04fd8290:/# uname -a
</span></span><span style="display:flex;"><span>Linux 77cf04fd8290 4.19.31-rt18 #2 SMP PREEMPT RT Mon Apr 29 09:06:08 CEST 2019 x86_64 x86_64 x86_64 GNU/Linux
</span></span><span style="display:flex;"><span>root@77cf04fd8290:/# 
</span></span></code></pre></div><p>So proud!!!</p>
<p>Happy Building!!</p>
<h3 id="note-on-kernel-files">Note on Kernel Files</h3>
<p><code>vmlinux</code>: uncompressed kernel. |
<code>vmlinuz</code>: compressed kernel. |
<code>bzImage</code>: located under <code>arch/x86_64/boot/bzImage</code>. Big Zimage. Compressed kernel image.</p>
<p>More info: <a href="https://stackoverflow.com/a/22338835/3760442">https://stackoverflow.com/a/22338835/3760442</a></p>
<h3 id="acknowledgements">Acknowledgements</h3>
<p>Special thanks to @egernst, @rico and the great team on Slack!! Though this was my first foray into Kata Containers, I must say the folks were very welcoming. Thank you all!!</p>
<p><em>* I built the kernel (as of the time of writing) using <code>make build -j4</code> instead of using the <code>build-kernel.sh</code> script but it shouldn&rsquo;t matter. Just FYI.</em></p>
]]></content:encoded></item></channel></rss>