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
Out-of-the-box "Agent mode" support for antctl on Windows #3645
Out-of-the-box "Agent mode" support for antctl on Windows #3645
Conversation
At the moment is is possible to run antctl in Agent mode from a Windows Node on which Antrea is runing, but it requires setting the following environment variables manually: ``` > $Env:POD_NAME="antrea-agent" > $Env:KUBERNETES_SERVICE_HOST="<ClusterIP>" > $Env:KUBERNETES_SERVICE_PORT="443" ``` This is not very convenient and it is not documented either. Additionally, there is no reason to require KUBERNETES_SERVICE_HOST and KUBERNETES_SERVICE_PORT in Agent mode. This requirement is caused by a bug in the antctl code: when antctl is running inside a Pod, there is no need to resolve the "in-cluster" Kubeconfig, as we generate this config manually to connect to the Antrea API server. In order to make antctl work out-of-the-box for that case, we change the logic which decides what the antctl "runtime mode" is: if the antctl binary is running on Windows and if a loopback client token exists, we assume that this is a Windows Node which is running the Antrea Agent. Fixes antrea-io#2104 Signed-off-by: Antonin Bas <abas@vmware.com>
I tested this manually on a Windows K8s Node. I will also try to enable the antctl tests for Windows. |
Signed-off-by: Antonin Bas <abas@vmware.com>
/test-all |
Codecov Report
@@ Coverage Diff @@
## main #3645 +/- ##
==========================================
+ Coverage 63.56% 64.47% +0.90%
==========================================
Files 278 278
Lines 39360 39363 +3
==========================================
+ Hits 25020 25380 +360
+ Misses 12420 11999 -421
- Partials 1920 1984 +64
Flags with carried forward coverage won't be shown. Click here to find out more.
|
@@ -53,6 +56,15 @@ func init() { | |||
podName, found := os.LookupEnv("POD_NAME") | |||
InPod = found && (strings.HasPrefix(podName, "antrea-agent") || strings.HasPrefix(podName, "antrea-controller") || | |||
strings.HasPrefix(podName, "flow-aggregator")) | |||
|
|||
if runtime.IsWindowsPlatform() && !InPod { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I remember the default mode is ControllerMode if no environment variable settings, this design supports antctl on a remote client other than K8s Node. I doubt change may cause antctl fails to run on a remote Windows client?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be no token on a remote client.
The only issue is if you want antctl controller mode on a Windows K8s Node, which doesn't seem like something someone would typically do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/test-windows-e2e |
At the moment is is possible to run antctl in Agent mode from a Windows
Node on which Antrea is runing, but it requires setting the following
environment variables manually:
This is not very convenient and it is not documented
either. Additionally, there is no reason to require
KUBERNETES_SERVICE_HOST and KUBERNETES_SERVICE_PORT in Agent mode. This
requirement is caused by a bug in the antctl code: when antctl is
running inside a Pod, there is no need to resolve the "in-cluster"
Kubeconfig, as we generate this config manually to connect to the Antrea
API server.
In order to make antctl work out-of-the-box for that case, we change the
logic which decides what the antctl "runtime mode" is: if the antctl
binary is running on Windows and if a loopback client token exists, we
assume that this is a Windows Node which is running the Antrea Agent.
Fixes #2104
Signed-off-by: Antonin Bas abas@vmware.com