<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Build a Custom Scenario on Krkn</title><link>https://krkn-chaos.dev/docs/developers-guide/custom-scenario/</link><description>Recent content in Build a Custom Scenario on Krkn</description><generator>Hugo</generator><language>en</language><atom:link href="https://krkn-chaos.dev/docs/developers-guide/custom-scenario/index.xml" rel="self" type="application/rss+xml"/><item><title>Implement the Plugin</title><link>https://krkn-chaos.dev/docs/developers-guide/custom-scenario/implement-plugin/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://krkn-chaos.dev/docs/developers-guide/custom-scenario/implement-plugin/</guid><description>&lt;p>&lt;strong>Starting point:&lt;/strong> complete the &lt;a href="https://krkn-chaos.dev/docs/developers-guide/custom-scenario/#prepare-the-workspace">workspace setup&lt;/a>.
&lt;strong>Result:&lt;/strong> a concrete plugin class that Krkn can discover and execute.&lt;/p>
&lt;h2 id="read-the-prepared-behavior">
 Read the prepared behavior
 &lt;a class="td-heading-self-link" href="#read-the-prepared-behavior" aria-label="Heading self-link">&lt;/a>
&lt;/h2>
&lt;p>Open &lt;code>$KRKN_DEV_PLUGIN_DIR/dev_demo_scenario_plugin.py&lt;/code>. Its
&lt;code>DevDemoScenarioPlugin&lt;/code> class already implements &lt;code>execute_demo(scenario, lib_telemetry)&lt;/code>. The method:&lt;/p>
&lt;ol>
&lt;li>Reads the YAML file identified by &lt;code>scenario&lt;/code>.&lt;/li>
&lt;li>Requires &lt;code>wait&lt;/code> to be an integer from &lt;code>0&lt;/code> to &lt;code>60&lt;/code>, and &lt;code>namespace&lt;/code> to be a
nonempty string. A YAML boolean is not accepted as an integer.&lt;/li>
&lt;li>Sleeps for the requested duration.&lt;/li>
&lt;li>Obtains the Kubernetes helper from &lt;code>lib_telemetry&lt;/code> and checks namespace
existence with &lt;code>list_namespaces()&lt;/code>.&lt;/li>
&lt;li>Lists pods with &lt;code>list_pods(namespace)&lt;/code> and logs a distinctive banner.&lt;/li>
&lt;li>Returns &lt;code>0&lt;/code> on success and &lt;code>1&lt;/code> on a missing namespace or another failure.&lt;/li>
&lt;/ol>
&lt;p>The input file is intentionally small:&lt;/p></description></item><item><title>Package and Test the Image</title><link>https://krkn-chaos.dev/docs/developers-guide/custom-scenario/package-and-test/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://krkn-chaos.dev/docs/developers-guide/custom-scenario/package-and-test/</guid><description>&lt;p>&lt;strong>Starting point:&lt;/strong> the &lt;a href="https://krkn-chaos.dev/docs/developers-guide/custom-scenario/implement-plugin/">plugin methods are implemented&lt;/a>.
&lt;strong>Result:&lt;/strong> a locally tested image that clients can discover through its labels.&lt;/p>
&lt;h2 id="build-the-custom-krkn-base">
 Build the custom Krkn base
 &lt;a class="td-heading-self-link" href="#build-the-custom-krkn-base" aria-label="Heading self-link">&lt;/a>
&lt;/h2>
&lt;p>&lt;code>Dockerfile.base&lt;/code> overlays the local Python package on the published runtime:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-dockerfile" data-lang="dockerfile">&lt;span class="line">&lt;span class="cl">&lt;span class="k">FROM&lt;/span>&lt;span class="s"> quay.io/krkn-chaos/krkn:latest&lt;/span>&lt;span class="err">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="err">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="err">&lt;/span>&lt;span class="k">COPY&lt;/span> --chown&lt;span class="o">=&lt;/span>krkn:krkn __init__.py &lt;span class="se">\
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="se">&lt;/span> /home/krkn/kraken/krkn/scenario_plugins/dev_demo/__init__.py&lt;span class="err">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="err">&lt;/span>&lt;span class="k">COPY&lt;/span> --chown&lt;span class="o">=&lt;/span>krkn:krkn dev_demo_scenario_plugin.py &lt;span class="se">\
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="se">&lt;/span> /home/krkn/kraken/krkn/scenario_plugins/dev_demo/dev_demo_scenario_plugin.py&lt;span class="err">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">podman build &lt;span class="se">\
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="se">&lt;/span> -f &lt;span class="s2">&amp;#34;&lt;/span>&lt;span class="nv">$KRKN_DEV_PLUGIN_DIR&lt;/span>&lt;span class="s2">/Dockerfile.base&amp;#34;&lt;/span> &lt;span class="se">\
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="se">&lt;/span> -t &lt;span class="s2">&amp;#34;&lt;/span>&lt;span class="nv">$KRKN_BASE_IMAGE&lt;/span>&lt;span class="s2">&amp;#34;&lt;/span> &lt;span class="se">\
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="se">&lt;/span> &lt;span class="s2">&amp;#34;&lt;/span>&lt;span class="nv">$KRKN_DEV_PLUGIN_DIR&lt;/span>&lt;span class="s2">&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>

