大网数据广告活动
服务器运维问答

kubernetes client-go plugin exec command not found on Windows 10

· 52CE 我爱测

Our client's core team uses kubeconfig with client-go authentication executing a python script to get token. They all use Macs. I use Windows with mingw64. No matter how I try to specify path to that script: forward slashes with …

问题原文

原帖链接 · Divijan · CC BY-SA 4.0

Our client's core team uses kubeconfig with client-go authentication executing a python script to get token. They all use Macs. I use Windows with mingw64. No matter how I try to specify path to that script: forward slashes with drive letter between slashes or classic Windows style (even though it is present in PATH), even if I put the script into the same directory as kube config file and don't specify any path, I get Unable to connect to the server: getting credentials: exec: executable <our script name> not found. I can execute this script without specifying path to it from CLI just fine. I'm just trying to kubectl get pods. Relevant user: snippet:

- name: someName
  user:
    exec:
      apiVersion: client.authentication.k8s.io/v1beta1
      args:
      - --creds
      - '%userprofile%\path\to\credentials.properties'
      command: path\to\script
      env: null

Question: how to specify executable in exec section of kubeconfig in Windows?

已采纳解答

原帖链接 · Divijan · CC BY-SA 4.0

There is little documentation on using kubeconfig under Windows, so with a lot trial and error and a little help from @mdaniel's comment I came up with the following solution:

I created a Windows batch file that contains one line: @python <path-to-script> %* and referenced that file with full path in command: under exec:.

I had to use %* because python script takes parameters.

@ prevents Windows from echoing this command in console when running batch.

I couldn't do command: <path-to-python>\python <path-to-script> because kubernetes still complained it couldn't find the executable with such name.

Also, as a side note, if you use Windows environment variables like %userprofile% in kubeconfig, they need to be referenced inside single quotes.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2020-12-30)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。