node-k8s-client icon indicating copy to clipboard operation
node-k8s-client copied to clipboard

Does the post accept yaml manifest file ?

Open lakshmantgld opened this issue 8 years ago • 4 comments

Thank you for your hard work. I have a question related to creating a pod using KubeAPI.

I am trying to create a pod using the following snippet:

var K8s = require('k8s');

var kubeapi = K8s.api({
  "endpoint": "https://***.**.**.**",
  "version": "/api/v1",
  "auth": {
    "clientCert": Buffer.from(clientCert, 'base64'),
    "clientKey": Buffer.from(clientKey, 'base64'),
    "caCert": Buffer.from(caCert, 'base64')
  }
});

  kubeapi.post("namespaces/default/pods", require("./podUbuntuManifest.yaml"), function(err, data){
    console.log("Create namespaces/default/pods");

    if (err) {
      console.log("error in namespaces/default/nodes");
      console.log(err);
    }

    console.log("printing success data of create namespaces/default/nodes");
    console.log(JSON.stringify(data));
  });

I get a ReferenceError in Yaml. But the yaml syntax is ok, I have verified with an online yamlLint. Only JSON is supported?

Can you provide an detailed example for creating a pod using the kubeApi?.

lakshmantgld avatar May 12 '17 06:05 lakshmantgld

Can you post the the detail of error?

shenshouer avatar May 12 '17 13:05 shenshouer

@junjun16818 is there any example for create pod via the api or in the test ?

shenshouer avatar May 12 '17 13:05 shenshouer

@shenshouer I changed the manifest to JSON and it worked.

lakshmantgld avatar May 15 '17 08:05 lakshmantgld

@lakshmantgld do you have any example of how you configured your client? the me returns an error when I run a get in the pods pod:the server doesn't have the resource type "pods", and also to a get in the nodes nod:pod:the server doesn't have the resource type "pods". I've tried various forms

Isaacs9 avatar May 18 '17 16:05 Isaacs9