<p>Is there a possibility to deploy a <strong>kubernetes Pod</strong> using <strong>golang</strong> code instead of command line Linux with <strong>kubectl</strong> ?</p>

<p>Yes. Definitely you can. Kubernetes is written in golang. It has official client for go. You can create,delete,patch,list, control almost any Kubernetes resources with this go client.</p>

<p>Here is the official client repository: <a href="https://github.com/kubernetes/client-go" rel="noreferrer">kubernetes/client-go</a></p>

<p>I have create a sample repository <a href="https://github.com/hossainemruz/k8s-client-go-practice" rel="noreferrer">here</a> to show how to create a pod using <code>client-go</code>.</p>

<p>You have to do following things to create a pod with this client. We are going to create a simple busybox pod.</p>

<ol>
<li>Create <code>configuration</code> using your kube-config file. Generally the configuration file is <code>$HOME/.kube/config</code> file. See example <a href="https://github.com/hossainemruz/k8s-client-go-practice/blob/56eeb12f1ce54d3fe4d428e7546d70cd5bde3b50/main.go#L26" rel="noreferrer">here</a>. </li>
<li>Create a <code>clientset</code> using this <code>configuration</code>. See example <a href="https://github.com/hossainemruz/k8s-client-go-practice/blob/56eeb12f1ce54d3fe4d428e7546d70cd5bde3b50/main.go#L31" rel="noreferrer">here</a>.</li>
<li>Now, generate a pod definition that we want to deploy. See example <a href="https://github.com/hossainemruz/k8s-client-go-practice/blob/56eeb12f1ce54d3fe4d428e7546d70cd5bde3b50/main.go#L37" rel="noreferrer">here</a>.</li>
<li>Finally, create the pod in kubernetes cluster using the <code>clientset</code>. See example <a href="https://github.com/hossainemruz/k8s-client-go-practice/blob/56eeb12f1ce54d3fe4d428e7546d70cd5bde3b50/main.go#L40" rel="noreferrer">here</a>.</li>
</ol>
