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

537
Vistas
Can not find kubeconfig file

I am trying to access a remote kubernetes cluster with kubectl. In order to copy/paste cluster credentials in the kubeconfig file I tried to access with "~/.kube/config" command but there is an error saying "No such file or directory".

Could anyone please tell me why i get this error? kubectl is perfectly working.

over 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

If your kubectl works correctly against your cluster than the /kube/config file should be there.

You can check the location of the file with increasing verbosity level when launching the command:

➜  ~ kubectl get pods -v=6

...] Config loaded from file:  /home/thomas/.kube/config ◄ ◄ ◄ ◄ ◄
...] Starting client certificate rotation controller
...] GET https://172.17.0.4:8443/api/v1/namespaces/default/pods?limit=500 200 OK in 11 milliseconds

There is workaround that enables you to generate the config with kubectl config view --flatten:

--flatten[=false]: flatten the resulting kubeconfig file into self contained output (useful for creating portable kubeconfig files)

There is also possibility that while boostraping your cluster with kubeadm you did not move the files accordingly to the instructions (:

  • To make kubectl work for your non-root user, run these commands, which are also part of the kubeadm init output:

    mkdir -p $HOME/.kube
    sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
    sudo chown $(id -u):$(id -g) $HOME/.kube/config
    
  • Alternatively, if you are the root user, you can run:

    export KUBECONFIG=/etc/kubernetes/admin.conf
    

If you used kubectl with sudo you will be using kube/config from your root path.


For more reading please have a look at these:

  1. Configuration/Organizing Cluster Access Using kubeconfig Files
  2. Configuration/Organizing Cluster Access Using kubeconfig Files
  3. Mastering-kubeconfig
over 4 years ago · Santiago Trujillo Denunciar

0

In my case I had KUBECONFIG variable set to "~/.kube/config" in .bashrc. The file existed & had correct permissions yet it wasn't being resolved somehow. Turned out I had to use ${HOME} in place of ~. That did the trick.

over 4 years ago · Santiago Trujillo Denunciar

0

to solve this issue you need first to create a cluster in your workstation. This would generate the KUBECONFIG variable set to "~/.kube/config" directory.

Or you can use --kubeconfig + path to your kubeconfig file with

over 4 years ago · Santiago Trujillo 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