Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

276
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda