<p>Using the <a href="https://github.com/operator-framework/operator-sdk" rel="nofollow noreferrer">Operator-sdk</a> I deploy a CR that has a Job with a pod. CR has a Status struct something like below</p>
<pre class="lang-golang prettyprint-override"><code>type CRStatus struct {
    TestStatus string `json:&quot;testStatus&quot;`
    TestCount int `json:&quot;testCount&quot;`
}
</code></pre>
<p>The Pod does some processing and prints output TestStatus and TestCount values. How can operator-sdk controller update CR's TestStatus and TestCount fields with values from Pod output of the job?</p>

<p>You can start by creating a controller (you might have already):</p>
<pre><code>operator-sdk add controller --api-version=example.com/v1alpha1 --kind=YourCRApp
</code></pre>
<p>Then in the implementation, you will want to make use of the Kubernetes Informers/SharedInformers by adding an <code>AddEventHandler</code> call to see if any value has changed on any Kubernetes resource. You can find a sample controller in <a href="https://github.com/kubernetes/sample-controller/blob/release-1.18/controller.go" rel="nofollow noreferrer">Kubernetes source code</a>. Also, there are many resources available online that can guide you on how to create the controller and make use of Informers, here are some examples:</p>
<ul>
<li><a href="https://gianarb.it/blog/kubernetes-shared-informer" rel="nofollow noreferrer">https://gianarb.it/blog/kubernetes-shared-informer</a></li>
<li><a href="https://www.firehydrant.io/blog/stay-informed-with-kubernetes-informers/" rel="nofollow noreferrer">https://www.firehydrant.io/blog/stay-informed-with-kubernetes-informers/</a></li>
<li><a href="https://linuxera.org/writing-operators-using-operator-framework/" rel="nofollow noreferrer">https://linuxera.org/writing-operators-using-operator-framework/</a></li>
</ul>
