【发布时间】:2020-01-12 10:06:38
【问题描述】:
我需要在我的 kubeconfig 文件中使用一个环境变量来指向 Kubernetes API 服务器的 NODE_IP。
我的配置是:
apiVersion: v1
clusters:
- cluster:
insecure-skip-tls-verify: true
server: https://$NODE_IP:6443
name: docker-for-desktop-cluster
contexts:
- context:
cluster: docker-for-desktop-cluster
user: docker-for-desktop
name: docker-for-desktop
current-context: docker-for-desktop
kind: Config
preferences: {}
users:
- name: docker-for-desktop
user:
......
但是当我运行命令时,kubeconfig 文件似乎没有得到渲染变量:
kubectl --kubeconfig mykubeConfigFile get pods.
它抱怨如下:
无法连接到服务器:dial tcp:lookup $NODE_IP: no such host
有没有人尝试过这样的事情,或者是否有可能让它发挥作用?
提前致谢
【问题讨论】:
-
你可以做
kubectl --kubeconfig mykubeConfigFile --server "https://${NODE_IP}:6443" get pods。阅读有关 kubeconfig 的更多信息here -
@Amit 非常感谢回复和编辑我的帖子,但我认为 helm 不支持 --server 选项。我在下面分享了我的 helm 命令输出。错误:未知标志:--server 但无论如何我不知道发生了什么,但我的问题已解决。我可以使用默认的 kubeconfig 配置在 pod 中上传 helmchart。所以无论如何我都不必传递新的 kubeconfig 文件。
标签: kubernetes yaml kubeconfig