Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

277
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda