<p>I started a pod in kubernetes cluster which can call kubernetes api via go-sdk (like in this example: <a href="https://github.com/kubernetes/client-go/tree/master/examples/in-cluster-client-configuration" rel="nofollow noreferrer">https://github.com/kubernetes/client-go/tree/master/examples/in-cluster-client-configuration</a>). I want to listen some external events in this pod (e.g. GitHub web-hooks), fetch <code>yaml</code> configuration files from repository and apply them to this cluster.</p>

<p>Is it possible to call <code>kubectl apply -f &lt;config-file&gt;</code> via kubernetes API (or better via golang SDK)?</p>

Kirill
<p>As yaml directly: no, not that I'm aware of. But if you increase the <code>kubectl</code> verbosity (<code>--v=100</code> or such), you'll see that the first thing <code>kubectl</code> does to your yaml file is convert it to json, and then <code>POST</code> <em>that</em> content to the API. So the spirit of the answer to your question is "yes."</p>

<p>This <a href="https://github.com/box/kube-applier#readme" rel="nofollow noreferrer">box/kube-applier</a> project may interest you. While it does not appear to be webhook aware, I am sure they would welcome a PR teaching it to do that. Using their existing project also means you benefit from all the bugs they have already squashed, as well as their nifty prometheus metrics integration.</p>
