<p>How can I create a Pod using REST API ?  </p>

<p>I checked the Kubernetes API documentation:<br>
<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.10/#-strong-write-operations-strong--54" rel="noreferrer">https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.10/#-strong-write-operations-strong--54</a>  </p>

<p>They are writing that need to use POST request:<br>
<code>POST /api/v1/namespaces/{namespace}/pods</code>  </p>

<p>I have this YAML of simple nginx pod:  </p>

<pre><code>cat &gt; nginx-pod.yaml &lt;&lt;EOF
apiVersion: v1
kind: Pod
metadata:
  name: nginx1
spec:
  containers:
  - name: nginx
    image: nginx:1.7.9
    ports:
    - containerPort: 80
EOF
</code></pre>

<p>Need to translate the YAML file to JSON file:  </p>

<pre><code>cat &gt; nginx-pod.json &lt;&lt;EOF
{
    "apiVersion": "v1",
    "kind": "Pod",
    "metadata": {
        "name": "nginx1"
    },
    "spec": {
        "containers": [
            {
                "name": "nginx",
                "image": "nginx:1.7.9",
                "ports": [
                    {
                        "containerPort": 80
                    }
                ]
            }
        ]
    }
}
EOF
</code></pre>

<p>Use the curl command like that:  </p>

<pre><code>curl -k -v -X POST -H "Authorization: Bearer &lt;JWT_TOKEN&gt;" -H "Content-Type: application/json" https://127.0.0.1:6443/api/v1/namespaces/default/pods -d@nginx-pod.json  
</code></pre>

<p>Of course, the token you are using should have permissions to create pod.  </p>

<p>If someone has a way to do it without converting to JSON, please share.    </p>