&lt;div class="alert alert-info" role="alert">
&lt;h4 class="alert-heading">Tip: Dockerfile path and build context are different&lt;/h4>

 &lt;code>-f&lt;/code> selects the Dockerfile; the final argument selects the directory available
to its &lt;code>COPY&lt;/code> instructions. &lt;code>-t&lt;/code> assigns a local image name. Keeping both paths
absolute makes this command work from any directory. Nothing is pushed to a
registry at this stage.

&lt;/div>

&lt;p>This build context is the plugin repository. Using Krkn&amp;rsquo;s upstream container
Dockerfile unchanged would clone Krkn from GitHub during the build and omit the
local plugin. If you change the core engine or &lt;code>krkn-lib&lt;/code>, build a runtime that
includes those changes explicitly.&lt;/p></description></item><item><title>Publish and Run with Krkn Operator</title><link>https://krkn-chaos.dev/docs/developers-guide/custom-scenario/operator-lab/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://krkn-chaos.dev/docs/developers-guide/custom-scenario/operator-lab/</guid><description>&lt;p>&lt;strong>Starting point:&lt;/strong> the &lt;a href="https://krkn-chaos.dev/docs/developers-guide/custom-scenario/package-and-test/">scenario image passes its local tests&lt;/a>.
&lt;strong>Result:&lt;/strong> the operator discovers the image, renders its two inputs, and runs
it against a target you have already registered.&lt;/p>
&lt;p>The management cluster hosts the registry, operator, and scenario Pods. The
target&amp;rsquo;s kubeconfig is mounted into each scenario Pod. You do not need to place
the private registry on the target or configure the target&amp;rsquo;s runtime to pull
this scenario image.&lt;/p>
&lt;figure>&lt;a href="https://krkn-chaos.dev/images/developers-guide/registry-access.svg">&lt;img src="https://krkn-chaos.dev/images/developers-guide/registry-access.svg"
 alt="Podman pushes to localhost port 5001, which maps to the Kind registry NodePort 30500. Inside Kind, the operator reads metadata and containerd pulls image layers through separate HTTP connections to the stable node hostname. The scenario Pod then uses a mounted kubeconfig to reach the target API.">&lt;/a>&lt;figcaption>
 &lt;p>One registry, two client configurations. Select the diagram to view it at full size.&lt;/p></description></item><item><title>Troubleshooting the Demo</title><link>https://krkn-chaos.dev/docs/developers-guide/custom-scenario/troubleshooting/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://krkn-chaos.dev/docs/developers-guide/custom-scenario/troubleshooting/</guid><description>&lt;p>First determine whether the scenario was discovered, whether its image was
pulled, and whether its process started. These are separate checkpoints.
Kubernetes events explain scheduling and pull failures; container logs explain
startup and plugin failures.&lt;/p>
&lt;h2 id="the-scenario-is-visible-but-the-pull-attempts-https">
 The scenario is visible, but the pull attempts HTTPS
 &lt;a class="td-heading-self-link" href="#the-scenario-is-visible-but-the-pull-attempts-https" aria-label="Heading self-link">&lt;/a>
&lt;/h2>
&lt;p>Typical event:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-text" data-lang="text">&lt;span class="line">&lt;span class="cl">http: server gave HTTP response to HTTPS client
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>The operator&amp;rsquo;s registry client successfully used HTTP to list metadata. Kubelet
then asked containerd to pull the image, and containerd defaulted to HTTPS.
Krknctl&amp;rsquo;s &lt;code>insecure&lt;/code> setting does not configure the node runtime.&lt;/p></description></item></channel></rss>