<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Charms on Jon Seager</title><link>https://jnsgr.uk/tags/charms/</link><description>Recent content in Charms on Jon Seager</description><generator>Hugo -- gohugo.io</generator><language>en</language><lastBuildDate>Sat, 10 Feb 2024 00:00:00 +0000</lastBuildDate><atom:link href="https://jnsgr.uk/tags/charms/index.xml" rel="self" type="application/rss+xml"/><item><title>Integration testing with NixOS in Github Actions</title><link>https://jnsgr.uk/2024/02/nixos-vms-in-github-actions/</link><pubDate>Sat, 10 Feb 2024 00:00:00 +0000</pubDate><guid>https://jnsgr.uk/2024/02/nixos-vms-in-github-actions/</guid><description>&lt;h2 id="introduction" class="relative group"&gt;Introduction &lt;span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100"&gt;&lt;a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700" style="text-decoration-line: none !important;" href="#introduction" aria-label="Anchor"&gt;#&lt;/a&gt;&lt;/span&gt;&lt;/h2&gt;&lt;p&gt;While in my own time I&amp;rsquo;ve tended toward NixOS over the past 18 months, in my day-to-day work for &lt;a href="https://canonical.com" target="_blank" rel="noreferrer"&gt;Canonical&lt;/a&gt; I&amp;rsquo;m required to interact with a fair few of our products - and particularly build tools.&lt;/p&gt;
&lt;p&gt;I frequently need to use some combination of &lt;a href="https://snapcraft.io/docs" target="_blank" rel="noreferrer"&gt;Snaps&lt;/a&gt;, &lt;a href="https://juju.is/docs/juju/charmed-operator" target="_blank" rel="noreferrer"&gt;Charms&lt;/a&gt; and &lt;a href="https://ubuntu.com/server/docs/rock-images/introduction" target="_blank" rel="noreferrer"&gt;Rocks&lt;/a&gt;. Each of these have their own &amp;ldquo;craft&amp;rdquo; build tools (&lt;a href="https://github.com/snapcore/snapcraft" target="_blank" rel="noreferrer"&gt;&lt;code&gt;snapcraft&lt;/code&gt;&lt;/a&gt;, &lt;a href="https://github.com/canonical/charmcraft" target="_blank" rel="noreferrer"&gt;&lt;code&gt;charmcraft&lt;/code&gt;&lt;/a&gt; and &lt;a href="https://github.com/canonical/rockcraft" target="_blank" rel="noreferrer"&gt;&lt;code&gt;rockcraft&lt;/code&gt;&lt;/a&gt;), which are distributed exclusively as Snap packages and thus a little tricky to consume from NixOS.&lt;/p&gt;
&lt;h2 id="the-problem" class="relative group"&gt;The Problem &lt;span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100"&gt;&lt;a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700" style="text-decoration-line: none !important;" href="#the-problem" aria-label="Anchor"&gt;#&lt;/a&gt;&lt;/span&gt;&lt;/h2&gt;&lt;p&gt;Packaging the tools for Nix was a little repetitive, but not particularly difficult. They&amp;rsquo;re all built with Python, and share a common set of libraries. Testing that the packages were working correctly (i.e. could actually build software) &lt;em&gt;on NixOS&lt;/em&gt; using the &lt;em&gt;NixOS version of LXD&lt;/em&gt; in Github Actions proved more difficult.&lt;/p&gt;
&lt;p&gt;Github Actions defaults to Ubuntu as the operating system for its runners - an entirely sensible choice, but not one that was going to help me test packages could work together on NixOS.&lt;/p&gt;
&lt;p&gt;I could have hosted my own Github Actions runners to solve the problem, but I didn&amp;rsquo;t want to maintain such a deployment.&lt;/p&gt;
&lt;p&gt;For a while I relied on just testing each of the crafts locally before pushing, and the CI simply installed the Nix package manager on the runners (using the &lt;em&gt;excellent&lt;/em&gt; &lt;a href="https://github.com/DeterminateSystems/nix-installer" target="_blank" rel="noreferrer"&gt;Nix installer from Determinate Systems&lt;/a&gt;) and ensured that the build could succeed, but this left a lot to be desired - particularly when I accidentally (and somewhat inevitably) broke one of the packages.&lt;/p&gt;
&lt;h2 id="kvm-for-github-actions" class="relative group"&gt;KVM for Github Actions &lt;span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100"&gt;&lt;a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700" style="text-decoration-line: none !important;" href="#kvm-for-github-actions" aria-label="Anchor"&gt;#&lt;/a&gt;&lt;/span&gt;&lt;/h2&gt;&lt;p&gt;Some time later I came across &lt;a href="https://github.blog/changelog/2023-02-23-hardware-accelerated-android-virtualization-on-actions-windows-and-linux-larger-hosted-runners/" target="_blank" rel="noreferrer"&gt;this post&lt;/a&gt; on the Github Blog, stating the following:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Starting on February 23, 2023, Actions users [&amp;hellip;] will be able to make use of hardware acceleration [&amp;hellip;].&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;What follows is an example of a relatively simple addition to a Github Workflow to enable KVM on Github Actions runners:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;
&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1
&lt;/span&gt;&lt;span class="lnt"&gt;2
&lt;/span&gt;&lt;span class="lnt"&gt;3
&lt;/span&gt;&lt;span class="lnt"&gt;4
&lt;/span&gt;&lt;span class="lnt"&gt;5
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-yaml" data-lang="yaml"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;- &lt;span class="nt"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l"&gt;Enable KVM group perms&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;run&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="sd"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="sd"&gt; echo &amp;#39;KERNEL==&amp;#34;kvm&amp;#34;, GROUP=&amp;#34;kvm&amp;#34;, MODE=&amp;#34;0666&amp;#34;, OPTIONS+=&amp;#34;static_node=kvm&amp;#34;&amp;#39; | sudo tee /etc/udev/rules.d/99-kvm4all.rules
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="sd"&gt; sudo udevadm control --reload-rules
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="sd"&gt; sudo udevadm trigger --name-match=kvm&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;Given the ability to relatively easily create NixOS VMs from a machine configuration, this should enable me to run a NixOS VM inside my Github Actions runners, and use that VM to run end to end tests of my craft packages.&lt;/p&gt;
&lt;p&gt;After some quick tests, I confirmed that the above snippet worked just fine on the freely available runners that are assigned to public projects. After &lt;a href="https://hachyderm.io/@jnsgruk/111449289662026017" target="_blank" rel="noreferrer"&gt;tooting excitedly&lt;/a&gt; about this, it was also picked up by the folks at Determinate Systems who &lt;a href="https://octodon.social/@grahamc/111450168028125913" target="_blank" rel="noreferrer"&gt;promptly added support&lt;/a&gt; for this in their Nix install Github Action - enabling the feature by default.&lt;/p&gt;
&lt;h2 id="building-vms-with-nix" class="relative group"&gt;Building VMs with Nix &lt;span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100"&gt;&lt;a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700" style="text-decoration-line: none !important;" href="#building-vms-with-nix" aria-label="Anchor"&gt;#&lt;/a&gt;&lt;/span&gt;&lt;/h2&gt;&lt;p&gt;A really nice feature of NixOS that I discovered relatively late, is that given a NixOS machine configuration &lt;a href="https://gist.github.com/FlakM/0535b8aa7efec56906c5ab5e32580adf" target="_blank" rel="noreferrer"&gt;it&amp;rsquo;s trivial to build a virtual machine&lt;/a&gt; image for that configuration. This has the nice property that one can actually boot a VM-equivalent of any previously defined machines. You could, for example, boot a VM-equivalent of my laptop with the following command:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;
&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;nix run github:jnsgruk/nixos-config#nixosConfigurations.freyja.config.system.build.vm
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;In order to test my craft tools, I needed a relatively simple NixOS VM that had LXD enabled, and my craft tools installed. My test VM &lt;a href="https://github.com/jnsgruk/crafts-flake/blob/f63f315ee2832a112e0777b8af575297c8c9e62d/test/vm.nix" target="_blank" rel="noreferrer"&gt;configuration&lt;/a&gt; looks like this:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;
&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1
&lt;/span&gt;&lt;span class="lnt"&gt; 2
&lt;/span&gt;&lt;span class="lnt"&gt; 3
&lt;/span&gt;&lt;span class="lnt"&gt; 4
&lt;/span&gt;&lt;span class="lnt"&gt; 5
&lt;/span&gt;&lt;span class="lnt"&gt; 6
&lt;/span&gt;&lt;span class="lnt"&gt; 7
&lt;/span&gt;&lt;span class="lnt"&gt; 8
&lt;/span&gt;&lt;span class="lnt"&gt; 9
&lt;/span&gt;&lt;span class="lnt"&gt;10
&lt;/span&gt;&lt;span class="lnt"&gt;11
&lt;/span&gt;&lt;span class="lnt"&gt;12
&lt;/span&gt;&lt;span class="lnt"&gt;13
&lt;/span&gt;&lt;span class="lnt"&gt;14
&lt;/span&gt;&lt;span class="lnt"&gt;15
&lt;/span&gt;&lt;span class="lnt"&gt;16
&lt;/span&gt;&lt;span class="lnt"&gt;17
&lt;/span&gt;&lt;span class="lnt"&gt;18
&lt;/span&gt;&lt;span class="lnt"&gt;19
&lt;/span&gt;&lt;span class="lnt"&gt;20
&lt;/span&gt;&lt;span class="lnt"&gt;21
&lt;/span&gt;&lt;span class="lnt"&gt;22
&lt;/span&gt;&lt;span class="lnt"&gt;23
&lt;/span&gt;&lt;span class="lnt"&gt;24
&lt;/span&gt;&lt;span class="lnt"&gt;25
&lt;/span&gt;&lt;span class="lnt"&gt;26
&lt;/span&gt;&lt;span class="lnt"&gt;27
&lt;/span&gt;&lt;span class="lnt"&gt;28
&lt;/span&gt;&lt;span class="lnt"&gt;29
&lt;/span&gt;&lt;span class="lnt"&gt;30
&lt;/span&gt;&lt;span class="lnt"&gt;31
&lt;/span&gt;&lt;span class="lnt"&gt;32
&lt;/span&gt;&lt;span class="lnt"&gt;33
&lt;/span&gt;&lt;span class="lnt"&gt;34
&lt;/span&gt;&lt;span class="lnt"&gt;35
&lt;/span&gt;&lt;span class="lnt"&gt;36
&lt;/span&gt;&lt;span class="lnt"&gt;37
&lt;/span&gt;&lt;span class="lnt"&gt;38
&lt;/span&gt;&lt;span class="lnt"&gt;39
&lt;/span&gt;&lt;span class="lnt"&gt;40
&lt;/span&gt;&lt;span class="lnt"&gt;41
&lt;/span&gt;&lt;span class="lnt"&gt;42
&lt;/span&gt;&lt;span class="lnt"&gt;43
&lt;/span&gt;&lt;span class="lnt"&gt;44
&lt;/span&gt;&lt;span class="lnt"&gt;45
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-nix" data-lang="nix"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;modulesPath&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;flake&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pkgs&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="o"&gt;...&lt;/span&gt; &lt;span class="p"&gt;}:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="c1"&gt;# A nice helper that handles creating the VM launch script, which in turn&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="c1"&gt;# ensures the disk image is created as required, and QEMU is launched&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="c1"&gt;# with sensible parameters.&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="n"&gt;imports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;&lt;/span&gt;&lt;span class="si"&gt;${&lt;/span&gt;&lt;span class="n"&gt;modulesPath&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;/virtualisation/qemu-vm.nix&amp;#34;&lt;/span&gt; &lt;span class="p"&gt;];&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="c1"&gt;# Define the version of NixOS and the architecture.&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="n"&gt;system&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;stateVersion&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;23.11&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="n"&gt;nixpkgs&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;hostPlatform&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;x86_64-linux&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="c1"&gt;# This overlay is provided by the crafts-flake, and ensures that&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="c1"&gt;# &amp;#39;pkgs.snapcraft&amp;#39;, &amp;#39;pkgs.charmcraft&amp;#39;, &amp;#39;pkgs.rockcraft&amp;#39; all resolve to&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="c1"&gt;# the packages in the flake.&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="n"&gt;nixpkgs&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;overlays&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt; &lt;span class="n"&gt;flake&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;outputs&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;overlay&lt;/span&gt; &lt;span class="p"&gt;];&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="c1"&gt;# These values are tuned such that the VM performs on Github Actions runners.&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="n"&gt;virtualisation&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="n"&gt;forwardPorts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[{&lt;/span&gt; &lt;span class="n"&gt;from&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;host&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;host&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;port&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2222&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;guest&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;port&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;22&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}];&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="n"&gt;cores&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="n"&gt;memorySize&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5120&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="n"&gt;diskSize&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10240&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="p"&gt;};&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="c1"&gt;# Configure the root user without password and enable SSH.&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="c1"&gt;# This VM will only ever be used in short-lived testing environments with&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="c1"&gt;# no inbound networking permitted, so there is minimal (if any) risk.&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="c1"&gt;# If you put this VM on the internet, you can keep the pieces! :)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="n"&gt;networking&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;firewall&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;enable&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="n"&gt;services&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;openssh&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;enable&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="n"&gt;services&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;openssh&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;settings&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;PermitRootLogin&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;yes&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="n"&gt;users&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;extraUsers&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;password&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;password&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="c1"&gt;# Ensure that LXD is installed, and started on boot.&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="n"&gt;virtualisation&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;lxd&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;enable&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="c1"&gt;# Include the `craft-test` script, ensuring the craft apps are installed&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="c1"&gt;# and included in its PATH.&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="n"&gt;environment&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;systemPackages&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pkgs&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;writeShellApplication&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;craft-test&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="n"&gt;runtimeInputs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="n"&gt;pkgs&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt; &lt;span class="n"&gt;unixtools&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;xxd&lt;/span&gt; &lt;span class="n"&gt;git&lt;/span&gt; &lt;span class="n"&gt;snapcraft&lt;/span&gt; &lt;span class="n"&gt;charmcraft&lt;/span&gt; &lt;span class="n"&gt;rockcraft&lt;/span&gt; &lt;span class="p"&gt;];&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="n"&gt;text&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;builtins&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;readFile&lt;/span&gt; &lt;span class="sr"&gt;./craft-test&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="p"&gt;})&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="p"&gt;];&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;Anybody can build and launch this VM trivially:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;
&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;nix run github:jnsgruk/crafts-flake#testVM
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;h2 id="writing-a-github-workflow" class="relative group"&gt;Writing a Github workflow &lt;span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100"&gt;&lt;a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700" style="text-decoration-line: none !important;" href="#writing-a-github-workflow" aria-label="Anchor"&gt;#&lt;/a&gt;&lt;/span&gt;&lt;/h2&gt;&lt;p&gt;All the building blocks are in place! I wanted to keep the actual workflow definition for the tests as clean and understandable as possible, so I put together the &lt;a href="https://github.com/jnsgruk/crafts-flake/blob/f63f315ee2832a112e0777b8af575297c8c9e62d/test/craft-test" target="_blank" rel="noreferrer"&gt;&lt;code&gt;craft-test&lt;/code&gt;&lt;/a&gt; script as a small helper which automates the building of real artefacts. An example invocation might be:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;
&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;bash craft-test snapcraft
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;On each invocation, the script creates temporary directory, clones some representative build files for the selected craft tool, and launches the craft. The repos it uses for the representative packages are hard-coded for each craft for now.&lt;/p&gt;
&lt;p&gt;I wrote one more &lt;a href="https://github.com/jnsgruk/crafts-flake/blob/f63f315ee2832a112e0777b8af575297c8c9e62d/test/vm-exec" target="_blank" rel="noreferrer"&gt;small helper script&lt;/a&gt; to simplify connecting to the VM with the required parameters. It&amp;rsquo;s a wrapper around &lt;code&gt;ssh&lt;/code&gt; and &lt;code&gt;sshpass&lt;/code&gt; that&amp;rsquo;s hard-coded with the credentials of the test VM (don&amp;rsquo;t @ me!), and executes commands over SSH in the test VM. Using this script, one can &lt;code&gt;bash vm-exec -- craft-test snapcraft&lt;/code&gt; and the &lt;code&gt;craft-test&lt;/code&gt; script will be executed over SSH in the VM.&lt;/p&gt;
&lt;p&gt;With all that said and done, the resulting &lt;a href="https://github.com/jnsgruk/crafts-flake/blob/f63f315ee2832a112e0777b8af575297c8c9e62d/.github/workflows/test.yaml" target="_blank" rel="noreferrer"&gt;workflow&lt;/a&gt; is pleasingly simple:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;
&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1
&lt;/span&gt;&lt;span class="lnt"&gt; 2
&lt;/span&gt;&lt;span class="lnt"&gt; 3
&lt;/span&gt;&lt;span class="lnt"&gt; 4
&lt;/span&gt;&lt;span class="lnt"&gt; 5
&lt;/span&gt;&lt;span class="lnt"&gt; 6
&lt;/span&gt;&lt;span class="lnt"&gt; 7
&lt;/span&gt;&lt;span class="lnt"&gt; 8
&lt;/span&gt;&lt;span class="lnt"&gt; 9
&lt;/span&gt;&lt;span class="lnt"&gt;10
&lt;/span&gt;&lt;span class="lnt"&gt;11
&lt;/span&gt;&lt;span class="lnt"&gt;12
&lt;/span&gt;&lt;span class="lnt"&gt;13
&lt;/span&gt;&lt;span class="lnt"&gt;14
&lt;/span&gt;&lt;span class="lnt"&gt;15
&lt;/span&gt;&lt;span class="lnt"&gt;16
&lt;/span&gt;&lt;span class="lnt"&gt;17
&lt;/span&gt;&lt;span class="lnt"&gt;18
&lt;/span&gt;&lt;span class="lnt"&gt;19
&lt;/span&gt;&lt;span class="lnt"&gt;20
&lt;/span&gt;&lt;span class="lnt"&gt;21
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-yaml" data-lang="yaml"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c"&gt;# ...&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nt"&gt;jobs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;test&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;runs-on&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l"&gt;ubuntu-latest&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;strategy&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;matrix&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;package&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;&amp;#34;charmcraft&amp;#34;&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;#34;rockcraft&amp;#34;&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;#34;snapcraft&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;steps&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;- &lt;span class="nt"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l"&gt;Checkout flake&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;uses&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l"&gt;actions/checkout@v4&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;- &lt;span class="nt"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l"&gt;Install nix&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;uses&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l"&gt;DeterminateSystems/nix-installer-action@v9&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;- &lt;span class="nt"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l"&gt;Build and run the test VM&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;run&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="sd"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="sd"&gt; nix run .#testVm -- -daemonize -display none&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;- &lt;span class="nt"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l"&gt;Test ${{ matrix.package }}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;run&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="sd"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="sd"&gt; nix run .#testVmExec -- craft-test ${{ matrix.package }}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;A separate job is run for each of the crafts, and a real artefact is built in each, giving reasonable confidence that the consumers of my flake will be successful when building snaps, rocks and charms natively on NixOS. A successful run can be seen &lt;a href="https://github.com/jnsgruk/crafts-flake/actions/runs/7772604925" target="_blank" rel="noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id="summary" class="relative group"&gt;Summary &lt;span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100"&gt;&lt;a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700" style="text-decoration-line: none !important;" href="#summary" aria-label="Anchor"&gt;#&lt;/a&gt;&lt;/span&gt;&lt;/h2&gt;&lt;p&gt;In this article we&amp;rsquo;ve covered:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Enabling KVM on Github Runners&lt;/li&gt;
&lt;li&gt;Building NixOS VMs using Flakes&lt;/li&gt;
&lt;li&gt;Booting NixOS VMs in Github Actions&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If you&amp;rsquo;d like to build snaps, rocks or charms and you&amp;rsquo;re running NixOS, you can run the tools individually from my flake:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;
&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1
&lt;/span&gt;&lt;span class="lnt"&gt;2
&lt;/span&gt;&lt;span class="lnt"&gt;3
&lt;/span&gt;&lt;span class="lnt"&gt;4
&lt;/span&gt;&lt;span class="lnt"&gt;5
&lt;/span&gt;&lt;span class="lnt"&gt;6
&lt;/span&gt;&lt;span class="lnt"&gt;7
&lt;/span&gt;&lt;span class="lnt"&gt;8
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Run charmcraft&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;nix run github:jnsgruk/crafts-flake#charmcraft
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Run rockcraft&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;nix run github:jnsgruk/crafts-flake#rockcraft
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Run snapcraft&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;nix run github:jnsgruk/crafts-flake#snapcraft
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;Or you can check out the &lt;a href="https://github.com/jnsgruk/crafts-flake" target="_blank" rel="noreferrer"&gt;README&lt;/a&gt; for instructions on how to integrate into your Nix config using overlays!&lt;/p&gt;
&lt;p&gt;That&amp;rsquo;s all for now! 🤓&lt;/p&gt;</description></item><item><title>Continuous Profiling for Juju with Parca</title><link>https://jnsgr.uk/2022/08/continuous-profiling-juju/</link><pubDate>Tue, 02 Aug 2022 00:00:00 +0000</pubDate><guid>https://jnsgr.uk/2022/08/continuous-profiling-juju/</guid><description>&lt;blockquote&gt;
&lt;p&gt;This post was originally posted &lt;a href="https://discourse.charmhub.io/t/continuous-profiling-for-juju-parca-on-machines-and-kubernetes/6815" target="_blank" rel="noreferrer"&gt;on Charmhub&lt;/a&gt; on 02 August 2022. I&amp;rsquo;ve posted it to my blog retrospectively, but the article is unchanged. Some commands may need slight adjustments today, feel free to reach out if you get stuck!&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id="introduction" class="relative group"&gt;Introduction &lt;span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100"&gt;&lt;a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700" style="text-decoration-line: none !important;" href="#introduction" aria-label="Anchor"&gt;#&lt;/a&gt;&lt;/span&gt;&lt;/h2&gt;&lt;p&gt;Over the past few days, I&amp;rsquo;ve been diving into some charm development to get a hands-on feel for where Juju and the Charmed Operator ecosystem has gotten to over the past 15 months. In this post we will:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Outline the progress we&amp;rsquo;ve made, and the current state of charm development and integration&lt;/li&gt;
&lt;li&gt;Show how the Observability libraries can be used to rapidly instrument charmed operators&lt;/li&gt;
&lt;li&gt;Highlight a nice open source continuous profiling tool&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;But first, let&amp;rsquo;s start with a juicy screenshot showing where we&amp;rsquo;re headed with this post!&lt;/p&gt;
&lt;p&gt;&lt;a href="01.png"&gt;
&lt;figure&gt;
&lt;picture
class="mx-auto my-0 rounded-md"
&gt;
&lt;source
srcset="https://jnsgr.uk/2022/08/continuous-profiling-juju/01_hu_8e8e8468a09ec6b7.webp 330w,https://jnsgr.uk/2022/08/continuous-profiling-juju/01_hu_902983b2e820e934.webp 660w
,https://jnsgr.uk/2022/08/continuous-profiling-juju/01_hu_b840beed04f3cf95.webp 1024w
,https://jnsgr.uk/2022/08/continuous-profiling-juju/01_hu_7e268c4ee75e6d20.webp 1320w
"
sizes="100vw"
type="image/webp"
/&gt;
&lt;img
width="1840"
height="1390"
class="mx-auto my-0 rounded-md"
alt="controller-profile"
loading="lazy" decoding="async"
src="https://jnsgr.uk/2022/08/continuous-profiling-juju/01_hu_68ca4c7c69792e17.png" srcset="https://jnsgr.uk/2022/08/continuous-profiling-juju/01_hu_9718b382dfc24e97.png 330w,https://jnsgr.uk/2022/08/continuous-profiling-juju/01_hu_68ca4c7c69792e17.png 660w
,https://jnsgr.uk/2022/08/continuous-profiling-juju/01_hu_a8dea93e3480c161.png 1024w
,https://jnsgr.uk/2022/08/continuous-profiling-juju/01_hu_1a534b357876e32c.png 1320w
"
sizes="100vw"
/&gt;
&lt;/picture&gt;
&lt;/figure&gt;
&lt;/a&gt;&lt;/p&gt;
&lt;h2 id="what-is-continuous-profiling" class="relative group"&gt;What is continuous profiling? &lt;span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100"&gt;&lt;a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700" style="text-decoration-line: none !important;" href="#what-is-continuous-profiling" aria-label="Anchor"&gt;#&lt;/a&gt;&lt;/span&gt;&lt;/h2&gt;&lt;p&gt;Profiling itself is not a new concept. Profiling is all about measuring applications dynamically at runtime to understand their CPU usage, memory usage, and other important metrics. Profiling can yield deep insights about your application&amp;rsquo;s performance at runtime right down to the line of code that allocated some memory, or created a thread&lt;/p&gt;
&lt;p&gt;Previously profiling was almost always performed on a &amp;ldquo;point in time&amp;rdquo; basis; continuous profiling improves upon this methodology by introducing a new dimension to your profiling results: time. The basic principle is that by profiling your code at regular intervals, you can understand more easily how different stimuli and runtime conditions affect the performance of your code, and its effect in turn on the underlying system.&lt;/p&gt;
&lt;p&gt;Continuous profiling itself is not particularly new either, but its certainly a more regular topic of conversation for many in the last twelve months. Google wrote about it back in 2010 in a paper named &lt;a href="https://research.google/pubs/pub36575/" target="_blank" rel="noreferrer"&gt;Google Wide Profiling&lt;/a&gt;. They also stewarded the &lt;a href="https://github.com/google/pprof" target="_blank" rel="noreferrer"&gt;&lt;code&gt;pprof&lt;/code&gt;&lt;/a&gt; project which not only defines a data format for profiles themselves, but resulted in the inclusion of the &lt;a href="https://pkg.go.dev/gopkg.in/gin-contrib/pprof.v1" target="_blank" rel="noreferrer"&gt;&lt;code&gt;pprof&lt;/code&gt; Go package&lt;/a&gt; which provides a trivial means for including an HTTP server that&amp;rsquo;s ready to serve performance profiles in the &lt;code&gt;pprof&lt;/code&gt; format, giving insights into memory allocations, CPU usage and goroutines created in the Go runtime.&lt;/p&gt;
&lt;h2 id="enter-parca" class="relative group"&gt;Enter Parca &lt;span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100"&gt;&lt;a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700" style="text-decoration-line: none !important;" href="#enter-parca" aria-label="Anchor"&gt;#&lt;/a&gt;&lt;/span&gt;&lt;/h2&gt;&lt;p&gt;&lt;a href="https://parca.dev" target="_blank" rel="noreferrer"&gt;Parca&lt;/a&gt; is an open source continuous profiling tool by &lt;a href="https://www.polarsignals.com/" target="_blank" rel="noreferrer"&gt;Polar Signals&lt;/a&gt;. It&amp;rsquo;s written in Go, and takes inspiration from Prometheus in its configuration and storage of data. Better still, while Polar Signals are the primary stewards of Parca, the project is fully open source and has an &lt;a href="https://www.parca.dev/docs/governance" target="_blank" rel="noreferrer"&gt;open governance model&lt;/a&gt; which means anyone can become a maintainer.&lt;/p&gt;
&lt;p&gt;We have been troubleshooting some crunchy performance issues in the Juju controller code of late, and it led me to think more carefully about profiling tools and start experimenting with Parca&lt;/p&gt;
&lt;p&gt;Polar Signals &lt;a href="https://www.parca.dev/docs/parca" target="_blank" rel="noreferrer"&gt;distribute two key components&lt;/a&gt; for their solution: the Parca server, and the Parca agent. The server is responsible for collecting profiles across applications (and hosts) and making them available for viewing, filtering and analysis in a nice modern web interface. The agent is focused on specific hosts and unlocks some very powerful capabilities, including host-wide profiling using eBPF, which means you can benefit from profiling even if the applications themselves are not natively instrumented for profiling.&lt;/p&gt;
&lt;p&gt;I read a little about Parca, and dived right in to configuring it in an SSH session on my controller (I even &lt;a href="https://twitter.com/jnsgruk/status/1550184107568762880" target="_blank" rel="noreferrer"&gt;tweeted&lt;/a&gt; about it!). After I&amp;rsquo;d got things running, I decided to write a simple charm for Parca, but at the time it was just distributed by means of signed binaries in a Github release. I wanted an easier way to get access to Parca from within my charm that would save me the hassle of working out which architecture to fetch, verifying checksums and figuring out an escape hatch for &amp;ldquo;airgapped&amp;rdquo; systems. I decided to start building a snap package…&lt;/p&gt;
&lt;h2 id="snap-install-parca" class="relative group"&gt;&lt;code&gt;snap install parca&lt;/code&gt; &lt;span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100"&gt;&lt;a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700" style="text-decoration-line: none !important;" href="#snap-install-parca" aria-label="Anchor"&gt;#&lt;/a&gt;&lt;/span&gt;&lt;/h2&gt;&lt;p&gt;Building a snap for Parca turned out to be a dream&lt;/p&gt;
&lt;p&gt;Being written in Go gives it an unfair advantage, but at this early stage there isn&amp;rsquo;t a huge amount of config to contend with either. Even better, the server component requires very little access to the underlying host, making it a great candidate for a strictly confined snap. You can find the code for the Parca snap &lt;a href="https://github.com/parca-dev/parca/blob/64e853a94dc382feae3481f3f64efa47e8f5709c/.goreleaser.yml#L37-L85" target="_blank" rel="noreferrer"&gt;on Github&lt;/a&gt;. You get started right away with:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;
&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sudo snap install parca --channel edge
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;At the time of writing, the snap has two modes of operation: firstly it&amp;rsquo;ll make the &lt;code&gt;parca&lt;/code&gt; command available for you to run one-shot. Parca is configured using command line flags in conjunction with a YAML file for specifying scrape targets and object storage. Because the snap is strictly confined, it can only read from &lt;code&gt;/var/snap/parca/current&lt;/code&gt; and &lt;code&gt;/var/snap/parca/common&lt;/code&gt;, so you&amp;rsquo;ll need to be careful about where you place your config file. The snap is also automatically granted access to &lt;code&gt;/etc/parca&lt;/code&gt;, so you can drop the config file in &lt;code&gt;/etc/parca/parca.yaml&lt;/code&gt; like the upstream docs &lt;a href="https://www.parca.dev/docs/systemd" target="_blank" rel="noreferrer"&gt;suggest&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;In addition to the &amp;ldquo;one-shot&amp;rdquo; mode of operation, the snap also provides a service. This essentially provides an out-of-the-box systemd configuration with a set of sensible defaults. Once installed you can start Parca immediately using the default configuration like so:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;
&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1
&lt;/span&gt;&lt;span class="lnt"&gt;2
&lt;/span&gt;&lt;span class="lnt"&gt;3
&lt;/span&gt;&lt;span class="lnt"&gt;4
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Start the service&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sudo snap start parca
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Follow the logs&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sudo snap logs -f parca
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;There are a couple of configuration options, though they&amp;rsquo;re intentionally limited for now. If you look around carefully you&amp;rsquo;ll find options to configure the in-memory profile storage limit, and the experimental on-disk storage mode.&lt;/p&gt;
&lt;h2 id="charmed-parca" class="relative group"&gt;Charmed Parca &lt;span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100"&gt;&lt;a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700" style="text-decoration-line: none !important;" href="#charmed-parca" aria-label="Anchor"&gt;#&lt;/a&gt;&lt;/span&gt;&lt;/h2&gt;&lt;p&gt;With a nice convenient way to install and basically configure Parca on any Linux machine, it was time to craft a simple charm! I&amp;rsquo;ll not delve too deep here, as the details of writing Charmed Operators is well covered in the &lt;a href="https://juju.is/docs/sdk" target="_blank" rel="noreferrer"&gt;SDK Docs&lt;/a&gt;. I do want to highlight some interesting points from those early commits, though…&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;I created a simple &lt;a href="https://github.com/jnsgruk/parca-operator/blob/a63ae8ba18d01c6bf3f002853cf043846ba79605/src/parca.py" target="_blank" rel="noreferrer"&gt;class&lt;/a&gt; that represents Parca in the codebase. This is a very simple wrapper around a set of snap commands.&lt;/li&gt;
&lt;li&gt;I&amp;rsquo;m utilising the snap &lt;a href="https://charmhub.io/operator-libs-linux/libraries/snap" target="_blank" rel="noreferrer"&gt;library&lt;/a&gt; from Charmhub to keep things brief&lt;/li&gt;
&lt;li&gt;The above class enables us to keep the actual &lt;a href="https://github.com/jnsgruk/parca-operator/blob/a63ae8ba18d01c6bf3f002853cf043846ba79605/src/charm.py" target="_blank" rel="noreferrer"&gt;charm class&lt;/a&gt; very simple indeed!&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I used to opportunity to test out a new way of testing &amp;ldquo;machine charms&amp;rdquo;. If you&amp;rsquo;re so inclined, you can dig in and see that there are &lt;a href="https://github.com/jnsgruk/parca-operator/tree/a63ae8ba18d01c6bf3f002853cf043846ba79605/tests/unit" target="_blank" rel="noreferrer"&gt;unit tests&lt;/a&gt; that focus solely on the lifecycle of the charm and its interation with the Juju hook tools, followed by &lt;a href="https://github.com/jnsgruk/parca-operator/tree/a63ae8ba18d01c6bf3f002853cf043846ba79605/tests/functional" target="_blank" rel="noreferrer"&gt;functional tests&lt;/a&gt; which make no assumptions about being run in the context of Juju and validate only the system-level behaviour of installing and manipulating the snap, and finally &lt;a href="https://github.com/jnsgruk/parca-operator/blob/a63ae8ba18d01c6bf3f002853cf043846ba79605/tests/integration/test_charm.py" target="_blank" rel="noreferrer"&gt;integration tests&lt;/a&gt; which build and deploy the charm on a real LXD cluster.&lt;/p&gt;
&lt;p&gt;But what about Kubernetes, I hear you ask? Well thankfully, because the kind folks at Polar Signals provide OCI images for each of their builds , it wasn&amp;rsquo;t much trouble to get it running on Kubernetes either, as early commits &lt;a href="https://github.com/jnsgruk/parca-k8s-operator/blob/0a45421025d381fcb21629095e84e33c56e827fd/src/charm.py" target="_blank" rel="noreferrer"&gt;would indicate&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id="integrating-parca-with-the-canonical-observability-stack" class="relative group"&gt;Integrating Parca with the Canonical Observability Stack &lt;span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100"&gt;&lt;a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700" style="text-decoration-line: none !important;" href="#integrating-parca-with-the-canonical-observability-stack" aria-label="Anchor"&gt;#&lt;/a&gt;&lt;/span&gt;&lt;/h2&gt;&lt;p&gt;Here&amp;rsquo;s where things got a bit magic Over the past 12 months, the Observability charm team have been busily working on the &lt;a href="https://charmhub.io/topics/canonical-observability-stack" target="_blank" rel="noreferrer"&gt;Canonical Observability Stack&lt;/a&gt;, which combines Prometheus, Grafana, Loki and Alertmanager into a turn-key observability solution on top of MicroK8s (or any other CNCF-conformant Kubernetes , for that matter.).&lt;/p&gt;
&lt;p&gt;I mentioned earlier on that Parca took inspiration from Prometheus&amp;rsquo; configuration when it comes to defining its profiling targets. This made my life very easy in this case. The Observability team have defined the &lt;a href="https://charmhub.io/prometheus-k8s/libraries/prometheus_scrape" target="_blank" rel="noreferrer"&gt;prometheus_scrape&lt;/a&gt; relation which provides a Charm library that anyone can use to integrate their application such that prometheus can scrape it for metrics. In my case, I wanted to re-use the other side of that library! While the overall changes I made to the charm in this phase were large, this &lt;a href="https://github.com/jnsgruk/parca-operator/commit/7537ae0526dbbadf9f22c5968193d126c104618b#diff-b9ed39bbc9c0387bd3e07da31d13373745534a1cd723d3e292c73496b12e307c" target="_blank" rel="noreferrer"&gt;diff&lt;/a&gt; highlights they key changes I needed to make in order to reuse the existing implementation. I later forked this library and updated the interface name to &lt;code&gt;parca_scrape&lt;/code&gt; to ensure that there are no mistakes when relating charms at runtime.&lt;/p&gt;
&lt;p&gt;This meant that any charmed application could now trivially implement a relation that enabled it to be profiled by Parca . I chose to do this initially with a small stub operator called &lt;code&gt;juju-introspect&lt;/code&gt; (&lt;a href="https://charmhub.io/juju-introspect" target="_blank" rel="noreferrer"&gt;Charmhub&lt;/a&gt;/&lt;a href="https://github.com/jnsgruk/juju-introspect-operator" target="_blank" rel="noreferrer"&gt;Github&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;Of course, once I&amp;rsquo;d worked this out, the implementation was relatively trivial to port to the Kubernetes charm too. Over a total of a few hours, I had created and published a Charmed Operator for Parca for both Kubernetes and machines that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Installs Parca from the Snap store (machines only)&lt;/li&gt;
&lt;li&gt;Starts and manages Parca&amp;rsquo;s configuration with minimal overhead on human operators&lt;/li&gt;
&lt;li&gt;Enables Parca to profile other applications using relations&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/jnsgruk/parca-operator/commit/53f6f078ed5fa1489f5526ef501f17a2e1c9ad1e" target="_blank" rel="noreferrer"&gt;Provide integrations with Prometheus&lt;/a&gt; so that Parca can be scraped for metrics&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/jnsgruk/parca-k8s-operator/commit/2160139ab427a528f9b4597969b7ac224fdfd949" target="_blank" rel="noreferrer"&gt;Provide integrations with Grafana&lt;/a&gt; and include a &lt;a href="https://github.com/jnsgruk/parca-k8s-operator/commit/2160139ab427a528f9b4597969b7ac224fdfd949#diff-dd822e68fe3d5e5e25161716bce5afdc7ac65b1d9754b622cce1d3690f38ddb2" target="_blank" rel="noreferrer"&gt;default dashboard&lt;/a&gt; for both charms&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/jnsgruk/parca-k8s-operator/commit/60543697a59c148a0408105901d542472e0d5623" target="_blank" rel="noreferrer"&gt;Integrate with the Traefik ingress&lt;/a&gt; on Kubernetes&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The other side of the coin is similarly approachable. Take the &lt;a href="https://charmhub.io/zinc-k8s" target="_blank" rel="noreferrer"&gt;Zinc&lt;/a&gt; operator as an example - Zinc is a modern, efficient alternative to Elasticsearch written in Go, and happens to provide a profiling endpoint when configured correctly - you can see &lt;em&gt;all of the effort&lt;/em&gt; required to enable that integration in the Juju model in &lt;a href="https://github.com/jnsgruk/zinc-k8s-operator/commit/ac64482af13f92777841f7782a7b1320c5454e3c" target="_blank" rel="noreferrer"&gt;this diff&lt;/a&gt; .&lt;/p&gt;
&lt;h2 id="try-it-out" class="relative group"&gt;Try it out! &lt;span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100"&gt;&lt;a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700" style="text-decoration-line: none !important;" href="#try-it-out" aria-label="Anchor"&gt;#&lt;/a&gt;&lt;/span&gt;&lt;/h2&gt;&lt;p&gt;So what if you want to get started?! I think there are two interesting experiments for the reader as a result of this article:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Profiling a Juju controller on LXD&lt;/li&gt;
&lt;li&gt;Profiling Zinc on Kubernetes&lt;/li&gt;
&lt;li&gt;Integrating Parca with the Canonical Observability Stack&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The following sections assume that you have access to a machine with a LXD setup, and a &lt;a href="https://microk8s.io" target="_blank" rel="noreferrer"&gt;MicroK8s&lt;/a&gt; setup. I use &lt;a href="https://multipass.run" target="_blank" rel="noreferrer"&gt;Multipass&lt;/a&gt; for this, but you can find a nice break down &lt;a href="https://juju.is/docs/sdk/dev-setup" target="_blank" rel="noreferrer"&gt;in the Juju docs&lt;/a&gt; if you need to get set up.&lt;/p&gt;
&lt;h3 id="profiling-a-juju-controller-on-lxd" class="relative group"&gt;Profiling a Juju controller on LXD &lt;span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100"&gt;&lt;a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700" style="text-decoration-line: none !important;" href="#profiling-a-juju-controller-on-lxd" aria-label="Anchor"&gt;#&lt;/a&gt;&lt;/span&gt;&lt;/h3&gt;&lt;p&gt;Make sure you&amp;rsquo;ve got access to a LXD cluster, and the perform the following steps to bootstrap a Juju controller, then augment the controller machine with the &lt;code&gt;juju-introspect&lt;/code&gt; operator (I&amp;rsquo;m going to give this some more thought in coming months; as Juju 3.0 releases we&amp;rsquo;ll introduce a &amp;lsquo;controller charm&amp;rsquo; that&amp;rsquo;ll be able to handle this natively!)&lt;/p&gt;
&lt;p&gt;Check out the asciinema recording below for a detailed walkthrough, or follow the instructions below:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://asciinema.org/a/517942" target="_blank" rel="noreferrer"&gt;
&lt;figure&gt;&lt;img src="https://asciinema.org/a/517942.svg" alt="asciicast" class="mx-auto my-0 rounded-md" /&gt;
&lt;/figure&gt;
&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="01.jpg"&gt;
&lt;figure&gt;&lt;img src="01.jpg" alt="controller-profile" class="mx-auto my-0 rounded-md" /&gt;
&lt;/figure&gt;
&lt;/a&gt;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;
&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1
&lt;/span&gt;&lt;span class="lnt"&gt; 2
&lt;/span&gt;&lt;span class="lnt"&gt; 3
&lt;/span&gt;&lt;span class="lnt"&gt; 4
&lt;/span&gt;&lt;span class="lnt"&gt; 5
&lt;/span&gt;&lt;span class="lnt"&gt; 6
&lt;/span&gt;&lt;span class="lnt"&gt; 7
&lt;/span&gt;&lt;span class="lnt"&gt; 8
&lt;/span&gt;&lt;span class="lnt"&gt; 9
&lt;/span&gt;&lt;span class="lnt"&gt;10
&lt;/span&gt;&lt;span class="lnt"&gt;11
&lt;/span&gt;&lt;span class="lnt"&gt;12
&lt;/span&gt;&lt;span class="lnt"&gt;13
&lt;/span&gt;&lt;span class="lnt"&gt;14
&lt;/span&gt;&lt;span class="lnt"&gt;15
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-shell" data-lang="shell"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Bootstrap a new Juju controller on LXD&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;juju bootstrap localhost lxd
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Switch to the controller model&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;juju switch controller
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Deploy the charm to the controller machine&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;juju deploy juju-introspect -to &lt;span class="m"&gt;0&lt;/span&gt; --channel edge
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Now you&amp;#39;ve got a controller machine up, you&amp;#39;re ready to start profiling.&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Deploy the Parca operator&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;juju deploy parca --channel edge
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Relate Parca to the juju-introspect operator to configure a profiling target&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;juju relate parca juju-introspect
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;You can monitor the status of these operations with &lt;code&gt;juju status&lt;/code&gt;, once things are settled you should be able to browse to the address of the Parca charm (on port &lt;code&gt;7070&lt;/code&gt;) and start exploring profiles.&lt;/p&gt;
&lt;h3 id="profiling-zinc-on-kubernetes" class="relative group"&gt;Profiling Zinc on Kubernetes &lt;span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100"&gt;&lt;a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700" style="text-decoration-line: none !important;" href="#profiling-zinc-on-kubernetes" aria-label="Anchor"&gt;#&lt;/a&gt;&lt;/span&gt;&lt;/h3&gt;&lt;p&gt;In this section, we&amp;rsquo;ll explore how to profile Zinc with Parca on Kubernetes with Juju, but also the integrations with Prometheus and Grafana. I&amp;rsquo;ve included a short recording here to show the process, and some abbreviated instructions…&lt;/p&gt;
&lt;p&gt;Check out the asciinema recording below for a detailed walkthrough, or follow the instructions below:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://asciinema.org/a/517947" target="_blank" rel="noreferrer"&gt;
&lt;figure&gt;&lt;img src="https://asciinema.org/a/517947.svg" alt="asciicast" class="mx-auto my-0 rounded-md" /&gt;
&lt;/figure&gt;
&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Once you&amp;rsquo;re done with that, you can login to the Parca dashboard and start comparing profiles:&lt;/p&gt;
&lt;p&gt;&lt;a href="02.png"&gt;
&lt;figure&gt;
&lt;picture
class="mx-auto my-0 rounded-md"
&gt;
&lt;source
srcset="https://jnsgr.uk/2022/08/continuous-profiling-juju/02_hu_54497b8f4a6ee356.webp 330w,https://jnsgr.uk/2022/08/continuous-profiling-juju/02_hu_24390646f300fc19.webp 660w
,https://jnsgr.uk/2022/08/continuous-profiling-juju/02_hu_98ec0ce03fd4b4a4.webp 1024w
,https://jnsgr.uk/2022/08/continuous-profiling-juju/02_hu_df5d4de5fab10682.webp 1320w
"
sizes="100vw"
type="image/webp"
/&gt;
&lt;img
width="1776"
height="1380"
class="mx-auto my-0 rounded-md"
alt="parca-zinc-profile"
loading="lazy" decoding="async"
src="https://jnsgr.uk/2022/08/continuous-profiling-juju/02_hu_6b1951fb75571310.png" srcset="https://jnsgr.uk/2022/08/continuous-profiling-juju/02_hu_1bb95c34f0ff7db0.png 330w,https://jnsgr.uk/2022/08/continuous-profiling-juju/02_hu_6b1951fb75571310.png 660w
,https://jnsgr.uk/2022/08/continuous-profiling-juju/02_hu_b5baac81a2f9d707.png 1024w
,https://jnsgr.uk/2022/08/continuous-profiling-juju/02_hu_6de5e1322b48ce17.png 1320w
"
sizes="100vw"
/&gt;
&lt;/picture&gt;
&lt;/figure&gt;
&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;And also take time to check out the targets page, and notice that the target has been automatically labelled with information about the target application&amp;rsquo;s location in the Juju model:&lt;/p&gt;
&lt;p&gt;&lt;a href="03.png"&gt;
&lt;figure&gt;
&lt;picture
class="mx-auto my-0 rounded-md"
&gt;
&lt;source
srcset="https://jnsgr.uk/2022/08/continuous-profiling-juju/03_hu_d3f9066834c80aa0.webp 330w,https://jnsgr.uk/2022/08/continuous-profiling-juju/03_hu_625f17997029c3.webp 660w
,https://jnsgr.uk/2022/08/continuous-profiling-juju/03_hu_490a4089fd18ae84.webp 1024w
,https://jnsgr.uk/2022/08/continuous-profiling-juju/03_hu_63d6a331abad69ee.webp 1320w
"
sizes="100vw"
type="image/webp"
/&gt;
&lt;img
width="1835"
height="1303"
class="mx-auto my-0 rounded-md"
alt="parca-zinc-target"
loading="lazy" decoding="async"
src="https://jnsgr.uk/2022/08/continuous-profiling-juju/03_hu_c149236a5cc56756.png" srcset="https://jnsgr.uk/2022/08/continuous-profiling-juju/03_hu_f51dc4683bcc59e8.png 330w,https://jnsgr.uk/2022/08/continuous-profiling-juju/03_hu_c149236a5cc56756.png 660w
,https://jnsgr.uk/2022/08/continuous-profiling-juju/03_hu_8f68939bd1cdedb3.png 1024w
,https://jnsgr.uk/2022/08/continuous-profiling-juju/03_hu_3aabbe947fb4b4bd.png 1320w
"
sizes="100vw"
/&gt;
&lt;/picture&gt;
&lt;/figure&gt;
&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;To try out profiling Zinc with Parca yourself, try the following:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;
&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1
&lt;/span&gt;&lt;span class="lnt"&gt; 2
&lt;/span&gt;&lt;span class="lnt"&gt; 3
&lt;/span&gt;&lt;span class="lnt"&gt; 4
&lt;/span&gt;&lt;span class="lnt"&gt; 5
&lt;/span&gt;&lt;span class="lnt"&gt; 6
&lt;/span&gt;&lt;span class="lnt"&gt; 7
&lt;/span&gt;&lt;span class="lnt"&gt; 8
&lt;/span&gt;&lt;span class="lnt"&gt; 9
&lt;/span&gt;&lt;span class="lnt"&gt;10
&lt;/span&gt;&lt;span class="lnt"&gt;11
&lt;/span&gt;&lt;span class="lnt"&gt;12
&lt;/span&gt;&lt;span class="lnt"&gt;13
&lt;/span&gt;&lt;span class="lnt"&gt;14
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Bootstrap a Juju controller on MicroK8s&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;juju bootstrap microk8s micro
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Add a model for us to deploy into&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;juju add-model dev
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Deploy Zinc&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;juju deploy zinc-k8s --trust
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Deploy Parca&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;juju deploy parca-k8s --channel edge --trust
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Relate the two apps to configure profiling&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;juju relate parca-k8s zinc-k8s:profiling-endpoint
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;As before, if you login to the Parca dashboard you should now see Zinc as a profiling target.&lt;/p&gt;
&lt;h3 id="integrating-parca-with-the-canonical-observability-stack-1" class="relative group"&gt;Integrating Parca with the Canonical Observability Stack &lt;span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100"&gt;&lt;a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700" style="text-decoration-line: none !important;" href="#integrating-parca-with-the-canonical-observability-stack-1" aria-label="Anchor"&gt;#&lt;/a&gt;&lt;/span&gt;&lt;/h3&gt;&lt;p&gt;As a bonus step, you can now deploy Prometheus and Grafana, and use them to monitor Parca itself!&lt;/p&gt;
&lt;p&gt;Check out the asciinema recording below for a detailed walkthrough, or follow the instructions below. It assumes the starting point is the end-state of the Kubernetes walkthrough above:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://asciinema.org/a/517948" target="_blank" rel="noreferrer"&gt;
&lt;figure&gt;&lt;img src="https://asciinema.org/a/517948.svg" alt="asciicast" class="mx-auto my-0 rounded-md" /&gt;
&lt;/figure&gt;
&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Once you&amp;rsquo;re done, you can login to the Grafana instance and check the dashboard for Parca:&lt;/p&gt;
&lt;p&gt;&lt;a href="04.png"&gt;
&lt;figure&gt;
&lt;picture
class="mx-auto my-0 rounded-md"
&gt;
&lt;source
srcset="https://jnsgr.uk/2022/08/continuous-profiling-juju/04_hu_9103193b810c630b.webp 330w,https://jnsgr.uk/2022/08/continuous-profiling-juju/04_hu_b4447ad850014919.webp 660w
,https://jnsgr.uk/2022/08/continuous-profiling-juju/04_hu_1766095538fbf712.webp 1024w
,https://jnsgr.uk/2022/08/continuous-profiling-juju/04_hu_447f08761fc603ea.webp 1320w
"
sizes="100vw"
type="image/webp"
/&gt;
&lt;img
width="1835"
height="1226"
class="mx-auto my-0 rounded-md"
alt="grafana"
loading="lazy" decoding="async"
src="https://jnsgr.uk/2022/08/continuous-profiling-juju/04_hu_b6dffcc595db1a84.png" srcset="https://jnsgr.uk/2022/08/continuous-profiling-juju/04_hu_259e9354d1ff2e1e.png 330w,https://jnsgr.uk/2022/08/continuous-profiling-juju/04_hu_b6dffcc595db1a84.png 660w
,https://jnsgr.uk/2022/08/continuous-profiling-juju/04_hu_3f8eb6fadfe09d0d.png 1024w
,https://jnsgr.uk/2022/08/continuous-profiling-juju/04_hu_fa9f7c1fdc452fb9.png 1320w
"
sizes="100vw"
/&gt;
&lt;/picture&gt;
&lt;/figure&gt;
&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;To try out the COS x Parca integration yourself, try the following:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;
&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1
&lt;/span&gt;&lt;span class="lnt"&gt; 2
&lt;/span&gt;&lt;span class="lnt"&gt; 3
&lt;/span&gt;&lt;span class="lnt"&gt; 4
&lt;/span&gt;&lt;span class="lnt"&gt; 5
&lt;/span&gt;&lt;span class="lnt"&gt; 6
&lt;/span&gt;&lt;span class="lnt"&gt; 7
&lt;/span&gt;&lt;span class="lnt"&gt; 8
&lt;/span&gt;&lt;span class="lnt"&gt; 9
&lt;/span&gt;&lt;span class="lnt"&gt;10
&lt;/span&gt;&lt;span class="lnt"&gt;11
&lt;/span&gt;&lt;span class="lnt"&gt;12
&lt;/span&gt;&lt;span class="lnt"&gt;13
&lt;/span&gt;&lt;span class="lnt"&gt;14
&lt;/span&gt;&lt;span class="lnt"&gt;15
&lt;/span&gt;&lt;span class="lnt"&gt;16
&lt;/span&gt;&lt;span class="lnt"&gt;17
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Deploy Prometheus&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;juju deploy prometheus-k8s --trust --channel edge
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Deploy Grafana&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;juju deploy grafana-k8s --trust --channel edge
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Setup the relations&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;juju relate grafana-k8s:grafana-source prometheus-k8s
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;juju relate prometheus-k8s parca-k8s:metrics-endpoint
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;juju relate grafana-k8s parca-k8s
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Wait for things to settle in the Juju status output&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Get the admin password for Grafana&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;juju run-action grafana-k8s/0 get-admin-password --wait
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Now you should be able to login to the Grafana application at http://&amp;lt;app address&amp;gt;:3000&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# and see the Parca dashboard!&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;And that&amp;rsquo;s it! You&amp;rsquo;re now profiling Zinc with Parca, which is being scraped by Prometheus for metrics, and dashboarded in Grafana.&lt;/p&gt;
&lt;h2 id="conclusions" class="relative group"&gt;Conclusions &lt;span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100"&gt;&lt;a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700" style="text-decoration-line: none !important;" href="#conclusions" aria-label="Anchor"&gt;#&lt;/a&gt;&lt;/span&gt;&lt;/h2&gt;&lt;p&gt;Well, that was fun! What have we learned?&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The combination of snap packaging and Charmed Operators can make for a powerful, yet readable and maintainable set of automation for deploying applications &lt;em&gt;anywhere&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;With the proliferation of more charm libraries (particularly from the Observability team!) it&amp;rsquo;s getting easier and easier for developers to integrate pieces of the Charmed Operator ecosystem&lt;/li&gt;
&lt;li&gt;The Operator Framework makes it trivial to share code between operators designed for machines/bare-metal and Kubernetes, reducing the development time for operators&lt;/li&gt;
&lt;li&gt;Parca looks really nice&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I&amp;rsquo;m going to continue to play with Parca. I&amp;rsquo;d like to have a continuous profiling tool better integrated with Juju 3.0 so that the team, and others, can use it to help us improve the performance of Juju itself. With the introduction of the controller charm, this should be eminently feasible. We may seek one day to integrate a continuous profiling tool into the Canonical Observability Stack. If you&amp;rsquo;ve got ideas about this, or you&amp;rsquo;d like to contribute then get in touch and let&amp;rsquo;s talk about it!&lt;/p&gt;
&lt;p&gt;Additionally, this post only really explored the possibility of using the Parca Server to scrape applications that are already set up for profiling. In the future I&amp;rsquo;d like to have a go at packaging the Parca Agent, so that we can unlock that juicy host-level, eBPF powered profiling and enable you get the benefit of continuous profiling in all of your deployments, irrespective of the technologies you&amp;rsquo;re deploying with Juju.&lt;/p&gt;
&lt;h2 id="links" class="relative group"&gt;Links &lt;span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100"&gt;&lt;a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700" style="text-decoration-line: none !important;" href="#links" aria-label="Anchor"&gt;#&lt;/a&gt;&lt;/span&gt;&lt;/h2&gt;&lt;p&gt;I&amp;rsquo;ve collected some links from throughout the article for reference:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Parca - &lt;a href="https://parca.dev" target="_blank" rel="noreferrer"&gt;Homepage&lt;/a&gt; / &lt;a href="https://github.com/parca-dev/parca" target="_blank" rel="noreferrer"&gt;Github&lt;/a&gt; / &lt;a href="https://snapcraft.io/parca" target="_blank" rel="noreferrer"&gt;Snap Store&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Parca Operator - &lt;a href="https://github.com/jnsgruk/parca-operator" target="_blank" rel="noreferrer"&gt;Github&lt;/a&gt; / &lt;a href="https://charmhub.io/parca" target="_blank" rel="noreferrer"&gt;Charmhub&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Parca Kubernetes Operator - &lt;a href="https://github.com/jnsgruk/parca-k8s-operator" target="_blank" rel="noreferrer"&gt;Github&lt;/a&gt; / &lt;a href="https://charmhub.io/parca-k8s" target="_blank" rel="noreferrer"&gt;Charmhub&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item></channel></rss>