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.
Rancher Kubernetes Engine(RKE)文档引用了一个运行 RKE 后生成的文件 kube_config_cluster.yml,本文解释了该文件是什么以及如何使用。

Pre-requisites  先决条件
  • A Rancher Kubernetes Engine (RKE) CLI provisioned Kubernetes cluster
    A Rancher Kubernetes Engine (RKE) CLI provisioned Kubernetes cluster
  • kubectl installed  Kubectl 安装
Answer  答案

When you provision a Kubernetes cluster using RKE, a kubeconfig file is automatically generated for your cluster.
当你用 RKE 配置 Kubernetes 集群时,会自动生成一个 kubeconfig 文件。

This file is created and saved by default as kube_config_cluster.yml.
该文件默认以 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.
文件名可以更改以区分其他 Kubeconfig 文件,例如生产集群的文件可以命名为 kube_config_prod.yml
This kubeconfig defines the authentication details to access and interact with your cluster, using tools such as kubectl.
这个 kubeconfig 定义了访问和交互集群的认证细节,使用如 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 会检查 ~/.kube/config 中的 kubeconfig 文件,但你也可以使用 --kubeconfig 标志指定不同的 kubeconfig 文件。例如:

<span style="color:#000000"><span style="background-color:#ffffff"><code class="language-bash">kubectl --kubeconfig /custom/path/rke/kube_config_cluster.yml get pods</code></span></span>

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:
或者你可以把配置路径导出到 KUBECONFIG 环境变量里,这样就不用每次运行 kubectl 都指定 --kubeconfig 标志:

<span style="color:#000000"><span style="background-color:#ffffff"><code class="language-bash">export KUBECONFIG="/custom/path/rke/kube_config_cluster.yml"</code></span></span>
Further Reading  延伸阅读

访问Rancher-K8S解决方案博主,企业合作伙伴 :
https://blog.csdn.net/lidw2009

更多推荐