<p>I am trying to create a deployment or replicaSet with the Kubernetes Javascript client. The Kubernetes javascript client documentation is virtually non-existent.</p>
<p>Is there any way to achieve this?</p>

Paschal
<p>Assuming that by:</p>
<ul>
<li><code>createDeployment()</code></li>
<li>you are referring to: <code>createNamespacedDeployment()</code></li>
</ul>
<p>You can use below code snippet to create a <code>Deployment</code> using Javascript client library:</p>
<pre class="lang-js prettyprint-override"><code>const k8s = require('@kubernetes/client-node');

const kc = new k8s.KubeConfig();
kc.loadFromDefault();

const k8sApi = kc.makeApiClient(k8s.AppsV1Api); // &lt;-- notice the AppsV1Api

// Definition of the deployment
var amazingDeployment = {
    metadata: {
       name: 'nginx-deployment'
    },
    spec: {
       selector: {
          matchLabels: {
             app: 'nginx'
          }
       },
       replicas: 3,
       template: {
          metadata: {
             labels: {
                app: 'nginx'
             }
          },
          spec: {
             containers: [
                {
                   name: 'nginx',
                   image: 'nginx'
                   
                } ]
          }
       }
    }
 };

// Sending the request to the API
k8sApi.createNamespacedDeployment('default', amazingDeployment).then(
  (response) =&gt; {
    console.log('Yay! \nYou spawned: ' + amazingDeployment.metadata.name);
  },
  (err) =&gt; {
    console.log('Oh no. Something went wrong :(');
    // console.log(err) &lt;-- Get the full output!
  }
);
</code></pre>
<blockquote>
<p>Disclaimer!</p>
<p>This code assumes that you have your <code>~/.kube/config</code> already configured!</p>
</blockquote>
<p>Running this code for the first time with:</p>
<ul>
<li><code>$ node deploy.js</code></li>
</ul>
<p>should output:</p>
<pre class="lang-sh prettyprint-override"><code>Yay! 
You spawned: nginx-deployment
</code></pre>
<p>You can check if the <code>Deployment</code> exists by:</p>
<ul>
<li><code>$ kubectl get deployment nginx-deployment</code></li>
</ul>
<pre class="lang-sh prettyprint-override"><code>NAME               READY   UP-TO-DATE   AVAILABLE   AGE
nginx-deployment   3/3     3            3           6m57s
</code></pre>
<p>Running this code once again will output (deployment already exists!):</p>
<pre class="lang-sh prettyprint-override"><code>Oh no. Something went wrong :(
</code></pre>
<hr />
<p>Additional resources:</p>
<ul>
<li><em><a href="https://github.com/kubernetes-client/javascript" rel="nofollow noreferrer">Github.com: Kubernetes-client: Javascript</a></em></li>
</ul>
