<p>I am creating a tool that will create kubernetes object using a yaml file. I am writing it in golang. The tool would like to achieve same behaviour as <code>kubectl apply -f test.yaml</code></p>

<p>Basically, the fastest is to use an existing library like the official <a href="https://github.com/kubernetes/client-go" rel="nofollow noreferrer">go client</a>.</p>

<p>In essence <a href="https://github.com/kubernetes/kubernetes/tree/master/pkg/kubectl" rel="nofollow noreferrer">kubectl</a> also uses <a href="https://github.com/kubernetes/client-go" rel="nofollow noreferrer">client-go</a> so you can also follow its source code as a guideline.</p>

<p>You can also use <a href="https://github.com/ericchiang/k8s" rel="nofollow noreferrer">k8s</a> which is another K8s go client.</p>
