godaddy / godaddy/kubernetes-client

Unable to post in configmaps

Open
#667 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
963
Forks
189
PR merge metrics
No merged PRs in 30d

Description

# 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

Contributor guide

Open the contributing guide

Research direction

Start with index.js and the client API path used for the ConfigMap request; compare that path with the kubernetes-client API structure and the Kubernetes version shown in the issue. Check config/corredor.json as the request body. Done means the request reaches a defined client resource and posts the ConfigMap without the undefined-property error.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, kubernetes, node.js
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.