英文:
Is there any command that points me to the kubeconfig file in k8s/openshift
问题
有没有命令可以指示我 kubeconfig 文件的路径在哪里?
我的意思是,我正在使用 Python 的 Kubernetes/OpenShift 客户端。我正在寻找能够打印 kubeconfig 文件所在路径的 Linux 或 Python 命令或库。
默认情况下,kubeconfig 大多数时候位于主目录中,但对于不同的部署类型可能会有所不同。
期待任何建议或关注。
英文:
Is there any command which points me to the path where kubeconfig file is present?
I mean I am working on python k8s/openshift client. I am looking for linux or python command or libraries which can print me the path where kubeconfig file is present.
By default kubeconfig is present it home most of the time, but it may also vary for different deployment types.
looking forward to any suggestions/concerns.
答案1
得分: 1
kubectl配置文件默认位于~/.kube/config。您可以使用以下代码进行检查:
kubeconfig_path = os.environ.get('KUBECONFIG', '~/.kube/config')
您可以检查变量是否已设置:
kubeconfig_path = os.environ['KUBECONFIG']
如果没有设置,您可以尝试设置如下:
os.environ["KUBECONFIG"]=您的配置文件路径
英文:
kubectl configuration file is located at ~/. kube/config as default. You can check using this code
kubeconfig_path = os.environ.get('KUBECONFIG', '~/.kube/config')
You can check if the variable is set
kubeconfig_path = os.environ['KUBECONFIG']
and if it's not you can try setting this
os.environ["KUBECONFIG"]=your_config_file_path
答案2
得分: 1
我使用安装程序来安装K8的集群。
在我的情况下,它可以在oauth文件夹下找到。(我不确定完整的正确路径),但你可以查看你的K8文件夹结构。
或者在Linux中使用find命令来定位文件。
类似这样:find / -type f -name '*.kubeconfig'
英文:
I used an installer to install the K8's cluster.
In my case, it is to be found under oauth folder. (I am not sure about the full correct path) but you can take a look in your k8's folder structure.
Or use the command find in linux to locate the file.
something like: find / -type f -name '*.kubeconfig'
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论