<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Libraries on Krkn</title><link>https://krkn-chaos.dev/tags/libraries/</link><description>Recent content in Libraries on Krkn</description><generator>Hugo</generator><language>en</language><atom:link href="https://krkn-chaos.dev/tags/libraries/index.xml" rel="self" type="application/rss+xml"/><item><title>Using and Extending Krkn-lib</title><link>https://krkn-chaos.dev/docs/developers-guide/krkn-lib/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://krkn-chaos.dev/docs/developers-guide/krkn-lib/</guid><description>&lt;p>&lt;code>krkn-lib&lt;/code> provides the Kubernetes, OpenShift, telemetry, metrics, and data-model
building blocks used by Krkn scenarios. Prefer its existing helpers for cluster
operations so scenarios share authentication, behavior, and testable interfaces.&lt;/p>
&lt;h2 id="use-the-client-supplied-to-the-plugin">
 Use the client supplied to the plugin
 &lt;a class="td-heading-self-link" href="#use-the-client-supplied-to-the-plugin" aria-label="Heading self-link">&lt;/a>
&lt;/h2>
&lt;p>Krkn passes a &lt;code>KrknTelemetryOpenshift&lt;/code> instance as &lt;code>lib_telemetry&lt;/code> to &lt;code>run()&lt;/code>.
Obtain the Kubernetes helper from it:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-python" data-lang="python">&lt;span class="line">&lt;span class="cl"> &lt;span class="n">kubernetes&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">lib_telemetry&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">get_lib_kubernetes&lt;/span>&lt;span class="p">()&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">namespaces&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">kubernetes&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">list_namespaces&lt;/span>&lt;span class="p">()&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">pods&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">kubernetes&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">list_pods&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">namespace&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>For OpenShift-specific operations, use &lt;code>lib_telemetry.get_lib_ocp()&lt;/code> and the
methods documented for the installed library version. The wrapper has already
been initialized for the run; creating another client with a separately loaded
kubeconfig can make the plugin act on the wrong cluster.&lt;/p></description></item></channel></rss>