Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

275
Views
Cannot read properties of undefined (reading 'KubeConfig') while using library @kubernetes/client-nde

I am working on a NextJS project to create a Kubernetes Job. To create a Job on minikube, I am using config.yaml that is generally generated whenever we start the minikube. So I am using the same file to make connection with Kubernetes API. Now to make connection with kubernetes(minikube), I am using following code:

import k8s from "@kubernetes/client-node";

let kubeAPI = null;

const createKubeAPI = async () => {
  const kc = new k8s.KubeConfig();
  const path = "../config/k8sConfig.yaml";
  console.log(path);
  kc.loadFromFile(path);

  const k8sApi = kc.makeApiClient(k8s.BatchV1Api);

  return k8sApi;
};

export const get = () => kubeAPI;

export const create = async () => {
  kubeAPI = await createKubeAPI();
};

And in another .js file, by using the function created in the above code creating a new job or displaying the running the jobs.

But when running above code, it is showing the error. Complete error looks like:

event - compiled client and server successfully in 7.4s (224 modules)
null
error - utils\kube-utils\kubeClient.js (6:17) @ createKubeAPI
TypeError: Cannot read properties of undefined (reading 'KubeConfig')
  4 | 
  5 | const createKubeAPI = async () => {
> 6 |   const kc = new k8s.KubeConfig();
    |                 ^
  7 |   // kc.loadFromDefault();
  8 |   const path = "../config/k8sConfig.yaml";
  9 |   console.log(path);

Can someone help me or guide me, what am I doing wrong here?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

It seems there is no default export, so when using ES6 module imports, you need to either use named imports:

import { KubeConfig, CoreV1Api } from '@kubernetes/client-node';

or import everything:

import * as k8s from '@kubernetes/client-node';

new k8s.KubeConfig();
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!