kubernetes-client
kubernetes-client copied to clipboard
Unable to post in configmaps
Unable to post in configmaps
I am working on minikube
this is the minikube start command log
* minikube 1.12.3 is available! Download it: https://github.com/kubernetes/minikube/releases/tag/v1.12.3
* To disable this notice, run: 'minikube config set WantUpdateNotification false'
! minikube v1.7.3 on Ubuntu 16.04
* Using the virtualbox driver based on existing profile
* Reconfiguring existing host ...
* Starting existing virtualbox VM for "minikube" ...
* Preparing Kubernetes v1.17.3 on Docker 19.03.6 ...
* Launching Kubernetes ...
* Enabling addons: default-storageclass, storage-provisioner
* Done! kubectl is now configured to use "minikube"
this is my config.json
{
"apiVersion": "v1",
"kind": "ConfigMap",
"metadata": {
"name": "corredor-config",
"namespace": "default"
},
"data": {
"CORREDOR_LISTENER": "0.0.0.0:80",
"CORREDOR_ENV": "prod",
"CORREDOR_LOG_ENABLED": "true",
"CORREDOR_LOG_LEVEL": "debug",
"CORREDOR_LOG_PRETTY": "true"
}
}
this is my index.js file
const Client = require('kubernetes-client').Client
const { KubeConfig } = require('kubernetes-client')
const kubeconfig = new KubeConfig()
kubeconfig.loadFromFile('/home/software/.kube/config')
const Request = require('kubernetes-client/backends/request')
const backend = new Request({ kubeconfig })
const client = new Client({ backend, version: '1.13' })
async function main() {
const namespaces = await client.api.v1.namespaces.get()
// ------------- Config -------------
// create corredor
const configCorredor = require('./config/corredor.json')
create = await client.apis.apps.v1.namespaces('default').configmaps.post({ body: configCorredor }).catch((err)=>{
console.log("Corredor Config err:", err);
});
}
main()
this is the error
(node:21122) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'post' of undefined
at main (/var/www/corteza/corteza-local/kubeclient/index.js:21:72)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
(node:21122) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:21122) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
please help me