Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

antctl.exe fails to run on Windows VM due to missing in-cluster configuration #6687

Closed
XinShuYang opened this issue Sep 24, 2024 · 6 comments · Fixed by #6840
Closed

antctl.exe fails to run on Windows VM due to missing in-cluster configuration #6687

XinShuYang opened this issue Sep 24, 2024 · 6 comments · Fixed by #6840
Assignees
Labels
area/OS/windows Issues or PRs related to the Windows operating system. kind/bug Categorizes issue or PR as related to a bug.

Comments

@XinShuYang
Copy link
Contributor

Describe the bug
Running antctl.exe on a Windows VM results in an error. The same command works fine when executed inside a Windows pod.

To Reproduce

  1. Run antctl.exe supportbundle on a Windows Node.
  2. Observe the error output.

Expected
The command antctl.exe supportbundle should execute successfully on the Windows VM, similar to how it works inside the Windows pod.

Actual behavior
When executing antctl.exe on a Windows VM, the following error is returned:

PS C:\k\antrea\bin> .\antctl.exe supportbundle  
Error: error when creating system client: unable to load in-cluster configuration, KUBERNETES_SERVICE_HOST and KUBERNETES_SERVICE_PORT must be defined  

Versions:
Antrea v2.1

@XinShuYang XinShuYang added area/OS/windows Issues or PRs related to the Windows operating system. kind/bug Categorizes issue or PR as related to a bug. labels Sep 24, 2024
@luolanzone
Copy link
Contributor

@XinShuYang have you tried to define the KUBECONFIG env and rerun? I think this is expected when there is no right config file.

@luolanzone luolanzone added this to the Antrea v2.3 release milestone Oct 18, 2024
@luolanzone
Copy link
Contributor

@XinShuYang can you prioritize the bug fix for this issue in Antrea 2.3?

@XinShuYang
Copy link
Contributor Author

XinShuYang commented Nov 28, 2024

@XinShuYang have you tried to define the KUBECONFIG env and rerun? I think this is expected when there is no right config file.

@luolanzone I believe the root cause is the expired kubeconfig file on the Windows testbed. On a new created Kubernetes cluster, I cannot reproduce this issue, but after modifying or removing the kubeconfig file, I can reproduce the same error.

The KUBECONFIG env is not mandatory. According to the current implementation, the correct kubeconfig path can be obtained from clientcmd.RecommendedHomeFile if KUBECONFIG is not set(actually it has never been set on our windows testbed). Therefore, the root cause should be the unavailability of the kubeconfig file itself.

path, hasIt = os.LookupEnv("KUBECONFIG")
if !hasIt || len(strings.TrimSpace(path)) == 0 {
path = clientcmd.RecommendedHomeFile
}

@luolanzone
Copy link
Contributor

@XinShuYang is possible to detect that antctl is out of a Pod and skip checking in-cluster config? just return kubeconfig file not found error directly if it's outside of a Pod

@wenyingd
Copy link
Contributor

wenyingd commented Nov 29, 2024

@XinShuYang is possible to detect that antctl is out of a Pod and skip checking in-cluster config? just return kubeconfig file not found error directly if it's outside of a Pod

@luolanzone Do you mean we will drop the support to run antctl on VM (in-cluster config is detected if running inside Pod)?

@XinShuYang
Copy link
Contributor Author

@XinShuYang is possible to detect that antctl is out of a Pod and skip checking in-cluster config? just return kubeconfig file not found error directly if it's outside of a Pod

@luolanzone In-cluster config method was added in #3645 , so even without kubeconfig file the client will still try to get in-cluster config. But I think we can enhance the error log for debugging purpose.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/OS/windows Issues or PRs related to the Windows operating system. kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants