<p>I'm trying to add a custom function In Go template for parsing the time in PodStatus and getting the absolute time for it.</p>
<p>Example for the custom function:</p>
<pre><code>PodScheduled, _ := time.Parse(time.RFC3339, &quot;2021-12- 23T20:20:36Z&quot;)
Ready, _ := time.Parse(time.RFC3339, &quot;2021-12-31T07:36:11Z&quot;)

difference := Ready.Sub(PodScheduled)
fmt.Printf(&quot;difference = %v\n&quot;, difference)
</code></pre>
<p>I can use the built-in functions.</p>
<p>How I can use a custom function with the kubectl?</p>
<p>For example this lib:
<a href="https://github.com/Masterminds/sprig" rel="nofollow noreferrer">https://github.com/Masterminds/sprig</a></p>
<p>Thanks :)</p>

<p>IIUC you have (at least) 3 options:</p>
<ol>
<li>Discouraged: Write your own client (instead of <code>kubectl</code>) that provides the functionality;</li>
<li>Encouraged: Use the shell to post-process the output from e.g. <code>kubectl get pods --output=json</code>) by piping the result through:
<ul>
<li>Either your Golang binary that reads from standard input</li>
<li>Or better a general-purpose JSON processing tool like <a href="https://stedolan.github.io/jq/" rel="nofollow noreferrer"><code>jq</code></a> that would do this (and much more!)</li>
</ul>
</li>
<li>For completeness, <code>kubectl</code> supports output formatting (<code>--output=jsonpath...</code>); although <a href="https://kubernetes.io/docs/reference/kubectl/jsonpath/" rel="nofollow noreferrer"><code>JSONPath</code></a> may be insufficient for this need;</li>
</ol>
<p>See jq's documentation for <a href="https://stedolan.github.io/jq/manual/#Dates" rel="nofollow noreferrer">Dates</a></p>
