Skip to content

What is the kube_config_cluster.yml file that is created after provisioning a cluster with the Rancher Kubernetes Engine (RKE) CLI?

Article Number: 000020139

Situation

Question

The Rancher Kubernetes Engine (RKE) documentation references a file kube_config_cluster.yml that is generated after running rke up, this article explains what this file is and how to use it.

Pre-requisites

  • A Rancher Kubernetes Engine (RKE) CLI provisioned Kubernetes cluster
  • kubectl installed

Answer

When you provision a Kubernetes cluster using RKE, a kubeconfig file is automatically generated for your cluster.

This file is created and saved by default as kube_config_cluster.yml.
The filename can be changed to differentiate between other Kubeconfig files e.g. a prod cluster can have its file named as kube_config_prod.yml.
This kubeconfig defines the authentication details to access and interact with your cluster, using tools such as kubectl.

By default, kubectl checks ~/.kube/config for a kubeconfig file, but you can specify a different kubeconfig file using the --kubeconfig flag. For example:

kubectl --kubeconfig /custom/path/rke/kube_config_cluster.yml get pods

Or you can export the config path into the KUBECONFIG environment variable, removing the requirement to specify the --kubeconfig flag each time you run kubectl:

export KUBECONFIG="/custom/path/rke/kube_config_cluster.yml"

Further Reading