Goyoo / node-k8s-client

kubernetes client of node.js
MIT License
164 stars 59 forks source link

Does the post accept yaml manifest file ? #38

Open lakshmantgld opened 7 years ago

lakshmantgld commented 7 years ago

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?.

shenshouer commented 7 years ago

Can you post the the detail of error?

shenshouer commented 7 years ago

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

lakshmantgld commented 7 years ago

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

Isaacs9 commented 7 years ago

@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